test_class.declarator: logger = LoggerFactory.getLogger(TestURIUtil.class)
test_class.modifier: final
test_class.original_string: final Logger logger = LoggerFactory.getLogger(TestURIUtil.class);
test_class.type: Logger
test_class.var_name: logger
test_class.file: sparqled-commons/src/test/java/org/sindice/core/analytics/commons/util/TestURIUtil.java
test_class.identifier: TestURIUtil
test_case.body: @Test
    public void testSecondDomain() {
      String[] testStrings = new String[] {
          "google.com -> google.com",
          "www.webaddict.za -> webaddict.za",
          "wilma     ->       null",
          "wilma.blogSpot.com  -> blogspot.com",
          "repubblica.it  -> repubblica.it",
          "isti.pomino.cnr.it -> cnr.it",
          "thelakersnation.com -> thelakersnation.com",
          "bio2rdf.org -> bio2rdf.org",
          "awakenedmmo.org -> awakenedmmo.org",
          "cheminfov.informatics.indiana.edu -> indiana.edu",
          "data-gov.tw.rpi.edu -> rpi.edu",
          "www.test.webaddict.co.za -> webaddict.co.za",
          "www.webaddict.co.za -> webaddict.co.za",
          "mxr.mozilla.org -> mozilla.org",
          "www.yago.zitgist.com -> zitgist.com",
          "aims.fao.org -> fao.org",
          "en.wikipedia.org -> wikipedia.org",
          "127.0.0.100 -> null",
          "http://en.wikipedia.org -> null"
      };
      for (String s : testStrings) {
        String[] elems = s.split("\\s+->\\s+");
        String domain = elems[0];
        String expectedSecondDomain = elems[1];
        logger.info("Check if sndDomain of {} equals {}", domain, expectedSecondDomain);
        final String sndDomain = URIUtil.getSndDomain(domain);
        assertEquals(sndDomain == null ? "null" : sndDomain, expectedSecondDomain);
  
      }
      assertEquals(null, URIUtil.getSndDomain(""));
      assertEquals(null, URIUtil.getSndDomain(null));
    }
test_case.class_method_signature: TestURIUtil.testSecondDomain()
test_case.full_signature: @Test public void testSecondDomain()
test_case.identifier: testSecondDomain
test_case.invocations: split info getSndDomain assertEquals assertEquals getSndDomain assertEquals getSndDomain
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testSecondDomain()
focal_class.declarator: logger = LoggerFactory.getLogger(URIUtil.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(URIUtil.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.file: sparqled-commons/src/main/java/org/sindice/core/analytics/commons/util/URIUtil.java
focal_class.identifier: URIUtil
focal_class.class_method_signature: URIUtil.getSndDomainFromUrl(String url)
focal_class.full_signature: public static String getSndDomainFromUrl(String url)
focal_class.identifier: getSndDomainFromUrl
focal_class.modifiers: public static
focal_class.parameters: (String url)
focal_class.return: String
focal_class.signature: String getSndDomainFromUrl(String url)
focal_class.class_method_signature: URIUtil.getSndDomain(String domain)
focal_class.full_signature: public static String getSndDomain(String domain)
focal_class.identifier: getSndDomain
focal_class.modifiers: public static
focal_class.parameters: (String domain)
focal_class.return: String
focal_class.signature: String getSndDomain(String domain)
focal_method.body: public static String getSndDomain(String domain) {
      if (domain == null) {
        return null;
      }
      // Remove www subdomain if it exists
      if (domain.startsWith("www.")) {
        domain = domain.substring(4);
      }
      if (InternetDomainName.isValid(domain)) { // the domain is valid according to the RFC3490
        final InternetDomainName idn = InternetDomainName.from(domain);
        if (idn.hasPublicSuffix()) { // the domain has a public suffix
          if (idn.isUnderPublicSuffix()) {
            return idn.topPrivateDomain().name();
          } else if (idn.hasParent()) {
            final List<String> parts = idn.parts();
            return parts.get(parts.size() - 2).concat(".").concat(parts.get(parts.size() - 1));
          }
        }
      }
      return null;
    }
focal_method.class_method_signature: URIUtil.getSndDomain(String domain)
focal_method.full_signature: public static String getSndDomain(String domain)
focal_method.identifier: getSndDomain
focal_method.invocations: startsWith substring isValid from hasPublicSuffix isUnderPublicSuffix name topPrivateDomain hasParent parts concat concat get size get size
focal_method.modifiers: public static
focal_method.parameters: (String domain)
focal_method.return: String
focal_method.signature: String getSndDomain(String domain)