Class Host

java.lang.Object
com.mastfrog.url.Host
All Implemented Interfaces:
URLComponent, Serializable, Iterable<Label>, org.netbeans.validation.api.Validating

public final class Host extends Object implements URLComponent, org.netbeans.validation.api.Validating, Iterable<Label>
An internet host such as a host name or IP address. Validation is more extensive than that done by java.net.URL, including checking name and label lengths for spec compatibility (max 63 chars per label, 255 chars per host name).
Author:
Tim Boudreau
See Also:
  • Constructor Details

    • Host

      public Host(boolean ipv6, Label... labels)
    • Host

      public Host(Label... labels)
  • Method Details

    • size

      public int size()
    • getElement

      public Label getElement(int ix)
    • isDomain

      public boolean isDomain(String domain)
    • parse

      public static Host parse(String path)
    • getTopLevelDomain

      public Label getTopLevelDomain()
    • getDomain

      public Label getDomain()
    • getLabels

      public Label[] getLabels()
    • getParentDomain

      public Host getParentDomain()
    • isIpAddress

      public boolean isIpAddress()
    • isIpV4Address

      public boolean isIpV4Address()
    • isIpV6Address

      public boolean isIpV6Address()
    • length

      public int length()
    • isValid

      public boolean isValid()
      Description copied from interface: URLComponent
      Determine if this component is in compliance with the RFCs governing URLs and DNS.
      Specified by:
      isValid in interface URLComponent
      Specified by:
      isValid in interface org.netbeans.validation.api.Validating
      Returns:
      True if this component is valid.
    • getProblems

      public org.netbeans.validation.api.Problems getProblems()
      Specified by:
      getProblems in interface org.netbeans.validation.api.Validating
    • builder

      public static AbstractBuilder<Label,Host> builder()
    • getComponentName

      public String getComponentName()
      Description copied from interface: URLComponent
      Get a human-readable, localized name for this part of the URL. Useful if an error message needs to be shown.
      Specified by:
      getComponentName in interface URLComponent
      Returns:
      The component name
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • appendTo

      public void appendTo(StringBuilder sb)
      Description copied from interface: URLComponent
      Append this component to a StringBuilder.
      Specified by:
      appendTo in interface URLComponent
      Parameters:
      sb - A StringBuilder
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • isLocalhost

      public boolean isLocalhost()
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • canonicalize

      public Host canonicalize()
    • iterator

      public Iterator<Label> iterator()
      Specified by:
      iterator in interface Iterable<Label>
    • toIntArray

      public int[] toIntArray()