Class Token

    • Method Detail

      • parse

        public static Token parse​(String token)
                           throws TokenParseException
        Parse a Token from the supplied string representation using the default format.
        Parameters:
        token - the string representation to parse; never null or blank
        Returns:
        a properly constructed Token
        Throws:
        TokenParseException - if the string cannot be parsed
      • root

        public static Token root​(String segmentType,
                                 String value)
        Create a root Token from the supplied segmentType and value using the default format.
        Parameters:
        segmentType - the segment type; never null or blank
        value - the value; never null or blank
      • append

        public final Token append​(String segmentType,
                                  String value)
        Construct a new Token by appending a new TokenFormat.Segment, based on the supplied segmentType and value, to the end of this Token.

        This Token will not be modified.

        Neither the segmentType nor the value may contain any of the special characters used for constructing the string representation of this Token.

        Parameters:
        segmentType - the type of the segment; never null or blank
        value - the value of the segment; never null or blank
      • append

        public final Token append​(TokenFormat.Segment segment)
        Construct a new Token by appending a new TokenFormat.Segment to the end of this Token.

        This Token will not be modified.

        Parameters:
        segment - the segment to be appended; never null
      • hasPrefix

        public boolean hasPrefix​(Token potentialPrefix)
        Determine if the supplied Token is a prefix for this Token.
        Parameters:
        potentialPrefix - the Token to be checked; never null
      • removeLastSegment

        public Token removeLastSegment()
        Construct a new Token and removing the last TokenFormat.Segment of this Token.

        This Token will not be modified.

        Returns:
        a new Token; never null
      • hashCode

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

        public String toString()
        Generate the unique, formatted string representation of this Token using the configured TokenFormat.
        Overrides:
        toString in class Object