Class ZoneIdSupport


  • @Internal
    public final class ZoneIdSupport
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean appendBracketedIPv6​(java.lang.StringBuilder buf, java.lang.CharSequence host)
      Appends a bracketed IPv6 literal to buf if host looks like IPv6.
      static java.lang.String decodeZoneId​(java.lang.CharSequence host)
      RFC 6874 decoder for bracket contents of an IPv6 literal.
      static java.lang.String encodeZoneIdRfc6874​(java.lang.CharSequence raw)
      RFC 6874 encoder for ZoneID: emits unreserved characters as-is and percent-encodes everything else using UTF-8 with UPPERCASE hex digits.
      static boolean looksLikeIPv6AddressPart​(java.lang.CharSequence host)
      Heuristic: returns true if host looks like an IPv6 address-part (i.e., before any ZoneID) by counting colons.
      static void validateZoneIdEncoded​(java.lang.CharSequence enc)
      RFC 6874 ZoneID validator:
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • encodeZoneIdRfc6874

        public static java.lang.String encodeZoneIdRfc6874​(java.lang.CharSequence raw)
        RFC 6874 encoder for ZoneID: emits unreserved characters as-is and percent-encodes everything else using UTF-8 with UPPERCASE hex digits. Existing %HH triplets are passed through unchanged.
      • decodeZoneId

        public static java.lang.String decodeZoneId​(java.lang.CharSequence host)
        RFC 6874 decoder for bracket contents of an IPv6 literal. Input: "addr%25<enc-zone>" ? Output internal form: "addr%<decoded-zone>". If there is no "%25" delimiter, returns the input as-is.
      • validateZoneIdEncoded

        public static void validateZoneIdEncoded​(java.lang.CharSequence enc)
        RFC 6874 ZoneID validator:
        ZoneID = 1*( unreserved / pct-encoded )
        Throws IllegalArgumentException on invalid input.
      • looksLikeIPv6AddressPart

        public static boolean looksLikeIPv6AddressPart​(java.lang.CharSequence host)
        Heuristic: returns true if host looks like an IPv6 address-part (i.e., before any ZoneID) by counting colons. We do not parse/validate IPv6; this keeps our surface minimal while still bracketing correctly.

        Rule: if the address-part (up to '%', if present) contains >= 2 colons, treat it as IPv6-like.

      • appendBracketedIPv6

        public static boolean appendBracketedIPv6​(java.lang.StringBuilder buf,
                                                  java.lang.CharSequence host)
        Appends a bracketed IPv6 literal to buf if host looks like IPv6. If a ZoneID is present (after '%'), it is written as "%25" followed by the RFC 6874-encoded ZoneID. Returns true iff it wrote the bracketed literal.