Package org.apache.hc.core5.net
Class ZoneIdSupport
- java.lang.Object
-
- org.apache.hc.core5.net.ZoneIdSupport
-
@Internal public final class ZoneIdSupport extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanappendBracketedIPv6(java.lang.StringBuilder buf, java.lang.CharSequence host)Appends a bracketed IPv6 literal tobufifhostlooks like IPv6.static java.lang.StringdecodeZoneId(java.lang.CharSequence host)RFC 6874 decoder for bracket contents of an IPv6 literal.static java.lang.StringencodeZoneIdRfc6874(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 booleanlooksLikeIPv6AddressPart(java.lang.CharSequence host)Heuristic: returnstrueifhostlooks like an IPv6 address-part (i.e., before any ZoneID) by counting colons.static voidvalidateZoneIdEncoded(java.lang.CharSequence enc)RFC 6874 ZoneID validator:
-
-
-
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 )
ThrowsIllegalArgumentExceptionon invalid input.
-
looksLikeIPv6AddressPart
public static boolean looksLikeIPv6AddressPart(java.lang.CharSequence host)
Heuristic: returnstrueifhostlooks 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 tobufifhostlooks like IPv6. If a ZoneID is present (after '%'), it is written as"%25"followed by the RFC 6874-encoded ZoneID. Returnstrueiff it wrote the bracketed literal.
-
-