io.github.binaryfoo.decoders.DOLParser.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
import io.github.binaryfoo.tlv.Tag
import java.nio.ByteBuffer
import java.util.ArrayList
/**
* DOL = Data Object List = A description of some data a receiver would like.
*
* Each element in the list is a tag and a length the receiver would like the value encoded on.
*/
class DOLParser {
fun parse(dol: ByteArray): List {
val elements = ArrayList()
val buffer = ByteBuffer.wrap(dol)
while (buffer.hasRemaining()) {
val tag = Tag.parse(buffer)
val length = buffer.get()
elements.add(DOLElement(tag, length.toInt()))
}
return elements
}
data class DOLElement(val tag: Tag, val length: Int)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy