/** * Returns the portion of this domain name that is one level beneath the {@linkplain * #isRegistrySuffix() registry suffix}. For example, for {@code x.adwords.google.co.uk} it * returns {@code google.co.uk}, since {@code co.uk} is a registry suffix. Similarly, for {@code * myblog.blogspot.com} it returns {@code blogspot.com}, since {@code com} is a registry suffix. * * <p>If {@link #isTopDomainUnderRegistrySuffix()} is true, the current domain name instance is * returned. * * <p><b>Warning:</b> This method should not be used to determine whether a domain is probably the * highest level for which cookies may be set. Use {@link #isTopPrivateDomain()} for that purpose. * * @throws IllegalStateException if this domain does not end with a registry suffix * @since 23.3 */ public InternetDomainName topDomainUnderRegistrySuffix() { if (isTopDomainUnderRegistrySuffix()) { return this; } checkState(isUnderRegistrySuffix(), "Not under a registry suffix: %s", name); return ancestor(registrySuffixIndex - 1); }
/** * Returns the portion of this domain name that is one level beneath the {@linkplain * #isRegistrySuffix() registry suffix}. For example, for {@code x.adwords.google.co.uk} it * returns {@code google.co.uk}, since {@code co.uk} is a registry suffix. Similarly, for {@code * myblog.blogspot.com} it returns {@code blogspot.com}, since {@code com} is a registry suffix. * * <p>If {@link #isTopDomainUnderRegistrySuffix()} is true, the current domain name instance is * returned. * * <p><b>Warning:</b> This method should not be used to determine whether a domain is probably the * highest level for which cookies may be set. Use {@link #isTopPrivateDomain()} for that purpose. * * @throws IllegalStateException if this domain does not end with a registry suffix * @since 23.3 */ public InternetDomainName topDomainUnderRegistrySuffix() { if (isTopDomainUnderRegistrySuffix()) { return this; } checkState(isUnderRegistrySuffix(), "Not under a registry suffix: %s", name); return ancestor(registrySuffixIndex - 1); }
/** * Returns the portion of this domain name that is one level beneath the {@linkplain * #isRegistrySuffix() registry suffix}. For example, for {@code x.adwords.google.co.uk} it * returns {@code google.co.uk}, since {@code co.uk} is a registry suffix. Similarly, for {@code * myblog.blogspot.com} it returns {@code blogspot.com}, since {@code com} is a registry suffix. * * <p>If {@link #isTopDomainUnderRegistrySuffix()} is true, the current domain name instance is * returned. * * <p><b>Warning:</b> This method should not be used to determine whether a domain is probably the * highest level for which cookies may be set. Use {@link #isTopPrivateDomain()} for that purpose. * * @throws IllegalStateException if this domain does not end with a registry suffix * @since 23.3 */ public InternetDomainName topDomainUnderRegistrySuffix() { if (isTopDomainUnderRegistrySuffix()) { return this; } checkState(isUnderRegistrySuffix(), "Not under a registry suffix: %s", name); return ancestor(registrySuffixIndex - 1); }
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()); } }
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()); } }
public void testRegistrySuffix() { for (String name : RS) { final InternetDomainName domain = InternetDomainName.from(name); assertTrue(name, domain.isRegistrySuffix()); assertTrue(name, domain.hasRegistrySuffix()); assertFalse(name, domain.isUnderRegistrySuffix()); assertFalse(name, domain.isTopDomainUnderRegistrySuffix()); assertEquals(domain, domain.registrySuffix()); } for (String name : NO_RS) { final InternetDomainName domain = InternetDomainName.from(name); assertFalse(name, domain.isRegistrySuffix()); assertFalse(name, domain.hasRegistrySuffix()); assertFalse(name, domain.isUnderRegistrySuffix()); assertFalse(name, domain.isTopDomainUnderRegistrySuffix()); assertNull(domain.registrySuffix()); } for (String name : NON_RS) { final InternetDomainName domain = InternetDomainName.from(name); assertFalse(name, domain.isRegistrySuffix()); assertTrue(name, domain.hasRegistrySuffix()); assertTrue(name, domain.isUnderRegistrySuffix()); } }
/** * Returns the portion of this domain name that is one level beneath the {@linkplain * #isRegistrySuffix() registry suffix}. For example, for {@code x.adwords.google.co.uk} it * returns {@code google.co.uk}, since {@code co.uk} is a registry suffix. Similarly, for {@code * myblog.blogspot.com} it returns {@code blogspot.com}, since {@code com} is a registry suffix. * * <p>If {@link #isTopDomainUnderRegistrySuffix()} is true, the current domain name instance is * returned. * * <p><b>Warning:</b> This method should not be used to determine whether a domain is probably the * highest level for which cookies may be set. Use {@link #isTopPrivateDomain()} for that purpose. * * @throws IllegalStateException if this domain does not end with a registry suffix * @since 23.3 */ public InternetDomainName topDomainUnderRegistrySuffix() { if (isTopDomainUnderRegistrySuffix()) { return this; } checkState(isUnderRegistrySuffix(), "Not under a registry suffix: %s", name); return ancestor(registrySuffixIndex - 1); }
/** * Returns the portion of this domain name that is one level beneath the {@linkplain * #isRegistrySuffix() registry suffix}. For example, for {@code x.adwords.google.co.uk} it * returns {@code google.co.uk}, since {@code co.uk} is a registry suffix. Similarly, for {@code * myblog.blogspot.com} it returns {@code blogspot.com}, since {@code com} is a registry suffix. * * <p>If {@link #isTopDomainUnderRegistrySuffix()} is true, the current domain name instance is * returned. * * <p><b>Warning:</b> This method should not be used to determine whether a domain is probably the * highest level for which cookies may be set. Use {@link #isTopPrivateDomain()} for that purpose. * * @throws IllegalStateException if this domain does not end with a registry suffix * @since 23.3 */ public InternetDomainName topDomainUnderRegistrySuffix() { if (isTopDomainUnderRegistrySuffix()) { return this; } checkState(isUnderRegistrySuffix(), "Not under a registry suffix: %s", name); return ancestor(registrySuffixIndex - 1); }
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()); } }
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()); } }
public void testRegistrySuffix() { for (String name : RS) { final InternetDomainName domain = InternetDomainName.from(name); assertTrue(name, domain.isRegistrySuffix()); assertTrue(name, domain.hasRegistrySuffix()); assertFalse(name, domain.isUnderRegistrySuffix()); assertFalse(name, domain.isTopDomainUnderRegistrySuffix()); assertEquals(domain, domain.registrySuffix()); } for (String name : NO_RS) { final InternetDomainName domain = InternetDomainName.from(name); assertFalse(name, domain.isRegistrySuffix()); assertFalse(name, domain.hasRegistrySuffix()); assertFalse(name, domain.isUnderRegistrySuffix()); assertFalse(name, domain.isTopDomainUnderRegistrySuffix()); assertNull(domain.registrySuffix()); } for (String name : NON_RS) { final InternetDomainName domain = InternetDomainName.from(name); assertFalse(name, domain.isRegistrySuffix()); assertTrue(name, domain.hasRegistrySuffix()); assertTrue(name, domain.isUnderRegistrySuffix()); } }