Codota Logo
InternetDomainName.from
Code IndexAdd Codota to your IDE (free)

How to use
from
method
in
com.google.common.net.InternetDomainName

Best Java code snippets using com.google.common.net.InternetDomainName.from (Showing top 20 results out of 450)

  • Common ways to obtain InternetDomainName
private void myMethod () {
InternetDomainName i =
  • Codota IconString domain;InternetDomainName.from(domain)
  • Codota IconPreconditions preconditions;Object reference;new InternetDomainName(preconditions.checkNotNull(reference))
  • Smart code suggestions by Codota
}
origin: google/guava

/**
 * Creates and returns a new {@code InternetDomainName} by prepending the argument and a dot to
 * the current name. For example, {@code InternetDomainName.from("foo.com").child("www.bar")}
 * returns a new {@code InternetDomainName} with the value {@code www.bar.foo.com}. Only lenient
 * validation is performed, as described {@link #from(String) here}.
 *
 * @throws NullPointerException if leftParts is null
 * @throws IllegalArgumentException if the resulting name is not valid
 */
public InternetDomainName child(String leftParts) {
 return from(checkNotNull(leftParts) + "." + name);
}
origin: google/guava

public void testValid() {
 for (String name : VALID_NAME) {
  InternetDomainName.from(name);
 }
}
origin: google/guava

/**
 * Returns the ancestor of the current domain at the given number of levels "higher" (rightward)
 * in the subdomain list. The number of levels must be non-negative, and less than {@code N-1},
 * where {@code N} is the number of parts in the domain.
 *
 * <p>TODO: Reasonable candidate for addition to public API.
 */
private InternetDomainName ancestor(int levels) {
 return from(DOT_JOINER.join(parts.subList(levels, parts.size())));
}
origin: google/guava

 public PackageSanityTests() {
  setDefault(InternetDomainName.class, InternetDomainName.from("google.com"));
 }
}
origin: google/guava

public void testInvalid() {
 for (String name : INVALID_NAME) {
  try {
   InternetDomainName.from(name);
   fail("Should have been invalid: '" + name + "'");
  } catch (IllegalArgumentException expected) {
  }
 }
}
origin: google/guava

public void testInvalidTopPrivateDomain() {
 ImmutableSet<String> badCookieDomains = ImmutableSet.of("co.uk", "foo", "com");
 for (String domain : badCookieDomains) {
  try {
   InternetDomainName.from(domain).topPrivateDomain();
   fail(domain);
  } catch (IllegalStateException expected) {
  }
 }
}
origin: google/guava

public void testParent() {
 assertEquals("com", InternetDomainName.from("google.com").parent().toString());
 assertEquals("uk", InternetDomainName.from("co.uk").parent().toString());
 assertEquals("google.com", InternetDomainName.from("www.google.com").parent().toString());
 try {
  InternetDomainName.from("com").parent();
  fail("'com' should throw ISE on .parent() call");
 } catch (IllegalStateException expected) {
 }
}
origin: google/guava

 @GwtIncompatible // NullPointerTester
 public void testNulls() {
  final NullPointerTester tester = new NullPointerTester();

  tester.testAllPublicStaticMethods(InternetDomainName.class);
  tester.testAllPublicInstanceMethods(InternetDomainName.from("google.com"));
 }
}
origin: google/guava

public void testParentChild() {
 InternetDomainName origin = InternetDomainName.from("foo.com");
 InternetDomainName parent = origin.parent();
 assertEquals("com", parent.toString());
 // These would throw an exception if leniency were not preserved during parent() and child()
 // calls.
 InternetDomainName child = parent.child(LOTS_OF_DELTAS);
 child.child(LOTS_OF_DELTAS);
}
origin: google/guava

public void testChild() {
 InternetDomainName domain = InternetDomainName.from("foo.com");
 assertEquals("www.foo.com", domain.child("www").toString());
 try {
  domain.child("www.");
  fail("www..google.com should have been invalid");
 } catch (IllegalArgumentException expected) {
 }
}
origin: google/guava

public void testUnderPublicSuffix() {
 for (String name : SOMEWHERE_UNDER_PS) {
  final InternetDomainName domain = InternetDomainName.from(name);
  assertFalse(name, domain.isPublicSuffix());
  assertTrue(name, domain.hasPublicSuffix());
  assertTrue(name, domain.isUnderPublicSuffix());
 }
}
origin: google/guava

public void testUnderRegistrySuffix() {
 for (String name : SOMEWHERE_UNDER_RS) {
  final InternetDomainName domain = InternetDomainName.from(name);
  assertFalse(name, domain.isRegistrySuffix());
  assertTrue(name, domain.hasRegistrySuffix());
  assertTrue(name, domain.isUnderRegistrySuffix());
 }
}
origin: google/guava

public void testUnderTopDomainUnderRegistrySuffix() {
 for (String name : UNDER_TOP_UNDER_REGISTRY_SUFFIX) {
  final InternetDomainName domain = InternetDomainName.from(name);
  assertFalse(name, domain.isRegistrySuffix());
  assertTrue(name, domain.hasRegistrySuffix());
  assertTrue(name, domain.isUnderRegistrySuffix());
  assertFalse(name, domain.isTopDomainUnderRegistrySuffix());
 }
}
origin: google/guava

