Java 类com.google.common.net.HostSpecifier 实例源码

项目:sinkit-core    文件:IPorFQDNValidator.java   
public static ImmutablePair<DECISION, String> decide(final String data) {
    String modified = sanitize.matcher(data).replaceAll("");
    if (InetAddresses.isInetAddress(data)) {
        // We return sanitized version with which we could operate as with IP address
        return new ImmutablePair<>(DECISION.IP, modified);
    } else {
        modified = dotUnderscoreRemove.matcher(modified).replaceAll("");
        modified = dotUnderscoreSeparatorPattern.matcher(modified).replaceAll("\\.");
        if (HostSpecifier.isValid(modified)) {
            // We are satisfied that FQDN could be made of this data, but we return the original form.
            return new ImmutablePair<>(DECISION.FQDN, data);
        } else {
            return new ImmutablePair<>(DECISION.GARBAGE, data);
        }
    }
}
项目:glycerin    文件:GlycerinHttpClient.java   
public GlycerinHttpClient(HostSpecifier host, String apiKey, Optional<RateLimiter> limiter, Optional<String> root) {
    this.host = checkNotNull(host);
    this.apiKey = checkNotNull(apiKey);
    this.limiter = checkNotNull(limiter);
    this.root = checkNotNull(root);
    this.requestFactory = initRequestFactory();
}
项目:glycerin    文件:GlycerinIntegrationTest.java   
@Parameters({"nitro.host", "nitro.apikey"})
@BeforeClass(groups = "integration")
public void setup(String host, String apiKey) {
    glycerin = XmlGlycerin.builder(apiKey)
            .withHost(HostSpecifier.fromValid(host))
            .build();
}
项目:glycerin    文件:GlycerinDeprecatedElementsTest.java   
@Parameters({ "nitro.host", "nitro.apikey" })
@BeforeClass(groups = "integration")
public void setUp(String host, String apiKey) throws ParseException {
    this.ignorableDeprecations = HashMultimap.create();
    addDeprecatedElementsToTheIgnorableMap();

    glycerinClient = new GlycerinHttpClient(HostSpecifier.from(host), apiKey, limiter, root);
}
项目:webindex    文件:URL.java   
public static boolean isValidHost(String host) {
  return HostSpecifier.isValid(host) && InternetDomainName.isValid(host)
      && InternetDomainName.from(host).isUnderPublicSuffix();
}
项目:glycerin    文件:XmlGlycerin.java   
public Builder withHost(HostSpecifier host) {
    this.host = host;
    return this;
}
项目:glycerin    文件:XmlGlycerin.java   
public XmlGlycerin(HostSpecifier host, String apiKey, Optional<RateLimiter> limiter, Optional<String> root) {
    this.client = new GlycerinHttpClient(host, apiKey, limiter, root);
}