MCPcopy
hub / github.com/google/guava / InternetDomainName

Class InternetDomainName

guava/src/com/google/common/net/InternetDomainName.java:73–643  ·  view source on GitHub ↗

An immutable well-formed internet domain name, such as {@code com} or {@code foo.co.uk}. Only syntactic analysis is performed; no DNS lookups or other network interactions take place. Thus there is no guarantee that the domain actually exists on the internet. <p>One common use of this class is to d

Source from the content-addressed store, hash-verified

71 * @since 5.0
72 */
73@GwtCompatible
74@Immutable
75public final class InternetDomainName {
76
77 private static final CharMatcher DOTS_MATCHER = CharMatcher.anyOf(".\u3002\uFF0E\uFF61");
78 private static final Splitter DOT_SPLITTER = Splitter.on('.');
79
80 /**
81 * Value of {@link #publicSuffixIndex()} or {@link #registrySuffixIndex()} which indicates that no
82 * relevant suffix was found.
83 */
84 private static final int NO_SUFFIX_FOUND = -1;
85
86 /**
87 * Value of {@link #publicSuffixIndexCache} or {@link #registrySuffixIndexCache} which indicates
88 * that they were not initialized yet.
89 */
90 private static final int SUFFIX_NOT_INITIALIZED = -2;
91
92 /**
93 * Maximum parts (labels) in a domain name. This value arises from the 255-octet limit described
94 * in <a href="http://www.ietf.org/rfc/rfc2181.txt">RFC 2181</a> part 11 with the fact that the
95 * encoding of each part occupies at least two bytes (dot plus label externally, length byte plus
96 * label internally). Thus, if all labels have the minimum size of one byte, 127 of them will fit.
97 */
98 private static final int MAX_PARTS = 127;
99
100 /**
101 * Maximum length of a full domain name, including separators, and leaving room for the root
102 * label. See <a href="http://www.ietf.org/rfc/rfc2181.txt">RFC 2181</a> part 11.
103 */
104 private static final int MAX_LENGTH = 253;
105
106 /**
107 * Maximum size of a single part of a domain name. See <a
108 * href="http://www.ietf.org/rfc/rfc2181.txt">RFC 2181</a> part 11.
109 */
110 private static final int MAX_DOMAIN_PART_LENGTH = 63;
111
112 /** The full domain name, converted to lower case. */
113 private final String name;
114
115 /** The parts of the domain name, converted to lower case. */
116 private final ImmutableList<String> parts;
117
118 /**
119 * Cached value of #publicSuffixIndex(). Do not use directly.
120 *
121 * <p>Since this field isn't {@code volatile}, if an instance of this class is shared across
122 * threads before it is initialized, then each thread is likely to compute their own copy of the
123 * value.
124 */
125 @SuppressWarnings("Immutable")
126 @LazyInit
127 private int publicSuffixIndexCache = SUFFIX_NOT_INITIALIZED;
128
129 /**
130 * Cached value of #registrySuffixIndex(). Do not use directly.

Callers

nothing calls this directly

Calls 4

anyOfMethod · 0.95
onMethod · 0.95
inRangeMethod · 0.95
orMethod · 0.45

Tested by

no test coverage detected