java.lang.Object
com.blackhillsoftware.smf.Data
com.blackhillsoftware.smf.Token

public class Token extends Data
Base class for comparable token data. This class is intended to be extended to create Tokens of different types which may have additional properties. Tokens of the same type can be compared for equality, used as HashMap keys etc. Tokens of different types can be compared by getting the basicToken() and using that for the comparison.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Token
    Empty token
  • Constructor Summary

    Constructors
    Constructor
    Description
    Token(byte[] source)
    Create a Token from a byte array.
    Token(byte[] source, int offset, int length)
    Create a Token with data copied from an existing byte array
  • Method Summary

    Modifier and Type
    Method
    Description
    Return the hexadecimal value of the token
    Return the token converted from EBCDIC to a String value.
    Return a basic Token object, which can be compared to other basic Tokens.
    boolean
    Check whether all bytes are zero i.e.
     

    Methods inherited from class com.blackhillsoftware.smf.Data

    dump, dump, dump, dump, equals, getBytes, getBytes, hashCode, length

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • EMPTY

      public static final Token EMPTY
      Empty token
  • Constructor Details

    • Token

      public Token(byte[] source, int offset, int length)
      Create a Token with data copied from an existing byte array
      Parameters:
      source - the byte array containing the token
      offset - the offset of the start of the token
      length - the length of the token
    • Token

      public Token(byte[] source)
      Create a Token from a byte array.
      Parameters:
      source - a byte array containing a complete Token
  • Method Details

    • basicToken

      public Token basicToken()
      Return a basic Token object, which can be compared to other basic Tokens. This allows you to compare tokens of different Java types, e.g. if tokens are intended to track the same work across different record types but have been implemented as different types.
      Returns:
      a Token
    • isZeros

      public boolean isZeros()
      Check whether all bytes are zero i.e. probably an empty token
      Returns:
      true if all bytes are zero
    • asHex

      public String asHex()
      Return the hexadecimal value of the token
      Returns:
      a hexadecimal formatted string
    • asString

      public String asString()
      Return the token converted from EBCDIC to a String value. This may or may not be a useful value depending on the token.
      Returns:
      String the token converted to a String
    • toString

      public String toString()
      Overrides:
      toString in class Data