Methods Summary |
---|
public byte[] | getData()Returns data associated with current TLV object
returns null if !isValidObject()
if (!mHasValidTlvObject) return null;
byte[] ret = new byte[mCurDataLength];
System.arraycopy(mRecord, mCurDataOffset, ret, 0, mCurDataLength);
return ret;
|
public int | getTag()Returns the tag for the current TLV object
Return 0 if !isValidObject()
0 and 0xff are invalid tag values
valid tags range from 1 - 0xfe
if (!mHasValidTlvObject) return 0;
return mRecord[mCurOffset] & 0xff;
|
public boolean | isValidObject()
return mHasValidTlvObject;
|
public boolean | nextObject()
if (!mHasValidTlvObject) return false;
mCurOffset = mCurDataOffset + mCurDataLength;
mHasValidTlvObject = parseCurrentTlvObject();
return mHasValidTlvObject;
|
private boolean | parseCurrentTlvObject()Updates curDataLength and curDataOffset
// 0x00 and 0xff are invalid tag values
try {
if (mRecord[mCurOffset] == 0 || (mRecord[mCurOffset] & 0xff) == 0xff) {
return false;
}
if ((mRecord[mCurOffset + 1] & 0xff) < 0x80) {
// one byte length 0 - 0x7f
mCurDataLength = mRecord[mCurOffset + 1] & 0xff;
mCurDataOffset = mCurOffset + 2;
} else if ((mRecord[mCurOffset + 1] & 0xff) == 0x81) {
// two byte length 0x80 - 0xff
mCurDataLength = mRecord[mCurOffset + 2] & 0xff;
mCurDataOffset = mCurOffset + 3;
} else {
return false;
}
} catch (ArrayIndexOutOfBoundsException ex) {
return false;
}
if (mCurDataLength + mCurDataOffset > mTlvOffset + mTlvLength) {
return false;
}
return true;
|