FileDocCategorySizeDatePackage
EditHandler.javaAPI DocphoneME MR2 API (J2ME)12489Wed May 02 18:00:40 BST 2007sim.toolkit

EditHandler

public abstract class EditHandler extends ViewHandler
This class is the basic class for the construction of a list of simple TLV elements. This class is able to handle Simple TLV with a value field no longer than 255 bytes.
version
8.3.0
see
ViewHandler
see
ProactiveHandler
see
EnvelopeResponseHandler
see
ToolkitException

Fields Summary
Constructors Summary
EditHandler()
Default constructor.

EditHandler(byte[] buffer, short offset, short length)
Builds a new EditHandler object.

param
buffer the buffer containg the TLV list
param
offset the position of the TLV list
param
length the length of the TLV list
exception
NullPointerException if buffer is null
exception
ArrayIndexOutOfBoundsException if offset or length or both would cause access outside array bounds

    
Methods Summary
public voidappendArray(byte[] buffer, short offset, short length)
Appends a buffer into the EditHandler buffer. A successful append does not modify the TLV selected. The TLV list structure of the handler should be maintained by the applet in the appended array (e.g. the length of the TLV element should be coded according to ISO 7816-6), if the TLV manipulation methods are to be used afterwards with the handler.

Notes:

  • If offset or length parameter is negative an ArrayIndexOutOfBoundsException exception is thrown and no append is performed.
  • If offset+length is greater than buffer.length, the length of the buffer array an ArrayIndexOutOfBoundsException exception is thrown and no append is performed.

param
buffer the buffer containing data for copy
param
offset the offset in the buffer
param
length the value length of the buffer
exception
NullPointerException if buffer is null
exception
ArrayIndexOutOfBoundsException if append would cause access of data outside array bounds
exception
ToolkitException with the following reason codes:
  • HANDLER_OVERFLOW if the EditHandler buffer is to small to append the requested data
  • HANDLER_NOT_AVAILABLE if the handler is busy

        byte[] APDUBuffer = ViewHandler.getAPDUBuffer();
        Util.arrayCopy(buffer, offset, APDUBuffer, (short)0, length);
        ViewHandler.setOutBufferData(length);
    
public voidappendTLV(byte tag, byte[] value, short valueOffset, short valueLength)
Appends a TLV element to the current TLV list (byte array format). A successful append does not modify the TLV selected.

Notes:

  • If valueOffset or valueLength parameter is negative an ArrayIndexOutOfBoundsException exception is thrown and no append is performed.
  • If valueOffset+valueLength is greater than value.length, the length of the value array an ArrayIndexOutOfBoundsException exception is thrown and no append is performed.

param
tag the tag of the TLV to append, including the Comprehension Required flag
param
value the buffer containing the TLV value
param
valueOffset the offset of the TLV value in the buffer
param
valueLength the value length of the TLV to append
exception
NullPointerException if value is null
exception
ArrayIndexOutOfBoundsException if append would cause access of data outside array bounds
exception
ToolkitException with the following reason codes:
  • HANDLER_OVERFLOW if the EditHandler buffer is to small to append the requested data
  • HANDLER_NOT_AVAILABLE if the handler is busy
  • BAD_INPUT_PARAMETER if valueLength is greater than 255

        byte[] APDUBuffer = ViewHandler.getAPDUBuffer();
        // prepare the data to be appended to the TLV list
        APDUBuffer[0] = tag;
        APDUBuffer[1] = (byte)valueLength;
        Util.arrayCopy(value, valueOffset, APDUBuffer, (short)2, valueLength);
        ViewHandler.setOutBufferData((short)(valueLength + 2));
    
public voidappendTLV(byte tag, byte value)
Appends a TLV element to the current TLV list (1-byte element). This method is useful to add single byte elements as Item Identifier or Tone. A successful append does not modify the TLV selected.

param
tag the tag of the TLV to append, including the Comprehension Required flag
param
value the TLV value on 1 byte
exception
ToolkitException with the following reason codes:
  • HANDLER_OVERFLOW if the EditHandler buffer is to small to append the requested data
  • HANDLER_NOT_AVAILABLE if the handler is busy

        byte[] APDUBuffer = ViewHandler.getAPDUBuffer();
        // prepare the data to be appended to the TLV list
        APDUBuffer[0] = tag; // set the tag
        APDUBuffer[1] = (byte)1; // 1-byte element so length is 1
        APDUBuffer[2] = value; // 1-byte element
        ViewHandler.setOutBufferData((short)3);
    
public voidappendTLV(byte tag, byte value1, byte value2)
Appends a TLV element to the current TLV list (2-byte element) This method is useful to add double byte elements as Device Identities, Duration or Response Length. A successful append does not modify the TLV selected.

param
tag the tag of the TLV to append, including the Comprehension Required flag
param
value1 the 1st byte (msb) of the TLV value
param
value2 the 2nd byte (lsb) of the TLV value
exception
ToolkitException with the following reason codes:
  • HANDLER_OVERFLOW if the EditHandler buffer is to small to append the requested data
  • HANDLER_NOT_AVAILABLE if the handler is busy

        byte[] APDUBuffer = ViewHandler.getAPDUBuffer();
        // prepare the data to be appended to the TLV list
        APDUBuffer[0] = tag; // set the tag
        APDUBuffer[1] = (byte)1; // 2-byte element so length is 1
        APDUBuffer[2] = value1; // 1-byte element
        APDUBuffer[3] = value2; // 1-byte element
        ViewHandler.setOutBufferData((short)4);
    
public voidappendTLV(byte tag, byte value1, byte[] value2, short value2Offset, short value2Length)
Appends a TLV element to the current TLV list (1 byte and a byte array format). A successful append does not modify the TLV selected.

Notes:

  • If value2Offset or value2Length parameter is negative an ArrayIndexOutOfBoundsException exception is thrown and no append is performed.
  • If value2Offset+value2Length is greater than value2.length, the length of the value2 array an ArrayIndexOutOfBoundsException exception is thrown and no append is performed.

param
tag the tag of the TLV to append, including the Comprehension Required flag
param
value1 the first byte in the value field
param
value2 the buffer containing the rest of the TLV field
param
value2Offset the offset of the rest of the TLV field in the buffer
param
value2Length the value length of the rest of the TLV field to append
exception
NullPointerException if value2 is null
exception
ArrayIndexOutOfBoundsException if append would cause access of data outside array bounds.
exception
ToolkitException with the following reason codes:
  • HANDLER_OVERFLOW if the EditHandler buffer is to small to append the requested data
  • HANDLER_NOT_AVAILABLE if the handler is busy
  • BAD_INPUT_PARAMETER if value2Length is greater than 254

        byte[] APDUBuffer = ViewHandler.getAPDUBuffer();
        // prepare the data to be appended to the TLV list
        APDUBuffer[0] = tag; // set the tag
        APDUBuffer[1] = (byte)(value2Length + 1); // 1-byte element 
	                                          // so length is 1
        APDUBuffer[2] = value1; // 1-byte element
        Util.arrayCopy(value2, value2Offset, APDUBuffer, 
		       (short)3, value2Length);        
        ViewHandler.setOutBufferData((short)(value2Length+3));
    
public voidclear()
Clears the TLV list of an EditHandler and resets the current TLV selected.

exception
ToolkitException with the following reason codes:
  • HANDLER_NOT_AVAILABLE if the handler is busy