Package com.google.common.net

Examples of com.google.common.net.InternetDomainName


        if (host == null) {
          reporter.incrCounter(this._counterGroup, "Invalid URI", 1);
          return;
        }

        InternetDomainName domainObj = InternetDomainName.from(host);

        String domain = domainObj.topPrivateDomain().name();

        if (domain == null) {
          reporter.incrCounter(this._counterGroup, "Invalid Domain", 1);
          return;
        }
View Full Code Here


          if (host == null || host.equals(""))
            throw new URISyntaxException(url, "Unable to gather host or no host found");

          // Gather the domain object
          InternetDomainName domainObj = InternetDomainName.from(host);

          // Output the TLD
          String publicSuffix = "[none]";

          if (domainObj.hasPublicSuffix())
            publicSuffix = domainObj.publicSuffix().name().trim().toLowerCase();

          output.collect(new Text("TLD\t"+publicSuffix), new LongWritable(1));

          // Output the private domain
          // WARNING - This dramatically increases the size of the output.
          String privateDomain = "[invalid]";

          if (domainObj.topPrivateDomain() != null)
            privateDomain = domainObj.topPrivateDomain().name().trim().toLowerCase();

          //output.collect(new Text("Domain\t"+privateDomain), new LongWritable(1));
        }
        catch (URISyntaxException ex) {
          output.collect(new Text("TLD\t[invalid URL]"), new LongWritable(1));
View Full Code Here

  public InternetDomainName getPublicSuffix() {
    if(this.host == null) {
      return null;
    }

    InternetDomainName idn = InternetDomainName.from(this.host);
    if ((idn != null) && (idn.hasPublicSuffix())) {
      return idn.publicSuffix();
    } else {
      return null;
    }     
  }
View Full Code Here

      return null;
    }     
  }

  public String getTld() {
    InternetDomainName idn = this.getPublicSuffix();
    if (idn != null) {
      return idn.toString();
    } else {
      return null;
    }
  }
View Full Code Here

   @Override
   @SuppressWarnings("unchecked")
   public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
      checkNotNull(payload, "hostprefix");
      checkArgument(isValid(request.getEndpoint().getHost()), "this is only valid for hostnames: " + request);
      InternetDomainName name = from(request.getEndpoint().getHost()).child(payload.toString());
      return (R) request.toBuilder().endpoint(uriBuilder(request.getEndpoint()).host(name.toString()).build()).build();
   }
View Full Code Here

   */
  public static String extractEffective2LD(String domainname)
  {
    String retval = null;
    try{
      InternetDomainName idn = InternetDomainName.from(domainname);
      InternetDomainName sld = idn.topPrivateDomain();
      retval = sld.name();
    } catch (Exception e) {
      if(log.isDebugEnabled()){
        log.debug("Unable to extract 2LD.", e);
      }
    }
View Full Code Here

   @Override
   @SuppressWarnings("unchecked")
   public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
      checkNotNull(payload, "hostprefix");
      checkArgument(isValid(request.getEndpoint().getHost()), "this is only valid for hostnames: " + request);
      InternetDomainName name = from(request.getEndpoint().getHost()).child(payload.toString());
      return (R) request.toBuilder().endpoint(uriBuilder(request.getEndpoint()).host(name.name()).build()).build();
   }
View Full Code Here

     */
    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 {
View Full Code Here

   public String apply(Endpoint input) {
      if (input.getRegion() != null)
         return input.getRegion();
      String host = input.getPublicURL().getHost();
      if (InternetDomainName.isValid(host)) {
         InternetDomainName domain = InternetDomainName.from(host);
         return domain.parts().get(0);
      }
      return provider;
   }
View Full Code Here

   @Override
   @SuppressWarnings("unchecked")
   public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
      checkNotNull(payload, "hostprefix");
      checkArgument(isValid(request.getEndpoint().getHost()), "this is only valid for hostnames: " + request);
      InternetDomainName name = from(request.getEndpoint().getHost()).child(payload.toString());
      return (R) request.toBuilder().endpoint(uriBuilder(request.getEndpoint()).host(name.toString()).build()).build();
   }
View Full Code Here

TOP

Related Classes of com.google.common.net.InternetDomainName

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.