public void testRegistrySuffixMultipleUnders() {
 // PSL has both *.uk and *.sch.uk; the latter should win.
 // See http://code.google.com/p/guava-libraries/issues/detail?id=1176
 InternetDomainName domain = InternetDomainName.from("www.essex.sch.uk");
 assertTrue(domain.hasRegistrySuffix());
 assertEquals("essex.sch.uk", domain.registrySuffix().toString());
 assertEquals("www.essex.sch.uk", domain.topDomainUnderRegistrySuffix().toString());
}
origin: google/guava

public void testRegistrySuffixExclusion() {
 InternetDomainName domain = InternetDomainName.from("foo.city.yokohama.jp");
 assertTrue(domain.hasRegistrySuffix());
 assertEquals("yokohama.jp", domain.registrySuffix().toString());
 // Behold the weirdness!
 assertFalse(domain.registrySuffix().isRegistrySuffix());
}
origin: google/guava

public void testPublicSuffixMultipleUnders() {
 // PSL has both *.uk and *.sch.uk; the latter should win.
 // See http://code.google.com/p/guava-libraries/issues/detail?id=1176
 InternetDomainName domain = InternetDomainName.from("www.essex.sch.uk");
 assertTrue(domain.hasPublicSuffix());
 assertEquals("essex.sch.uk", domain.publicSuffix().toString());
 assertEquals("www.essex.sch.uk", domain.topPrivateDomain().toString());
}
origin: google/guava

public void testPublicSuffixExclusion() {
 InternetDomainName domain = InternetDomainName.from("foo.city.yokohama.jp");
 assertTrue(domain.hasPublicSuffix());
 assertEquals("yokohama.jp", domain.publicSuffix().toString());
 // Behold the weirdness!
 assertFalse(domain.publicSuffix().isPublicSuffix());
}
origin: google/guava

public void testUnderPrivateDomain() {
 for (String name : UNDER_PRIVATE_DOMAIN) {
  final InternetDomainName domain = InternetDomainName.from(name);
  assertFalse(name, domain.isPublicSuffix());
  assertTrue(name, domain.hasPublicSuffix());
  assertTrue(name, domain.isUnderPublicSuffix());
  assertFalse(name, domain.isTopPrivateDomain());
 }
}
origin: google/guava

public void testTopDomainUnderRegistrySuffix() {
 for (String name : TOP_UNDER_REGISTRY_SUFFIX) {
  final InternetDomainName domain = InternetDomainName.from(name);
  assertFalse(name, domain.isRegistrySuffix());
  assertTrue(name, domain.hasRegistrySuffix());
  assertTrue(name, domain.isUnderRegistrySuffix());
  assertTrue(name, domain.isTopDomainUnderRegistrySuffix());
  assertEquals(domain.parent(), domain.registrySuffix());
 }
}
origin: google/guava

public void testTopPrivateDomain() {
 for (String name : TOP_PRIVATE_DOMAIN) {
  final InternetDomainName domain = InternetDomainName.from(name);
  assertFalse(name, domain.isPublicSuffix());
  assertTrue(name, domain.hasPublicSuffix());
  assertTrue(name, domain.isUnderPublicSuffix());
  assertTrue(name, domain.isTopPrivateDomain());
  assertEquals(domain.parent(), domain.publicSuffix());
 }
}
com.google.common.netInternetDomainNamefrom

Javadoc

Returns an instance of InternetDomainName after lenient validation. Specifically, validation against RFC 3490 ("Internationalizing Domain Names in Applications") is skipped, while validation against RFC 1035 is relaxed in the following ways:
  • Any part containing non-ASCII characters is considered valid.
  • Underscores ('_') are permitted wherever dashes ('-') are permitted.
  • Parts other than the final part may start with a digit, as mandated by RFC 1123.

Popular methods of InternetDomainName

  • toString
    Returns the domain name, normalized to all lower case.
  • hasPublicSuffix
    Indicates whether this domain name ends in a #isPublicSuffix(), including if it is a public suffix i
  • isValid
    Indicates whether the argument is a syntactically valid domain name using lenient validation. Specif
  • isUnderPublicSuffix
    Indicates whether this domain name ends in a #isPublicSuffix(), while not being a public suffix itse
  • isTopPrivateDomain
    Indicates whether this domain name is composed of exactly one subdomain component followed by a #isP
  • hasParent
    Indicates whether this domain is composed of two or more parts.
  • <init>
    Private constructor used to implement #ancestor(int). Argument parts are assumed to be valid, as the
  • ancestor
    Returns the ancestor of the current domain at the given number of levels "higher" (rightward) in the
  • validatePart
    Helper method for #validateSyntax(List). Validates that one part of a domain name is valid.
  • validateSyntax
    Validation method used by to ensure that the domain name is syntactically valid according to RFC 103
  • topPrivateDomain
    Returns the portion of this domain name that is one level beneath the public suffix. For example, fo
  • name
    Returns the domain name, normalized to all lower case.
  • topPrivateDomain,
  • name,
  • findPublicSuffix,
  • matchesWildcardPublicSuffix,
  • parts,
  • child,
  • hasRegistrySuffix,
  • isTopDomainUnderRegistrySuffix,
  • isUnderRegistrySuffix

Popular in Java

  • Reactive rest calls using spring rest template
  • scheduleAtFixedRate (Timer)
  • getExternalFilesDir (Context)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • KeyStore (java.security)
    This class represents an in-memory collection of keys and certificates. It manages two types of entr
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.This exception may include information for locating the er
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now