All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.binaryfoo.decoders.bit.FullByteField.kt Maven / Gradle / Ivy

There is a newer version: 0.1.8
Show newest version
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