Methods Summary |
---|
static java.lang.String | retrieveAlphaId(ComprehensionTlv ctlv)Retrieves alpha identifier from an Alpha Identifier COMPREHENSION-TLV
object.
byte[] rawValue = ctlv.getRawValue();
int valueIndex = ctlv.getValueIndex();
int length = ctlv.getLength();
if (length != 0) {
try {
return SimUtils.adnStringFieldToString(rawValue, valueIndex,
length);
} catch (IndexOutOfBoundsException e) {
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
}
}
return null;
|
static CommandDetails | retrieveCommandDetails(ComprehensionTlv ctlv)Search for a Command Details object from a list.
CommandDetails cmdDet = new CommandDetails();
byte[] rawValue = ctlv.getRawValue();
int valueIndex = ctlv.getValueIndex();
try {
cmdDet.compRequired = ctlv.isComprehensionRequired();
cmdDet.commandNumber = rawValue[valueIndex] & 0xff;
cmdDet.typeOfCommand = rawValue[valueIndex + 1] & 0xff;
cmdDet.commandQualifier = rawValue[valueIndex + 2] & 0xff;
return cmdDet;
} catch (IndexOutOfBoundsException e) {
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
}
|
static DeviceIdentities | retrieveDeviceIdentities(ComprehensionTlv ctlv)Search for a Device Identities object from a list.
DeviceIdentities devIds = new DeviceIdentities();
byte[] rawValue = ctlv.getRawValue();
int valueIndex = ctlv.getValueIndex();
try {
devIds.sourceId = rawValue[valueIndex] & 0xff;
devIds.destinationId = rawValue[valueIndex + 1] & 0xff;
return devIds;
} catch (IndexOutOfBoundsException e) {
throw new ResultException(ResultCode.REQUIRED_VALUES_MISSING);
}
|
static Duration | retrieveDuration(ComprehensionTlv ctlv)Retrieves Duration information from the Duration COMPREHENSION-TLV
object.
int timeInterval = 0;
TimeUnit timeUnit = TimeUnit.SECOND;
byte[] rawValue = ctlv.getRawValue();
int valueIndex = ctlv.getValueIndex();
try {
timeUnit = TimeUnit.values()[(rawValue[valueIndex] & 0xff)];
timeInterval = rawValue[valueIndex + 1] & 0xff;
} catch (IndexOutOfBoundsException e) {
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
}
return new Duration(timeInterval, timeUnit);
|
static IconId | retrieveIconId(ComprehensionTlv ctlv)Retrieves icon id from an Icon Identifier COMPREHENSION-TLV object
IconId id = new IconId();
byte[] rawValue = ctlv.getRawValue();
int valueIndex = ctlv.getValueIndex();
try {
id.selfExplanatory = (rawValue[valueIndex++] & 0xff) == 0x00;
id.recordNumber = rawValue[valueIndex] & 0xff;
} catch (IndexOutOfBoundsException e) {
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
}
return id;
|
static Item | retrieveItem(ComprehensionTlv ctlv)Retrieves Item information from the COMPREHENSION-TLV object.
Item item = null;
byte[] rawValue = ctlv.getRawValue();
int valueIndex = ctlv.getValueIndex();
int length = ctlv.getLength();
if (length != 0) {
int textLen = length - 1;
try {
int id = rawValue[valueIndex] & 0xff;
String text = SimUtils.adnStringFieldToString(rawValue,
valueIndex + 1, textLen);
item = new Item(id, text);
} catch (IndexOutOfBoundsException e) {
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
}
}
return item;
|
static int | retrieveItemId(ComprehensionTlv ctlv)Retrieves Item id information from the COMPREHENSION-TLV object.
int id = 0;
byte[] rawValue = ctlv.getRawValue();
int valueIndex = ctlv.getValueIndex();
try {
id = rawValue[valueIndex] & 0xff;
} catch (IndexOutOfBoundsException e) {
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
}
return id;
|
static ItemsIconId | retrieveItemsIconId(ComprehensionTlv ctlv)Retrieves item icons id from an Icon Identifier List COMPREHENSION-TLV
object
StkLog.d("ValueParser", "retrieveItemsIconId:");
ItemsIconId id = new ItemsIconId();
byte[] rawValue = ctlv.getRawValue();
int valueIndex = ctlv.getValueIndex();
int numOfItems = ctlv.getLength() - 1;
id.recordNumbers = new int[numOfItems];
try {
// get icon self-explanatory
id.selfExplanatory = (rawValue[valueIndex++] & 0xff) == 0x00;
for (int index = 0; index < numOfItems;) {
id.recordNumbers[index++] = rawValue[valueIndex++];
}
} catch (IndexOutOfBoundsException e) {
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
}
return id;
|
static java.util.List | retrieveTextAttribute(ComprehensionTlv ctlv)Retrieves text attribute information from the Text Attribute
COMPREHENSION-TLV object.
ArrayList<TextAttribute> lst = new ArrayList<TextAttribute>();
byte[] rawValue = ctlv.getRawValue();
int valueIndex = ctlv.getValueIndex();
int length = ctlv.getLength();
if (length != 0) {
// Each attribute is consisted of four bytes
int itemCount = length / 4;
try {
for (int i = 0; i < itemCount; i++, valueIndex += 4) {
int start = rawValue[valueIndex] & 0xff;
int textLength = rawValue[valueIndex + 1] & 0xff;
int format = rawValue[valueIndex + 2] & 0xff;
int colorValue = rawValue[valueIndex + 3] & 0xff;
int alignValue = format & 0x03;
TextAlignment align = TextAlignment.fromInt(alignValue);
int sizeValue = (format >> 2) & 0x03;
FontSize size = FontSize.fromInt(sizeValue);
if (size == null) {
// Font size value is not defined. Use default.
size = FontSize.NORMAL;
}
boolean bold = (format & 0x10) != 0;
boolean italic = (format & 0x20) != 0;
boolean underlined = (format & 0x40) != 0;
boolean strikeThrough = (format & 0x80) != 0;
TextColor color = TextColor.fromInt(colorValue);
TextAttribute attr = new TextAttribute(start, textLength,
align, size, bold, italic, underlined,
strikeThrough, color);
lst.add(attr);
}
return lst;
} catch (IndexOutOfBoundsException e) {
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
}
}
return null;
|
static java.lang.String | retrieveTextString(ComprehensionTlv ctlv)Retrieves text from the Text COMPREHENSION-TLV object, and decodes it
into a Java String.
byte[] rawValue = ctlv.getRawValue();
int valueIndex = ctlv.getValueIndex();
byte codingScheme = 0x00;
String text = null;
int textLen = ctlv.getLength();
// In case the text length is 0, return a null string.
if (textLen == 0) {
return text;
} else {
// one byte is coding scheme
textLen -= 1;
}
try {
codingScheme = (byte) (rawValue[valueIndex] & 0x0c);
if (codingScheme == 0x00) { // GSM 7-bit packed
text = GsmAlphabet.gsm7BitPackedToString(rawValue,
valueIndex + 1, (textLen * 8) / 7);
} else if (codingScheme == 0x04) { // GSM 8-bit unpacked
text = GsmAlphabet.gsm8BitUnpackedToString(rawValue,
valueIndex + 1, textLen);
} else if (codingScheme == 0x08) { // UCS2
text = new String(rawValue, valueIndex + 1, textLen, "UTF-16");
} else {
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
}
return text;
} catch (IndexOutOfBoundsException e) {
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
} catch (UnsupportedEncodingException e) {
// This should never happen.
throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
}
|