- java.lang.Object
-
- de.bernd_michaely.x3f.types.ByteArray
-
public class ByteArray extends Object
Class for representing string data read from aRandomAccessData
object.- See Also:
UInt32
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getAsHexBytes()
Returns a string representation of this ByteArray containing each byte formatted as hex string.String
getAsHexBytes(int numCols)
Returns a string representation of this ByteArray containing each byte formatted as hex string.byte[]
getByteArray()
Returns the encapsulated byte array.List<String>
getMultiLineHexView()
Returns a Hex editor like multiline output with a default number of columns per line.List<String>
getMultiLineHexView(int numbBytesPerLine)
Returns a Hex editor like multiline output.int
getSize()
Returns the size of this byte array.String
getUTF16z(int offset)
Get UTF-16 encoded zero terminated substring.protected void
readBytes(RandomAccessData randomAccessData, int length)
Reads the given number of bytes into this ByteArray object.String
toString()
-
-
-
Constructor Detail
-
ByteArray
protected ByteArray()
Creates an empty byte array.
-
ByteArray
public ByteArray(byte[] bytes)
Creates a byte array from given data.- Parameters:
bytes
- the given byte array
-
ByteArray
public ByteArray(String s)
Creates a byte array from the given string.- Parameters:
s
- a String containing ASCII bytes
-
-
Method Detail
-
readBytes
protected void readBytes(RandomAccessData randomAccessData, int length) throws RandomAccessDataException
Reads the given number of bytes into this ByteArray object.- Parameters:
randomAccessData
- the data to read fromlength
- the number of bytes to read- Throws:
RandomAccessDataException
- if data source is null
-
getSize
public int getSize()
Returns the size of this byte array.- Returns:
- the size of this byte array
-
getByteArray
public byte[] getByteArray()
Returns the encapsulated byte array. This method will never return null.- Returns:
- the encapsulated byte array
-
getAsHexBytes
public String getAsHexBytes()
Returns a string representation of this ByteArray containing each byte formatted as hex string.- Returns:
- a string representation as hex bytes
-
getAsHexBytes
public String getAsHexBytes(int numCols)
Returns a string representation of this ByteArray containing each byte formatted as hex string.- Parameters:
numCols
- if numCols>0, adds a new line after the given number of columns- Returns:
- a string representation as hex bytes
-
getMultiLineHexView
public List<String> getMultiLineHexView()
Returns a Hex editor like multiline output with a default number of columns per line. Same asgetMultiLineHexView(16)
.- Returns:
- a Hex editor like multiline output
- Since:
- 2.0
-
getMultiLineHexView
public List<String> getMultiLineHexView(int numbBytesPerLine)
Returns a Hex editor like multiline output.- Parameters:
numbBytesPerLine
- the number of bytes per output line (less or equal to zero will default to 16)- Returns:
- a Hex editor like multiline output
- Since:
- 2.0
-
getUTF16z
public String getUTF16z(int offset) throws RandomAccessDataException
Get UTF-16 encoded zero terminated substring.- Parameters:
offset
- position within byte array to start reading from- Returns:
- a decoded substring
- Throws:
RandomAccessDataException
- if an error occurs through decoding
-
-