Tabnine Logo
InternetDomainName.parent
Code IndexAdd Tabnine to your IDE (free)

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

Best Java code snippets using com.google.common.net.InternetDomainName.parent (Showing top 14 results out of 315)

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

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: internetarchive/heritrix3

/**
 * Returns a {@link LimitedCookieStoreFacade} whose
 * {@link LimitedCookieStoreFacade#getCookies()} method returns only cookies
 * from {@code host} and its parent domains, if applicable.
 */
public CookieStore cookieStoreFor(String host) {
  CompositeCollection cookieCollection = new CompositeCollection();
  if (InternetDomainName.isValid(host)) {
    InternetDomainName domain = InternetDomainName.from(host);
    while (domain != null) {
      Collection<Cookie> subset = hostSubset(domain.toString());
      cookieCollection.addComposited(subset);
      if (domain.hasParent()) {
        domain = domain.parent();
      } else {
        domain = null;
      }
    }
  } else {
    Collection<Cookie> subset = hostSubset(host.toString());
    cookieCollection.addComposited(subset);
  }
  @SuppressWarnings("unchecked")
  List<Cookie> cookieList = new RestrictedCollectionWrappedList<Cookie>(cookieCollection);
  LimitedCookieStoreFacade store = new LimitedCookieStoreFacade(cookieList);
  return store;
}
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());
 }
}
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: uk.bl.wa.discovery/warc-indexer

private static ImmutableList.Builder<String> parentLevels(InternetDomainName internetDomainName) {
  ImmutableList.Builder<String> levels;
  if(internetDomainName.hasParent()){
    levels = parentLevels(internetDomainName.parent());
  }
  else {
    levels = ImmutableList.builder();
  }
  levels.add(internetDomainName.toString());
  return levels;
}
origin: ukwa/webarchive-discovery

private static ImmutableList.Builder<String> parentLevels(InternetDomainName internetDomainName) {
  ImmutableList.Builder<String> levels;
  if(internetDomainName.hasParent()){
    levels = parentLevels(internetDomainName.parent());
  }
  else {
    levels = ImmutableList.builder();
  }
  levels.add(internetDomainName.toString());
  return levels;
}
origin: googlesamples/android-AutofillFramework

public static String getCanonicalDomain(String domain) {
  InternetDomainName idn = InternetDomainName.from(domain);
  while (idn != null && !idn.isTopPrivateDomain()) {
    idn = idn.parent();
  }
  return idn == null ? null : idn.toString();
}
origin: tcplugins/tcWebHooks

  @Override
  public GeneralisedWebAddress getGeneralisedHostName(URL url) {
    String host = url.getHost();
//        if (! url.getHost().contains(".")) {
//            return GeneralisedWebAddress.build(host, GeneralisedWebAddressType.HOST_ADDRESS);
//        } else 
    InetAddress ip = extractInetAddress(host);
    if (ip != null) {
      if (ip instanceof Inet4Address ) {
        return GeneralisedWebAddress.build(host.replaceFirst("\\d+$", ""), GeneralisedWebAddressType.IPV4_ADDRESS);
      } else if (ip instanceof Inet6Address) {
        return GeneralisedWebAddress.build(ip.getHostAddress(), GeneralisedWebAddressType.IPV6_ADDRESS);
      }
    } else if (InternetDomainName.isValid(host)) { 
      InternetDomainName domainName = InternetDomainName.from(host);
      if (domainName.isUnderPublicSuffix()) {
        return GeneralisedWebAddress.build(domainName.topPrivateDomain().toString(), GeneralisedWebAddressType.DOMAIN_NAME);
      } else if (domainName.hasParent()) {
        return GeneralisedWebAddress.build(domainName.parent().toString(), GeneralisedWebAddressType.DOMAIN_NAME);
      }
      return GeneralisedWebAddress.build(host, GeneralisedWebAddressType.HOST_ADDRESS);
    }
    
    return null;
  }
  
origin: com.google.guava/guava-tests

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: com.google.guava/guava-tests

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: org.archive.heritrix/heritrix-modules

/**
 * Returns a {@link LimitedCookieStoreFacade} whose
 * {@link LimitedCookieStoreFacade#getCookies()} method returns only cookies
 * from {@code host} and its parent domains, if applicable.
 */
public CookieStore cookieStoreFor(String host) {
  CompositeCollection cookieCollection = new CompositeCollection();
  if (InternetDomainName.isValid(host)) {
    InternetDomainName domain = InternetDomainName.from(host);
    while (domain != null) {
      Collection<Cookie> subset = hostSubset(domain.toString());
      cookieCollection.addComposited(subset);
      if (domain.hasParent()) {
        domain = domain.parent();
      } else {
        domain = null;
      }
    }
  } else {
    Collection<Cookie> subset = hostSubset(host.toString());
    cookieCollection.addComposited(subset);
  }
  @SuppressWarnings("unchecked")
  List<Cookie> cookieList = new RestrictedCollectionWrappedList<Cookie>(cookieCollection);
  LimitedCookieStoreFacade store = new LimitedCookieStoreFacade(cookieList);
  return store;
}
origin: com.google.guava/guava-tests

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: com.google.guava/guava-tests

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.netInternetDomainNameparent

Javadoc

Returns an InternetDomainName that is the immediate ancestor of this one; that is, the current domain with the leftmost part removed. For example, the parent of www.google.com is google.com.

Popular methods of InternetDomainName

  • from
    Returns an instance of InternetDomainName after lenient validation. Specifically, validation against
  • 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
  • validateSyntax,
  • topPrivateDomain,
  • name,
  • findPublicSuffix,
  • matchesWildcardPublicSuffix,
  • parts,
  • child,
  • hasRegistrySuffix,
  • isTopDomainUnderRegistrySuffix,
  • isUnderRegistrySuffix

Popular in Java

  • Creating JSON documents from java classes using gson
  • scheduleAtFixedRate (ScheduledExecutorService)
  • compareTo (BigDecimal)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now