fm.liveswitch.matroska.Element Class Referenceabstract

A Matroska element. More...

Public Member Functions

byte[] getBytes ()
 Serializes to a byte array. More...
 
abstract byte[] getId ()
 Gets the EBML ID. More...
 
int getLength ()
 Gets the total length of the element (including ID/size field), set after calling fm.liveswitch.matroska.Element#getBytes. More...
 
int getSize ()
 Gets the size of the element (excluding ID/size field), set after calling fm.liveswitch.matroska.Element#getBytes. More...
 
int getSizeLength ()
 Gets the length of the size field, in bytes. More...
 
boolean getWriteDefaultValues ()
 Gets whether to include default values when serializing. More...
 
void setSizeLength (int value)
 Sets the length of the size field, in bytes. More...
 
void setWriteDefaultValues (boolean value)
 Sets whether to include default values when serializing. More...
 

Static Public Member Functions

static boolean compare (byte[] bytes1, byte[] bytes2)
 Compares two byte arrays for equality. More...
 
static boolean readBool (byte[] value)
 Reads a boolean element from the stream. More...
 
static java.util.Date readDate (byte[] value)
 Reads a date string element from the stream. More...
 
static double readDouble (byte[] value)
 Reads a double element from the stream. More...
 
static float readFloat (byte[] value)
 Reads a float element from the stream. More...
 
static fm.liveswitch.Guid readGuid (byte[] value)
 Reads a GUID element from the stream. More...
 
