ByteDataAccessBase
public abstract class ByteDataAccessOld
extends java.lang.Object
ByteDataAccessBase
This class is a base class to control the access to binary data.
The binary data may typically used or produced from a part of software written in C or C++.
There the binary data are struct-constructs.
struct
are adequate mapped with a derivated class of this class,
using the protected commonly access methods like _getInt(int, int)
with predefined indexes
in special methods like getValueXyz().struct
with nested struct
inside are mapped
with one derivated class per struct
, define one reference per nested struct
and overwriting the method assignDataToFixChilds()
struct
inside a struct
(inherition in C) can be mapped with
extra derivated classes for the base struct and usind the
assignCasted_i(ByteDataAccess, int)
-method.next()
sets the indices to a possible but not yet defined current child:
addChild()
or its adequate addChildXY() sets the indices to the given current child:
specifyLengthElement()
if this method returns >=0.
specifyLengthElementHead()
if this method returns >=0.
setLengthElement(int)
with the child
or setLengthCurrentChildElement(int)
with the parent, respectively with this.
specifyLengthCurrentChildElement()
supplied the number of bytes.
But if this method is not overwritten in the inherited class, an exception is thrown.
<+>--->
is a composition,
<>--->
is a aggregation, <|----
is a inherition.
+-------------------------------+ +----------+ | ByteDataAccess |----data-------->| byte[] | |-------------------------------| +----------+ |idxBegin:int | |idxChild:int |<---------------+ a known parent +-------------+ |idxEnd:int |---parent-------+ setted in addChild() | derivated | |-------------------------------| | user |---|>|specifyLengthElement() | | classes | |specifyLengthElementHead() |--currentChild--+ the actual child element +-------------+ |specifyLengthCurrentChild() |<---------------+ +-------------------------------+
Modifier and Type | Field and Description |
---|---|
static int |
_version_
Deprecated.
The version.
|
protected boolean |
bBigEndian
Deprecated.
Flag is set or get data in big endian or little endian (if false)
|
protected boolean |
bExpand
Deprecated.
True if the
idxEnd should be increment on adding children. |
(package private) java.lang.String |
charset
Deprecated.
The charset.
|
private ByteDataAccessOld |
currentChild
Deprecated.
The child on end to add() something
|
protected byte[] |
data
Deprecated.
The array containing the binary data.
|
protected int |
idxBegin
Deprecated.
Index of the beginning of the actual element in data
|
protected int |
idxCurrentChild
Deprecated.
Index within the at position of the current child element.
|
protected int |
idxCurrentChildEnd
Deprecated.
Index of the currents child end.
|
protected int |
idxEnd
Deprecated.
Index of the end of the actual element in data
|
protected int |
idxFirstChild
Deprecated.
Index of the first child element, it is after the head.
|
static byte |
kEndOfElements
Deprecated.
Definition of the code of end of information, return from next()
|
protected static int |
kIdxElementCode
Deprecated.
Index in the data, position of element code
|
static byte |
kNothing
Deprecated.
Definition of the code of no information, return from next()
|
static byte |
kText
Deprecated.
Aussage: es ist ein String (XML: text()), kein Tag im String
|
static byte |
kUndefined
Deprecated.
coding: the value is undefined
|
private ByteDataAccessOld |
parent
Deprecated.
The parent XmlBinCodeElement, necessary only for add() and expand().
|
Modifier | Constructor and Description |
---|---|
protected |
ByteDataAccessOld()
Deprecated.
Constructs a new empty instance.
|
Modifier and Type | Method and Description |
---|---|
protected long |
_getLong(int idxInChild,
int nrofBytesAndSign)
Deprecated.
Returns the content of 1 to 8 bytes inside the actual element as a long number,
big- or little-endian depending on setBigEndian().
|
protected java.lang.String |
_getString(int idx,
int nrofBytes)
Deprecated.
sets the content inside the acutal element with the character bytes from the given String.
|
protected void |
_setLong(int idx,
int nrofBytes,
long val)
Deprecated.
sets the content of 1 to 8 bytes inside the actual element as a long number,
big- or little-endian depending on setBigEndian().
|
protected void |
_setString(int idx,
int nrofBytes,
java.lang.String value,
java.lang.String sEncoding,
boolean preventCtrlChars)
Deprecated.
sets the content inside the actual element with the character bytes from the given String.
|
boolean |
addChild(ByteDataAccessOld child)
Deprecated.
adds an child Element after the current child or as first child after head.
|
void |
addChildEmpty(ByteDataAccessOld child)
Deprecated.
Adds a child Element at current end of data to write data.
|
void |
addChildFloat(float value)
Deprecated.
Adds a child for 1 integer value without a child instance, and sets the value as integer.
|
void |
addChildInteger(int nrofBytes,
long value)
Deprecated.
Adds a child for 1 integer value without a child instance, and sets the value as integer.
|
void |
addChildString(java.lang.CharSequence value)
Deprecated.
Adds a child with String value.
|
void |
addChildString(java.lang.CharSequence value,
java.lang.String sEncoding)
Deprecated.
Adds a child with String value.
|
void |
addChildString(java.lang.String value)
Deprecated.
Adds a child with String value.
|
void |
addChildString(java.lang.String value,
java.lang.String sEncoding,
boolean preventCtrlChars)
Deprecated.
Adds a child with String value.
|
int |
addText(java.lang.String ss)
Deprecated.
|
boolean |
assertNotExpandable()
Deprecated.
|
void |
assignAsChild(ByteDataAccessOld parent)
Deprecated.
use addChild()
|
void |
assignAtIndex(int idxChildInParent,
ByteDataAccessOld parent)
Deprecated.
assigns the element to the given position of the parents data to present a child of the parent.
|
void |
assignAtIndex(int idxChildInParent,
int lengthChild,
ByteDataAccessOld parent)
Deprecated.
assigns the element to the given position of the parents data to present a child of the parent
with a defined length.
|
protected void |
assignCasted_i(ByteDataAccessOld src,
int offsetCastToInput,
int lengthDst)
Deprecated.
Assigns this element to the same position in data, but it is another view.
|
void |
assignData(byte[] data,
int length)
Deprecated.
Assigns new data to this element.
|
void |
assignData(byte[] data,
int lengthData,
int index)
Deprecated.
Assigns new data to this element at given index in data.
|
protected void |
assignDataToFixChilds()
Deprecated.
This method is called inside all assign...() methods.
|
protected void |
assignDowncast_i(ByteDataAccessOld input)
Deprecated.
Older form, see protected method
assignCasted_i(ByteDataAccessOld, int )
If a cast is possible, it should be programmed in the derivated class. |
void |
assignEmpty(byte[] data)
Deprecated.
Initializes a top level, the data are considered as non initalized.
|
void |
copyData(int[] dst)
Deprecated.
copies some data to a int[], primarily to debug a content.
|
void |
copyDataFrom(ByteDataAccessOld src)
Deprecated.
Copies the data into a byte[]
|
protected void |
correctCurrentChildEnd(int idxEndNew)
Deprecated.
Increments the idxEnd and the idxCurrentChildEnd if a new child is added.
|
private void |
correctIdxChildEnd(int idxCurrentChildEndNew)
Deprecated.
Increments the idxEnd if a new child is added.
|
void |
detach()
Deprecated.
Remove all connections.
|
void |
elementAt(int indexObjectArray)
Deprecated.
Counts the idxChild by given index, idxChild is ByteCount from idxBegin
|
void |
expandParent()
Deprecated.
Expands the end index of the parent, it means the management
of the expanse of the data.
|
protected char |
getChar(int idx)
Deprecated.
Returns the content of 1 bytes as ASCII
inside the actual element.
|
double |
getChildDouble()
Deprecated.
Adds a child for 1 double value without a child instance, but returns the value as integer.
|
float |
getChildFloat()
Deprecated.
Adds a child for 1 float value without a child instance, but returns the value as integer.
|
long |
getChildInteger(int nrofBytes)
Deprecated.
Adds a child for 1 integer value without a child instance, but returns the value as integer.
|
java.lang.String |
getChildString(int nrofBytes)
Deprecated.
Adds a child for a String value without a child instance, but returns the value as String.
|
ByteDataAccessOld |
getCurrentChild()
Deprecated.
|
byte[] |
getData()
Deprecated.
Returns the data buffer itself.
|
protected double |
getDouble(int idx)
Deprecated.
|
protected float |
getFloat(int idx)
Deprecated.
Gets a float value from the content of 4 byte.
|
protected float |
getFloat(int idxBytes,
int idxArray,
int lengthArray)
Deprecated.
|
protected short |
getInt16(int idx)
Deprecated.
Returns the content of 2 bytes as a positive nr between 0..65535 inside the actual element.
|
protected int |
getInt16(int idxBytes,
int idxArray,
int lengthArray)
Deprecated.
|
int |
getInt32(int idx)
Deprecated.
Returns the content of 4 bytes inside the actual element as a integer number between -2147483648 and 2147483647,
big- or little-endian depending on setBigEndian().
|
protected int |
getInt32(int idxBytes,
int idxArray,
int lengthArray)
Deprecated.
|
protected long |
getInt64(int idx)
Deprecated.
|
protected byte |
getInt8(int idx)
Deprecated.
Returns the content of 1 bytes as a positive or negative nr between -128..127
inside the actual element.
|
protected int |
getInt8(int idxBytes,
int idxArray,
int lengthArray)
Deprecated.
|
int |
getLength()
Deprecated.
Returns the length of the existing actual element.
|
int |
getLengthCurrentChildElement()
Deprecated.
Returns the length of the current child element.
|
int |
getLengthHead()
Deprecated.
returns the length of the head.
|
int |
getLengthTotal()
Deprecated.
Returns the length of the data.
|
int |
getMaxNrofBytes()
Deprecated.
returns the number number of bytes there are max available from position of the current child
|
int |
getMaxNrofBytesForNextChild()
Deprecated.
returns the number number of bytes there are max available from position of a next current child
|
int |
getPositionInBuffer()
Deprecated.
Returns the position of the Element data in the assigned buffer.
|
int |
getPositionNextChildInBuffer()
Deprecated.
Returns the position of the current child in the assigned buffer.
|
protected java.lang.String |
getString(int idx,
int nmax)
Deprecated.
Returns a String from the given position inside the actual element .
|
java.lang.String |
getText()
Deprecated.
Returns the current string or null on end
|
protected int |
getUint16(int idx)
Deprecated.
Returns the content of 2 bytes as a positive nr between 0..65535, big-endian
inside the actual element.
|
protected int |
getUint16(int idxBytes,
int idxArray,
int lengthArray)
Deprecated.
|
int |
getUint32(int idx)
Deprecated.
|
protected int |
getUint32(int idxBytes,
int idxArray,
int lengthArray)
Deprecated.
|
protected int |
getUint8(int idx)
Deprecated.
Returns the content of 1 bytes as a positive or negative nr between -128..127
inside the actual element.
|
protected int |
getUint8(int idxBytes,
int idxArray,
int lengthArray)
Deprecated.
|
boolean |
isTextByte(byte nn)
Deprecated.
Returns true if the current child element represents a TEXT(), direct ASCII chars,
false if the element is a complex element.
|
int |
next()
Deprecated.
Sets the data index to the position after the current child element and returns its code.
|
protected void |
notifyAddChild()
Deprecated.
Notifies, that a child is added.
|
void |
removeChild()
Deprecated.
remove the current child to assign another current child instead of the first one.
|
void |
removeChildren()
Deprecated.
Remove all children.
|
void |
reset(int lengthData)
Deprecated.
Resets the view to the buffer.
|
void |
rewind()
Deprecated.
starts the calling loop of next().
|
void |
setBigEndian(boolean val)
Deprecated.
Sets the big or little endian mode.
|
protected void |
setDouble(int idx,
double value)
Deprecated.
Set the content of 8 byte from a double variable.
|
protected void |
setFloat(int idx,
float value)
Deprecated.
Set the content of 4 byte from a float variable.
|
protected void |
setFloat(int idxBytes,
int idxArray,
int lengthArray,
float val)
Deprecated.
|
protected boolean |
setIdxCurrentChildEnd(int nrofBytes)
Deprecated.
sets the idxCurrentChildEnd and idxEnd.
|
private void |
setIdxtoNextCurrentChild()
Deprecated.
sets the idxCurrentChild to the known idxCurrentChildEnd.
|
protected void |
setInt16(int idx,
int value)
Deprecated.
Set the content of 2 bytes from an integer between -32768..32768,
or from an integer number between 0..65535.
|
protected void |
setInt16(int idxBytes,
int idxArray,
int lengthArray,
int val)
Deprecated.
|
protected void |
setInt32(int idx,
int value)
Deprecated.
Set the content of 4 bytes as a integer number between -2147483648 and 2147483647,
big- or little-endian depended from setBigEndian().
|
protected void |
setInt32(int idxBytes,
int idxArray,
int lengthArray,
int val)
Deprecated.
|
protected void |
setInt8(int idx,
int value)
Deprecated.
Set the content of 1 bytes as a positive nr between 0..256.
|
protected void |
setInt8(int idxBytes,
int idxArray,
int lengthArray,
int val)
Deprecated.
|
void |
setLengthCurrentChildElement(int lengthOfCurrentChild)
Deprecated.
Sets the length of the current child element after calling next().
|
void |
setLengthElement(int length)
Deprecated.
Sets the length of the element in this and all
parent of this. |
protected int |
setString(int idx,
int nmax,
java.lang.String ss)
Deprecated.
Sets a String to the the given position inside the actual element .
|
protected void |
setUint16(int idx,
int value)
Deprecated.
Set the content of 2 bytes as a positive nr between 0..65535, big- or little-endian.
|
protected void |
setUint16(int idxBytes,
int idxArray,
int lengthArray,
int val)
Deprecated.
|
protected void |
setUint32(int idxBytes,
int idxArray,
int lengthArray,
int val)
Deprecated.
|
protected void |
setUint32(int idx,
long value)
Deprecated.
Set the content of 4 bytes as a positive nr between 0..2pow32-1, big- or little-endian.
|
protected void |
setUint8(int idx,
int value)
Deprecated.
Set the content of 1 bytes as a positive nr between 0..255, big- or little-endian.
|
protected void |
setUint8(int idxBytes,
int idxArray,
int lengthArray,
int val)
Deprecated.
|
protected abstract void |
specifyEmptyDefaultData()
Deprecated.
Sets the elements data to the default empty data.
|
protected int |
specifyLengthCurrentChildElement()
Deprecated.
Returns the length of a child element at current position specified in the derivated class.
|
protected abstract int |
specifyLengthElement()
Deprecated.
Returns the actual length of the whole data presenting with this instance.
|
abstract int |
specifyLengthElementHead()
Deprecated.
Specifies the length of the head data.
|
boolean |
sufficingBytesForNextChild(int nrofBytes)
Deprecated.
returns true if the given number of bytes is sufficing in the data from position of next child.
|
public static final int _version_
reset(int)
, some comments.
protected byte[] data
protected int idxBegin
protected int idxEnd
protected boolean bExpand
idxEnd
should be increment on adding children. It is to write.protected int idxFirstChild
protected int idxCurrentChild
protected int idxCurrentChildEnd
protected boolean bBigEndian
private ByteDataAccessOld parent
private ByteDataAccessOld currentChild
java.lang.String charset
public static final byte kEndOfElements
public static final byte kNothing
public static final byte kText
public static final byte kUndefined
protected static final int kIdxElementCode
protected ByteDataAccessOld()
public final int getLengthHead()
specifyLengthElementHead()
of the derived class. But this method returns the difference between (idxFirstChild - idxBegin),
which is initialized in construction or assignData(byte[], int)
-invocations and not changed normally.protected abstract void specifyEmptyDefaultData()
protected void specifyEmptyDefaultData() { data[idxBegin + 0] = 0; data[idxBegin + kIdxMid] = 0; data[idxBegin + kIdxMin] = kNotAValue; data[idxBegin + kIdxMax] = kNotAValue; }The default implementation is empty.
public abstract int specifyLengthElementHead()
protected void specifyLengthElementHead() { return kIdxFirstChild; //kIdxFistChild should be defined as static final int. }
protected abstract int specifyLengthElement() throws java.lang.IllegalArgumentException
idxEnd
.
java.lang.IllegalArgumentException
- If the data inside are corrupted, the user can throw this exception.protected int specifyLengthCurrentChildElement() throws java.lang.IllegalArgumentException
int eChildCode = dataCode.next(); switch(eChildCode) { case ...: { child.assignAsChild(dataCode); //the child is known yet! dataCode.setLengthCurrentChildElement(child.getLength()); .... }If the user always calls setLengthCurrentChildElement in this manner, he don't need to overwrite specifyLengthCurrentChildElement.
java.lang.IllegalArgumentException
public void assignData(byte[] data, int length) throws java.lang.IllegalArgumentException
assign(null, 0);
.
data
- The data. The length of data may be greater as
the number of the significant bytes.length
- Number of significant bytes in data.
If length is > data.length, an exception may be thrown
in any state of the evaluation.java.lang.IllegalArgumentException
- if the length is > data.lengthpublic void assignData(byte[] data, int lengthData, int index) throws java.lang.IllegalArgumentException
assign(null, 0);
.
data
- The data. The length of data may be greater as
the number of the significant bytes.lengthData
- absolute Number of significant bytes in data from idx=0.
If length is > data.length, an exception is thrown.
If the length is <0 (especially -1), it means, it is not known outside.
Than the element is initialized with its known head length.
The length mustn't not ==0, it is tested. Use -1 also if the head length is 0.index
- Start position in datajava.lang.IllegalArgumentException
public final void reset(int lengthData)
reset(0); //all data are invalid.In that case the head data are initialized callingspecifyEmptyDefaultData()
from the derived class.
Or the data are set newly with any designated content, then callreset(length); with the known length. Then the data can be evaluate by callingaddChild(ByteDataAccessOld)
. or by getting data from the head only if children should ot be used.
SeeassignEmpty(byte[])
,assignData(byte[], int)
. This routine is called there after setting the data reference and theidxBegin
. In opposite to the newly assignment of data, thedata
-reference is not changed, theidxBegin
is not changed and aparent
is not changed. It means, a reset can be invoked for any child of data without changing the context.
lengthData
- Number of valid designated content in the associated buffer.public final void assignEmpty(byte[] data)
specifyLengthElementHead()
. The child Positions
are set to the end of head, no childs are presumed.
The head should be filled with data after that calling some methods like
setInt32(int, int)
.addChild(ByteDataAccessOld)
and filled with data after that.
...........the data undefined with defined length......... +++++ Head, the length should be known. ####****#####**** Space for children,
data
- The data. The reference should be initialized, it means
the data have a defined maximum of length. But it is not tested here.java.lang.IllegalArgumentException
public final void removeChildren()
public final void detach()
protected final void assignCasted_i(ByteDataAccessOld src, int offsetCastToInput, int lengthDst) throws java.lang.IllegalArgumentException
src
- The known data accessoffsetCastToInput
- typical 0 if single inherition is used.java.lang.IllegalArgumentException
- if a length of the new type is specified but the byte[]-data are shorter.
The length of byte[] is tested.protected final void assignDowncast_i(ByteDataAccessOld input) throws java.lang.IllegalArgumentException
assignCasted_i(ByteDataAccessOld, int )
If a cast is possible, it should be programmed in the derivated class.input
- java.lang.IllegalArgumentException
@Deprecated public final void assignAsChild(ByteDataAccessOld parent) throws java.lang.IllegalArgumentException
next()
should be called before. The pattern of using is:
int nWhat; //code of the element while( (nWhat = dataElement.next()) != ByteDataAccessOld.kEndOfElements ) { switch(nWhat) //test the first byte of the current element { case ByteDataAccessOld.kText: { sText = dataElement.getText(); } break; case code1: { code1Element.assignAsChild(dataElement); evaluateValue(code1Element); } break: case code2: { code1Element.assignAsChild(dataElement); evaluateValue(code1Element); } break: default: throw new IllegalArgumentException("unknown Element", dataElement); } }The difference to
addChild(ByteDataAccessOld)
is: addChild() is used
to writeout to data, addChild() appends the child always after idxEnd,
but this method is used to read from data and appends the child at position of the current child.
specifyLengthElementHead()
: idxChild
and specifyLengthElement()
: idxEnd.
The idxChildEnd of parent is setted, so calling next() after this operation
increments in data after this new child.
parent
- The parent. It should reference data, and a current child position
should be set by calling next() before. See sample at next()
.java.lang.IllegalArgumentException
- If the data are wrong. The exception is thrown
orginal from specifyLengthElement()
.public final void assignAtIndex(int idxChildInParent, int lengthChild, ByteDataAccessOld parent) throws java.lang.IllegalArgumentException
addChild(ByteDataAccessOld)
is: The position is given here
directly, it should not be the current child but a free child.
specifyLengthElementHead()
: idxChild
and specifyLengthElement()
: idxEnd.
parent
- The parent. It should reference data.lengthChild
- Number of the bytes of the free child.idxChildInParent
- The index of the free child in the data.java.lang.IllegalArgumentException
- If the indices are wrong in respect to the data.public final void assignAtIndex(int idxChildInParent, ByteDataAccessOld parent) throws java.lang.IllegalArgumentException
parent
- The parent. It should reference data.idxChildInParent
- The index of the free child in the data.java.lang.IllegalArgumentException
- If the indices are wrong in respect to the data.protected void assignDataToFixChilds() throws java.lang.IllegalArgumentException
assignDataAtIndex(byte[], int)
should be called for the fix childs.
example:java.lang.IllegalArgumentException
public final boolean addChild(ByteDataAccessOld child) throws java.lang.IllegalArgumentException
ByteAccessDerivation child = new ByteAccessDerivation(); //empty and unassigned. parent.addChild(child); //The byte[] data of parent are assigned, index after current child index of parent. child.addChild(grandchild); //By adding a child to this child, also the parent's index is corrected.
child
- The child will be assigned with the data of this at index after the current child's end-index.java.lang.IllegalArgumentException
- if the length of the old current child is not determined yet.
Either the method specifyLengthElement() should be overwritten or the method
setLengthElement(int)
for the child or setLengthCurrentChildElement(int)
should be called to prevent this exception.java.lang.IllegalArgumentException
- if the length of the head of the new current child is to far for the data.
It means, child.idxEnd > data.length.public final void removeChild() throws java.lang.IllegalArgumentException
child
- java.lang.IllegalArgumentException
private final void setIdxtoNextCurrentChild()
next()
was called before. Than this operation is done already, a second call does nothing.
protected final boolean setIdxCurrentChildEnd(int nrofBytes) throws java.lang.IllegalArgumentException
nrofBytes
- of the childjava.lang.IllegalArgumentException
- if there are not enough data.
In expanded mode the data.length are to less.
In using existing data: idxEnd are to less.public final void addChildEmpty(ByteDataAccessOld child) throws java.lang.IllegalArgumentException
child.specifyEmptyDefaultData().
child
- The child will associated to this and should be used
to add some content.java.lang.IllegalArgumentException
protected void notifyAddChild()
protected final void correctCurrentChildEnd(int idxEndNew)
private final void correctIdxChildEnd(int idxCurrentChildEndNew)
public final void expandParent() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public final long getChildInteger(int nrofBytes) throws java.lang.IllegalArgumentException
nrofBytes
- of the integerjava.lang.IllegalArgumentException
- if not data has not enaught bytes.public final float getChildFloat() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if not data has not enaught bytes.public final double getChildDouble() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if not data has not enaught bytes.public final void addChildInteger(int nrofBytes, long value) throws java.lang.IllegalArgumentException
nrofBytes
- of the integerjava.lang.IllegalArgumentException
public final void addChildFloat(float value) throws java.lang.IllegalArgumentException
nrofBytes
- of the integerjava.lang.IllegalArgumentException
public final java.lang.String getChildString(int nrofBytes) throws java.lang.IllegalArgumentException, java.io.UnsupportedEncodingException
nrofBytes
- of the integerjava.lang.IllegalArgumentException
- if not data has not enaught bytes.java.io.UnsupportedEncodingException
public final void addChildString(java.lang.String value, java.lang.String sEncoding, boolean preventCtrlChars) throws java.lang.IllegalArgumentException, java.io.UnsupportedEncodingException
value
- String to addsEncoding
- If null then use the standard encoding of the system-environment.preventCtrlChars
- true then values < 0x20 are not set.
If the String value contain a control character with code < 0x20,
a '?' is written. This behavior guarantees, that byte-values < 0x20
can use to detect no-String elements, see getByteNextChild()
.java.lang.IllegalArgumentException
java.io.UnsupportedEncodingException
public final void addChildString(java.lang.String value) throws java.lang.IllegalArgumentException
value
- String to addjava.lang.IllegalArgumentException
public final void addChildString(java.lang.CharSequence value, java.lang.String sEncoding) throws java.lang.IllegalArgumentException, java.io.UnsupportedEncodingException
value
- String to add, @pjava2c=nonPersistent.java.lang.IllegalArgumentException
java.io.UnsupportedEncodingException
public final void addChildString(java.lang.CharSequence value) throws java.lang.IllegalArgumentException
value
- String to add, @pjava2c=nonPersistent.java.lang.IllegalArgumentException
@Deprecated public final int addText(java.lang.String ss) throws java.lang.IllegalArgumentException
ss
- The String to writecolor
- The colorjava.lang.IllegalArgumentException
public final void rewind()
public final int next() throws java.lang.IllegalArgumentException
while( (eElement = code.next()) != kEndOfElements) { switch(eElement) { ... } }
java.lang.IllegalArgumentException
public final boolean sufficingBytesForNextChild(int nrofBytes) throws java.lang.IllegalArgumentException
nrofBytes
- that should fitting in the given data range from current child position
to the end of data determines by calling assingData(...)
or by calling addChild() with a known size of child or setLengthElement() .java.lang.IllegalArgumentException
- see getMaxNrofBytesForNextChild()
public final int getMaxNrofBytesForNextChild() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if the length of the current child is not determined yet.
Either the method specifyLengthElement() should be overwritten or the method
setLengthElement(int)
for the child or setLengthCurrentChildElement(int)
should be called to prevent this exception.public final int getMaxNrofBytes()
public final int getLength()
public final int getLengthTotal()
public final byte[] getData()
public final int getPositionInBuffer()
public final int getPositionNextChildInBuffer()
public final int getLengthCurrentChildElement() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if the user has not defined a overloaded methode specifyLengthCurrentChildElement()
or this method has thrown the exception because the length is not determinable.public final void setLengthCurrentChildElement(int lengthOfCurrentChild)
public final void setLengthElement(int length)
parent
of this.
If the element is a child of any parent, it should be the current child of the parent.
The idxEnd
and the idxCurrentChildEnd
of this and all its parents is set
with the (this.idxBegin
+length).
addChild(ByteDataAccessOld)
).
It is if the element has data after the head with different length without an own children structure.length
- The length of data of this current (last) child.public final boolean isTextByte(byte nn)
public final java.lang.String getText()
protected java.lang.String getString(int idx, int nmax)
idx
- The start position inside the child.nmax
- Maximal number of bytesprotected int setString(int idx, int nmax, java.lang.String ss)
idx
- The start position inside the child.nmax
- Maximal number of bytesss
- The String representation of the bytes.public void setBigEndian(boolean val)
val
- true if big endian, hi byte at lower adress, false if little endian.protected final long _getLong(int idxInChild, int nrofBytesAndSign)
idxInChild
- The position of leading byte in the actual element, the data are taken from data[idxBegin+idx].nrofBytesAndSign
- If positiv, than the method returns the unsigned interpretation of the bytes.
If negative, than the return value is negative, if the last significant bit of the given number of bytes is set.
The value represents the number of bytes to interprete as integer. It may be 1..8 respectively -1...-8.protected final void _setLong(int idx, int nrofBytes, long val)
idx
- the position of leading byte in the actual element, the data are set to data[idxBegin+idx].nrofBytes
- The number of bytes of the value.val
- the long value in range adequate nrof bytes.protected final java.lang.String _getString(int idx, int nrofBytes) throws java.io.UnsupportedEncodingException
getByteNextChild()
.
This method is protected because at user level its using is a prone to errors because the idx is free related.idx
- the position in the actual element, the data are set to data[idxBegin+idx].nrofBytes
- The length of the byte[] area to set.
If the String value is longer as nrofBytes, it will be truncated. No exception occurs.
If the String is shorter as nrofBytes, the rest is filled with 0.value
- The String value.java.io.UnsupportedEncodingException
protected final void _setString(int idx, int nrofBytes, java.lang.String value, java.lang.String sEncoding, boolean preventCtrlChars) throws java.io.UnsupportedEncodingException
idx
- the position in the actual element, the data are set to data[idxBegin+idx].nrofBytes
- The length of the byte[] area to set.
If the String value is longer as nrofBytes, it will be truncated. No exception occurs.
If the String is shorter as nrofBytes, the rest is filled with 0.value
- The String value.sEncoding
- The encoding of the String. null: Use standard encoding.preventCtrlChars
- true then values < 0x20 are not set.
If the String value contain a control character with code < 0x20,
a '?' is written. This behavior guarantees, that byte-values < 0x20
can use to detect no-String elements, see getByteNextChild()
.java.io.UnsupportedEncodingException
public final void copyData(int[] dst)
dst
- This array is field, but only from data of the current element between idxBegin and idxEndprotected final float getFloat(int idx)
protected final double getDouble(int idx)
protected final long getInt64(int idx)
public final int getInt32(int idx)
idx
- the position of leading byte in the actual element, the data are raken from data[idxBegin+idx].
This is not the absolute position in data, idxBegin is added.public final int getUint32(int idx)
protected final int getUint16(int idx)
idx
- the position of leading byte in the actual element, the data are raken from data[idxBegin+idx].
This is not the absolute position in data, idxBegin is added.protected final short getInt16(int idx)
idx
- the position of leading byte in the actual element, the data are raken from data[idxBegin+idx].
This is not the absolute position in data, idxBegin is added.protected final char getChar(int idx)
idx
- the position of char in the actual element, the data are raken from data[idxBegin+idx].
This is not the absolute position in data, idxBegin is added.protected final byte getInt8(int idx)
idx
- the position of leading byte in the actual element, the data are raken from data[idxBegin+idx].
This is not the absolute position in data, idxBegin is added.protected final int getUint8(int idx)
idx
- the position of leading byte in the actual element, the data are raken from data[idxBegin+idx].
This is not the absolute position in data, idxBegin is added.protected final int getUint32(int idxBytes, int idxArray, int lengthArray)
protected final int getInt32(int idxBytes, int idxArray, int lengthArray)
protected final int getInt16(int idxBytes, int idxArray, int lengthArray)
protected final int getInt8(int idxBytes, int idxArray, int lengthArray)
protected int getUint16(int idxBytes, int idxArray, int lengthArray)
protected int getUint8(int idxBytes, int idxArray, int lengthArray)
protected float getFloat(int idxBytes, int idxArray, int lengthArray)
protected final void setFloat(int idx, float value)
protected final void setDouble(int idx, double value)
protected final void setInt32(int idx, int value)
idx
- The position of leading byte in the current elements data.
This is not the absolute position in data, idxBegin is added.value
- The value in range 0..65535. The value is taken modulo 0xffffffff.protected final void setUint8(int idx, int value)
idx
- The position of leading byte in the current elements data.
This is not the absolute position in data, idxBegin is added.value
- The value in range 0..65535. The value is taken modulo 0xff.protected final void setUint16(int idx, int value)
idx
- The position of leading byte in the current elements data.
This is not the absolute position in data, idxBegin is added.value
- The value in range 0..65535. The value is taken modulo 0xffff.protected final void setUint32(int idx, long value)
idx
- The position of leading byte in the current elements data.
This is not the absolute position in data, idxBegin is added.value
- The value as long. The value is taken modulo 0xffffffff.protected final void setInt16(int idx, int value)
idx
- The position of leading byte in the current elements data.
This is not the absolute position in data, idxBegin is added.value
- The value in range 0..65535. The value is taken modulo 0xffff.protected final void setInt8(int idx, int value)
idx
- The position of leading byte in the current elements data.
This is not the absolute position in data, idxBegin is added.value
- The value in range 0..65535. The value is taken modulo 0xffff.protected final void setUint32(int idxBytes, int idxArray, int lengthArray, int val)
protected final void setInt32(int idxBytes, int idxArray, int lengthArray, int val)
protected final void setInt16(int idxBytes, int idxArray, int lengthArray, int val)
protected final void setInt8(int idxBytes, int idxArray, int lengthArray, int val)
protected final void setUint16(int idxBytes, int idxArray, int lengthArray, int val)
protected final void setUint8(int idxBytes, int idxArray, int lengthArray, int val)
protected final void setFloat(int idxBytes, int idxArray, int lengthArray, float val)
public final void copyDataFrom(ByteDataAccessOld src) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public final void elementAt(int indexObjectArray)
indexObjectArray
- Index of Arraypublic final boolean assertNotExpandable()
public final ByteDataAccessOld getCurrentChild()