
scales.utils.io.DataChunk.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scales-xml_2.11 Show documentation
Show all versions of scales-xml_2.11 Show documentation
An alternate Scala Xml processing library
The newest version!
package scales.utils.io
/**
* Represents a chunk of data to feed into an async parser.
* The instance is deemed "owned" by the asnyc parser until it requires more input.
*/
sealed trait DataChunk {
def array: Array[Byte]
def offset: Int
def length: Int
def isEOF: Boolean = false
def isEmpty: Boolean = false
}
/**
* Represents the end of a stream, no more Bytes are available
*/
object EOFData extends DataChunk {
val array = Array.empty[Byte]
val offset = 0
val length = -1
override val isEOF = true
}
/**
* Represents a data stream with no immediate data to return.
*/
object EmptyData extends DataChunk {
val array = Array.empty[Byte]
val offset = 0
val length = 0
override val isEmpty = true
}
/**
* Represents the full array
*/
final case class FullChunk( array: Array[Byte] ) extends DataChunk {
def offset = 0
def length = array.length
}
/**
* A section of a Byte array.
*/
final case class Chunk( array: Array[Byte], offset: Int, length: Int) extends DataChunk
© 2015 - 2025 Weber Informatics LLC | Privacy Policy