static byte[] readId (byte[] bytes, int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads a binary ID from the stream. More...
 
static long readSignedInteger (byte[] value)
 Reads a signed integer element from the byte array. More...
 
static String readString (byte[] value)
 Reads an ASCII string element from the stream. More...
 
static long readUnsignedInteger (byte[] value)
 Reads an unsigned integer element from the byte array. More...
 
static String readUtf8 (byte[] value)
 Reads a UTF-8 string element from the stream. More...
 
static byte[] readValue (byte[] bytes, int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads a binary value from the stream. More...
 
static long readVariableInteger (byte[] bytes, int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads a variable integer ("vint") from the byte array. More...
 
static byte[] serializeVariableInteger (long value)
 Serializes a variable integer. More...
 
static byte[] serializeVariableInteger (long value, int length)
 Serializes a variable integer using a fixed length. More...
 

Protected Member Functions

 Element ()
 
abstract byte[] getInnerBytes ()
 Gets the inner bytes. More...
 
void write (byte[] value, byte[] idValue, fm.liveswitch.ByteOutputStream stream)
 Writes a binary element to the stream. More...
 
void writeBool (boolean value, byte[] idValue, fm.liveswitch.ByteOutputStream stream)
 Writes a boolean element to the stream. More...
 
void writeDate (java.util.Date value, byte[] idValue, fm.liveswitch.ByteOutputStream stream)
 Writes a date element to the stream. More...
 
void writeDouble (double value, byte[] idValue, fm.liveswitch.ByteOutputStream stream)
 Writes a double element to the stream. More...
 
void writeFloat (float value, byte[] idValue, fm.liveswitch.ByteOutputStream stream)
 Writes a float element to the stream. More...
 
void writeGuid (fm.liveswitch.Guid value, byte[] idValue, fm.liveswitch.ByteOutputStream stream)
 Writes a GUID element to the stream. More...
 
void writeSignedInteger (long value, byte[] idValue, fm.liveswitch.ByteOutputStream stream)
 Writes an signed integer element to the stream. More...
 
void writeString (String value, byte[] idValue, fm.liveswitch.ByteOutputStream stream)
 Writes an ASCII string element to the stream. More...
 
void writeUnsignedInteger (long value, byte[] idValue, fm.liveswitch.ByteOutputStream stream)
 Writes an unsigned integer element to the stream. More...
 
void writeUtf8 (String value, byte[] idValue, fm.liveswitch.ByteOutputStream stream)
 Writes a UTF-8 string element to the stream. More...
 
void writeVariableInteger (long value, fm.liveswitch.ByteOutputStream stream)
 Writes a variable integer ("vint") to the stream. More...
 
void writeVariableInteger (long value, fm.liveswitch.ByteOutputStream stream, int length)
 Writes a variable integer ("vint") to the stream using a fixed length. More...
 

Detailed Description

A Matroska element.

Constructor & Destructor Documentation

◆ Element()

fm.liveswitch.matroska.Element.Element ( )
protected

Member Function Documentation

◆ compare()

static boolean fm.liveswitch.matroska.Element.compare ( byte[]  bytes1,
byte[]  bytes2 
)
static

Compares two byte arrays for equality.

Parameters
bytes1The first byte array.
bytes2The second byte array.

◆ getBytes()

byte [] fm.liveswitch.matroska.Element.getBytes ( )

Serializes to a byte array.

◆ getId()

◆ getInnerBytes()

◆ getLength()

int fm.liveswitch.matroska.Element.getLength ( )

Gets the total length of the element (including ID/size field), set after calling fm.liveswitch.matroska.Element#getBytes.

◆ getSize()

int fm.liveswitch.matroska.Element.getSize ( )

Gets the size of the element (excluding ID/size field), set after calling fm.liveswitch.matroska.Element#getBytes.

◆ getSizeLength()

int fm.liveswitch.matroska.Element.getSizeLength ( )

Gets the length of the size field, in bytes.

Defaults to zero (variable size).

◆ getWriteDefaultValues()

boolean fm.liveswitch.matroska.Element.getWriteDefaultValues ( )

Gets whether to include default values when serializing.

◆ readBool()

static boolean fm.liveswitch.matroska.Element.readBool ( byte[]  value)
static

Reads a boolean element from the stream.

Parameters
valueThe value.

◆ readDate()

static java.util.Date fm.liveswitch.matroska.Element.readDate ( byte[]  value)
static

Reads a date string element from the stream.

Parameters
valueThe value.

◆ readDouble()

static double fm.liveswitch.matroska.Element.readDouble ( byte[]  value)
static

Reads a double element from the stream.

Parameters
valueThe value.

◆ readFloat()

static float fm.liveswitch.matroska.Element.readFloat ( byte[]  value)
static

Reads a float element from the stream.

Parameters
valueThe value.

◆ readGuid()

static fm.liveswitch.Guid fm.liveswitch.matroska.Element.readGuid ( byte[]  value)
static

Reads a GUID element from the stream.

Parameters
valueThe value.

◆ readId()

static byte [] fm.liveswitch.matroska.Element.readId ( byte[]  bytes,
int  offset,
fm.liveswitch.IntegerHolder  offsetPlus 
)
static

Reads a binary ID from the stream.

Parameters
bytesThe byte array.
offsetThe offset into the byte array.
offsetPlusThe offset plus the amount read.

◆ readSignedInteger()

static long fm.liveswitch.matroska.Element.readSignedInteger ( byte[]  value)
static

Reads a signed integer element from the byte array.

Parameters
valueThe value.

◆ readString()

static String fm.liveswitch.matroska.Element.readString ( byte[]  value)
static

Reads an ASCII string element from the stream.

Parameters
valueThe value.

◆ readUnsignedInteger()

static long fm.liveswitch.matroska.Element.readUnsignedInteger ( byte[]  value)
static

Reads an unsigned integer element from the byte array.

Parameters
valueThe value.

◆ readUtf8()

static String fm.liveswitch.matroska.Element.readUtf8 ( byte[]  value)
static

Reads a UTF-8 string element from the stream.

Parameters
valueThe value.

◆ readValue()

static byte [] fm.liveswitch.matroska.Element.readValue ( byte[]  bytes,
int  offset,
fm.liveswitch.IntegerHolder  offsetPlus 
)
static

Reads a binary value from the stream.

Parameters
bytesThe byte array.
offsetThe offset into the byte array.
offsetPlusThe offset plus the amount read.

◆ readVariableInteger()

static long fm.liveswitch.matroska.Element.readVariableInteger ( byte[]  bytes,
int  offset,
fm.liveswitch.IntegerHolder  offsetPlus 
)
static

Reads a variable integer ("vint") from the byte array.

Parameters
bytesThe byte array.
offsetThe offset into the byte array.
offsetPlusThe offset plus the amount read.

◆ serializeVariableInteger() [1/2]

static byte [] fm.liveswitch.matroska.Element.serializeVariableInteger ( long  value)
static

Serializes a variable integer.

Parameters
valueThe value.

◆ serializeVariableInteger() [2/2]

static byte [] fm.liveswitch.matroska.Element.serializeVariableInteger ( long  value,
int  length 
)
static

Serializes a variable integer using a fixed length.

Parameters
valueThe value.
lengthThe length to use.

◆ setSizeLength()

void fm.liveswitch.matroska.Element.setSizeLength ( int  value)

Sets the length of the size field, in bytes.

Defaults to zero (variable size).

◆ setWriteDefaultValues()

void fm.liveswitch.matroska.Element.setWriteDefaultValues ( boolean  value)

Sets whether to include default values when serializing.

◆ write()

void fm.liveswitch.matroska.Element.write ( byte[]  value,
byte[]  idValue,
fm.liveswitch.ByteOutputStream  stream 
)
protected

Writes a binary element to the stream.

Parameters
valueThe value to write.
idValueThe ID of the value.
streamThe stream to write.

◆ writeBool()

void fm.liveswitch.matroska.Element.writeBool ( boolean  value,
byte[]  idValue,
fm.liveswitch.ByteOutputStream  stream 
)
protected

Writes a boolean element to the stream.

Parameters
valueThe value to write.
idValueThe ID of the value.
streamThe stream to write.

◆ writeDate()

void fm.liveswitch.matroska.Element.writeDate ( java.util.Date  value,
byte[]  idValue,
fm.liveswitch.ByteOutputStream  stream 
)
protected

Writes a date element to the stream.

Parameters
valueThe value to write.
idValueThe ID of the value.
streamThe stream to write.

◆ writeDouble()

void fm.liveswitch.matroska.Element.writeDouble ( double  value,
byte[]  idValue,
fm.liveswitch.ByteOutputStream  stream 
)
protected

Writes a double element to the stream.

Parameters
valueThe value to write.
idValueThe ID of the value.
streamThe stream to write.

◆ writeFloat()

void fm.liveswitch.matroska.Element.writeFloat ( float  value,
byte[]  idValue,
fm.liveswitch.ByteOutputStream  stream 
)
protected

Writes a float element to the stream.

Parameters
valueThe value to write.
idValueThe ID of the value.
streamThe stream to write.

◆ writeGuid()

void fm.liveswitch.matroska.Element.writeGuid ( fm.liveswitch.Guid  value,
byte[]  idValue,
fm.liveswitch.ByteOutputStream  stream 
)
protected

Writes a GUID element to the stream.

Parameters
valueThe value to write.
idValueThe ID of the value.
streamThe stream to write.

◆ writeSignedInteger()

void fm.liveswitch.matroska.Element.writeSignedInteger ( long  value,
byte[]  idValue,
fm.liveswitch.ByteOutputStream  stream 
)
protected

Writes an signed integer element to the stream.

Parameters
valueThe value to write.
idValueThe ID of the value.
streamThe stream to write.

◆ writeString()

void fm.liveswitch.matroska.Element.writeString ( String  value,
byte[]  idValue,
fm.liveswitch.ByteOutputStream  stream 
)
protected

Writes an ASCII string element to the stream.

Parameters
valueThe value to write.
idValueThe ID of the value.
streamThe stream to write.

◆ writeUnsignedInteger()

void fm.liveswitch.matroska.Element.writeUnsignedInteger ( long  value,
byte[]  idValue,
fm.liveswitch.ByteOutputStream  stream 
)
protected

Writes an unsigned integer element to the stream.

Parameters
valueThe value to write.
idValueThe ID of the value.
streamThe stream to write.

◆ writeUtf8()

void fm.liveswitch.matroska.Element.writeUtf8 ( String  value,
byte[]  idValue,
fm.liveswitch.ByteOutputStream  stream 
)
protected

Writes a UTF-8 string element to the stream.

Parameters
valueThe value to write.
idValueThe ID of the value.
streamThe stream to write.

◆ writeVariableInteger() [1/2]

void fm.liveswitch.matroska.Element.writeVariableInteger ( long  value,
fm.liveswitch.ByteOutputStream  stream 
)
protected

Writes a variable integer ("vint") to the stream.

Parameters
valueThe value to write.
streamThe stream to write.

◆ writeVariableInteger() [2/2]

void fm.liveswitch.matroska.Element.writeVariableInteger ( long  value,
fm.liveswitch.ByteOutputStream  stream,
int  length 
)
protected

Writes a variable integer ("vint") to the stream using a fixed length.

Parameters
valueThe value to write.
streamThe stream to write.
lengthThe length to use.