- All Implemented Interfaces:
Encodable,Serializable,Comparable<CardType>,Constable
The products these cards come as, which bytes 0 to 2 of block 1 tell apart.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionA personal Avanza Tarjeta Bus, which travels on a subscription and never spends.A balance top up Avanza Tarjeta Bus, which pays each journey out of its balance.A balance top up Lazo card. -
Method Summary
Modifier and TypeMethodDescriptionchip()The chip this product comes on.static CardTypedecode(byte[] block) Decodes block 1, which says which product a card is.byte[]encode()Encodes this product into block 1, with its checksum.intThe first byte of the product, which transactions and the journey summary carry.keys(int sector) The keys of one sector of a card of this product, read from the table it carries.static CardTypeofFirstByte(int firstByte) The product whose first byte is the one given, as transactions carry it.static CardTypeofValue(int value) The product with those three bytes.The sectors holding a subscription product on cards of this product, one product per sector.booleanWhether cards of this product rewrite block 10 on every journey.intvalue()Bytes 0 to 2 of block 1.static CardTypeReturns the enum constant of this class with the specified name.static CardType[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
AVANZA_TOP_UP
A balance top up Avanza Tarjeta Bus, which pays each journey out of its balance. -
AVANZA_PERSONAL_UNLIMITED
A personal Avanza Tarjeta Bus, which travels on a subscription and never spends. -
LAZO_TOP_UP
A balance top up Lazo card.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
value
public int value()Bytes 0 to 2 of block 1.- Returns:
- the three bytes as one integer
-
firstByte
public int firstByte()The first byte of the product, which transactions and the journey summary carry.- Returns:
- byte 0 of block 1
-
chip
The chip this product comes on.- Returns:
- the chip
-
productSectors
The sectors holding a subscription product on cards of this product, one product per sector.- Returns:
- the sectors, empty on a product that pays each journey out of its balance
-
recordsJourneySummary
public boolean recordsJourneySummary()Whether cards of this product rewrite block 10 on every journey. A product that travels on a subscription leaves a constant there instead, whichJourneySummary.decode(byte[])rejects.- Returns:
- true when block 10 holds a journey summary
-
ofValue
The product with those three bytes.- Parameters:
value- bytes 0 to 2 of block 1 as one integer- Returns:
- the product
- Throws:
CardFormatException- if no known product has those bytes
-
ofFirstByte
The product whose first byte is the one given, as transactions carry it.- Parameters:
firstByte- byte 0 of a transaction or of the journey summary- Returns:
- the product
- Throws:
CardFormatException- if no known product starts with that byte
-
decode
Decodes block 1, which says which product a card is.- Parameters:
block- the sixteen bytes- Returns:
- the product
- Throws:
CardFormatException- if the block is not sixteen bytes, its checksum does not match, bytes 3 to 14 are not zero, or no known product has those first three bytes
-
encode
public byte[] encode()Encodes this product into block 1, with its checksum. -
keys
The keys of one sector of a card of this product, read from the table it carries.Sectors 0 to 8 hold the same keys on both Avanza products, so either of them opens an Avanza card before block 1 has been read.
- Parameters:
sector- the sector, counting from zero- Returns:
- the keys, or empty for a sector the table does not cover, which is
every sector past the last one
Chip.sectors()counts - Throws:
IllegalArgumentException- if the sector is negative
-