io.github.binaryfoo.decoders.bit.FullByteField.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of emv-bertlv Show documentation
Show all versions of emv-bertlv Show documentation
Some decoders for the data used in EMV credit card transactions.
package io.github.binaryfoo.decoders.bit
import io.github.binaryfoo.bit.EmvBit
import io.github.binaryfoo.bit.matches
import java.util.*
/**
* An english description for a hex literal of a single byte.
*/
class FullByteField(field: Set, private val byteNumber: Int, private val hexValue: String, private val decodedValue: String) : BitStringField {
private val field: Set
init {
this.field = TreeSet(field)
}
override fun getPositionIn(bits: Set?): String {
return "Byte $byteNumber = 0x$hexValue"
}
override fun getValueIn(bits: Set): String? {
return if (field.matches(bits)) decodedValue else null
}
override fun getStartBytesOffset(): Int = byteNumber - 1
override fun getLengthInBytes(): Int = 1
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy