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

io.github.binaryfoo.decoders.DOLParser.kt Maven / Gradle / Ivy

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