Class Label

java.lang.Object
com.mastfrog.url.Label
All Implemented Interfaces:
URLComponent, Serializable

public final class Label extends Object implements URLComponent
One Label in a Host - i.e. one component of an IP address or host name such as www.example.com or 192.168.2.32.
Author:
Tim Boudreau
See Also:
  • Constructor Details

    • Label

      public Label(String domainPart)
  • Method Details

    • isEmpty

      public boolean isEmpty()
    • length

      public int length()
    • toString

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

      public boolean isNumeric()
    • getLabel

      public String getLabel()
      Get the literal label.
      Returns:
      The label
    • isHex

      public boolean isHex()
    • asInt

      public int asInt(boolean hex)
      Get an int value for this label, if it can be parsed, or -1 if not.
      Parameters:
      hex - Whether to parse as hexadecimal
      Returns:
      An int value
    • asInt

      @Deprecated public int asInt()
      Deprecated.
      Use asInt(hex) instead
      Get an int value for this label.
      Returns:
      An integer value or -1 if the label value is not a number
    • isValidIpComponent

      public boolean isValidIpComponent()
    • isValidIpV6Component

      public boolean isValidIpV6Component()
    • isValidIpV4Component

      public boolean isValidIpV4Component()
    • 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
      Returns:
      True if this component is valid.
    • 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
    • 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
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object