FileDocCategorySizeDatePackage
BerTlv.javaAPI DocAndroid 1.5 API3578Wed May 06 22:42:02 BST 2009com.android.internal.telephony.gsm.stk

BerTlv

public class BerTlv extends Object
Class for representing BER-TLV objects.
see
"ETSI TS 102 223 Annex C" for more information. {@hide}

Fields Summary
private int
mTag
private List
mCompTlvs
public static final int
BER_UNKNOWN_TAG
public static final int
BER_PROACTIVE_COMMAND_TAG
public static final int
BER_MENU_SELECTION_TAG
public static final int
BER_EVENT_DOWNLOAD_TAG
Constructors Summary
private BerTlv(int tag, List ctlvs)


         
        mTag = tag;
        mCompTlvs = ctlvs;
    
Methods Summary
public static com.android.internal.telephony.gsm.stk.BerTlvdecode(byte[] data)
Decodes a BER-TLV object from a byte array.

param
data A byte array to decode from
return
A BER-TLV object decoded
throws
ResultException

        int curIndex = 0;
        int endIndex = data.length;
        int tag, length = 0;

        try {
            /* tag */
            tag = data[curIndex++] & 0xff;
            if (tag == BER_PROACTIVE_COMMAND_TAG) {
                /* length */
                int temp = data[curIndex++] & 0xff;
                if (temp < 0x80) {
                    length = temp;
                } else if (temp == 0x81) {
                    temp = data[curIndex++] & 0xff;
                    if (temp < 0x80) {
                        throw new ResultException(
                                ResultCode.CMD_DATA_NOT_UNDERSTOOD);
                    }
                    length = temp;
                } else {
                    throw new ResultException(
                            ResultCode.CMD_DATA_NOT_UNDERSTOOD);
                }
            } else {
                if (ComprehensionTlvTag.COMMAND_DETAILS.value() == (tag & ~0x80)) {
                    tag = BER_UNKNOWN_TAG;
                    curIndex = 0;
                }
            }
        } catch (IndexOutOfBoundsException e) {
            throw new ResultException(ResultCode.REQUIRED_VALUES_MISSING);
        } catch (ResultException e) {
            throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
        }

        /* COMPREHENSION-TLVs */
        if (endIndex - curIndex < length) {
            throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD);
        }

        List<ComprehensionTlv> ctlvs = ComprehensionTlv.decodeMany(data,
                curIndex);

        return new BerTlv(tag, ctlvs);
    
public java.util.ListgetComprehensionTlvs()
Gets a list of ComprehensionTlv objects contained in this BER-TLV object.

return
A list of COMPREHENSION-TLV object

        return mCompTlvs;
    
public intgetTag()
Gets a tag id of the BER-TLV object.

return
A tag integer.

        return mTag;