@Test(expected = NullPointerException.class) public void testGetFormattedDomainNullURIThrows() throws Exception { FormattedDomain.format(RuntimeEnvironment.application, null, false, 0); }
@NonNull @WorkerThread public static String format(@NonNull final Context context, @NonNull final URI uri, final boolean shouldIncludePublicSuffix, @IntRange(from = 0) final int subdomainCount) { if (context == null) { throw new NullPointerException("Expected non-null Context argument"); } if (uri == null) { throw new NullPointerException("Expected non-null uri argument"); } if (subdomainCount < 0) { throw new IllegalArgumentException("Expected subdomainCount >= 0."); } final String host = uri.getHost(); if (TextUtils.isEmpty(host)) { return ""; } if (isIPv4(host) || isIPv6(uri) || !host.contains(".")) { return host; } final String domainStr = PublicSuffix.getPublicSuffix(context, host, subdomainCount + 1); if (TextUtils.isEmpty(domainStr)) { return stripSubdomains(host, subdomainCount); } if (!shouldIncludePublicSuffix) { return PublicSuffix.stripPublicSuffix(context, domainStr); } return domainStr; }
FormattedDomain { @NonNull @WorkerThread public static String format(@NonNull final Context context, @NonNull final URI uri, final boolean shouldIncludePublicSuffix, @IntRange(from = 0) final int subdomainCount) { if (context == null) { throw new NullPointerException("Expected non-null Context argument"); } if (uri == null) { throw new NullPointerException("Expected non-null uri argument"); } if (subdomainCount < 0) { throw new IllegalArgumentException("Expected subdomainCount >= 0."); } final String host = uri.getHost(); if (TextUtils.isEmpty(host)) { return ""; } if (isIPv4(host) || isIPv6(uri) || !host.contains(".")) { return host; } final String domainStr = PublicSuffix.getPublicSuffix(context, host, subdomainCount + 1); if (TextUtils.isEmpty(domainStr)) { return stripSubdomains(host, subdomainCount); } if (!shouldIncludePublicSuffix) { return PublicSuffix.stripPublicSuffix(context, domainStr); } return domainStr; } }
FormattedDomain { @NonNull @WorkerThread public static String format(@NonNull final Context context, @NonNull final URI uri, final boolean shouldIncludePublicSuffix, @IntRange(from = 0) final int subdomainCount) { if (context == null) { throw new NullPointerException("Expected non-null Context argument"); } if (uri == null) { throw new NullPointerException("Expected non-null uri argument"); } if (subdomainCount < 0) { throw new IllegalArgumentException("Expected subdomainCount >= 0."); } final String host = uri.getHost(); if (TextUtils.isEmpty(host)) { return ""; } if (isIPv4(host) || isIPv6(uri) || !host.contains(".")) { return host; } final String domainStr = PublicSuffix.getPublicSuffix(context, host, subdomainCount + 1); if (TextUtils.isEmpty(domainStr)) { return stripSubdomains(host, subdomainCount); } if (!shouldIncludePublicSuffix) { return PublicSuffix.stripPublicSuffix(context, domainStr); } return domainStr; } private  FormattedDomain(); }
FormattedDomain { @NonNull @WorkerThread public static String format(@NonNull final Context context, @NonNull final URI uri, final boolean shouldIncludePublicSuffix, @IntRange(from = 0) final int subdomainCount) { if (context == null) { throw new NullPointerException("Expected non-null Context argument"); } if (uri == null) { throw new NullPointerException("Expected non-null uri argument"); } if (subdomainCount < 0) { throw new IllegalArgumentException("Expected subdomainCount >= 0."); } final String host = uri.getHost(); if (TextUtils.isEmpty(host)) { return ""; } if (isIPv4(host) || isIPv6(uri) || !host.contains(".")) { return host; } final String domainStr = PublicSuffix.getPublicSuffix(context, host, subdomainCount + 1); if (TextUtils.isEmpty(domainStr)) { return stripSubdomains(host, subdomainCount); } if (!shouldIncludePublicSuffix) { return PublicSuffix.stripPublicSuffix(context, domainStr); } return domainStr; } private  FormattedDomain(); @NonNull @WorkerThread // calls PublicSuffix methods. static String format(@NonNull final Context context, @NonNull final URI uri,
                                final boolean shouldIncludePublicSuffix, @IntRange(from = 0) final int subdomainCount); static String stripCommonPrefixes(@NonNull final String host); }
FormattedDomain { @NonNull @WorkerThread public static String format(@NonNull final Context context, @NonNull final URI uri, final boolean shouldIncludePublicSuffix, @IntRange(from = 0) final int subdomainCount) { if (context == null) { throw new NullPointerException("Expected non-null Context argument"); } if (uri == null) { throw new NullPointerException("Expected non-null uri argument"); } if (subdomainCount < 0) { throw new IllegalArgumentException("Expected subdomainCount >= 0."); } final String host = uri.getHost(); if (TextUtils.isEmpty(host)) { return ""; } if (isIPv4(host) || isIPv6(uri) || !host.contains(".")) { return host; } final String domainStr = PublicSuffix.getPublicSuffix(context, host, subdomainCount + 1); if (TextUtils.isEmpty(domainStr)) { return stripSubdomains(host, subdomainCount); } if (!shouldIncludePublicSuffix) { return PublicSuffix.stripPublicSuffix(context, domainStr); } return domainStr; } private  FormattedDomain(); @NonNull @WorkerThread // calls PublicSuffix methods. static String format(@NonNull final Context context, @NonNull final URI uri,
                                final boolean shouldIncludePublicSuffix, @IntRange(from = 0) final int subdomainCount); static String stripCommonPrefixes(@NonNull final String host);  }