Class CardId

java.lang.Object
dev.hloth.zgztransport.CardId
All Implemented Interfaces:
Encodable

public final class CardId extends Object implements Encodable
The card id printed on the plastic, which block 2 holds as two letters and one decimal digit per nibble, such as BE322743.
  • Method Details

    • parse

      public static CardId parse(String text)
      The id that text spells.
      Parameters:
      text - two capital letters followed by an even count of 6 to 26 digits
      Returns:
      the id
      Throws:
      IllegalArgumentException - if the text is not in that form
    • decode

      public static CardId decode(byte[] block)
      Decodes block 2. Only the checksum is checked, so an id printed from a damaged block can hold bytes that parse(String) would not accept.
      Parameters:
      block - the sixteen bytes
      Returns:
      the id
      Throws:
      CardFormatException - if the block is not sixteen bytes or its checksum does not match
    • encode

      public byte[] encode()
      Encodes this id into block 2, with its checksum.
      Specified by:
      encode in interface Encodable
      Returns:
      the sixteen bytes
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      The id as printed on the card: the two letters, then the digits with the trailing zero bytes the card pads with trimmed off.
      Overrides:
      toString in class Object
      Returns:
      the printed id