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

ProactiveHandler

public final class ProactiveHandler extends EditHandler
This class is the basic class for the definition of Proactive commands . Low level methods, as init(), appendTLV()... will be used to handle generic Proactive commands (standard or future definitions...). The ProactiveHandler class is a Temporary JCRE Entry Point Object. The Toolkit applets, which need to send Proactive commands, shall call the getTheHandler() static method to get the reference of this system instance.

Example of use:


// constants definition
private static final byte MY_COMMAND = (byte)0x33;
private static final byte MY_TAG = (byte)0x45;

ProactiveHandler proHdlr; // get the system instance
proHdlr = ProactiveHandler.getTheHandler();

// build and send a new Proactive
// command
proHdlr.init(MY_COMMAND, (byte)0, DEV_ID_ME);
proHdlr.appendTLV((byte)(MY_TAG | TAG_SET_CR),
(byte)0);
short len = proHdlr.getLength(); // length should be 14 !
byte result = proHdlr.send();

private byte[] text = new byte[12]; // byte array definition
text[0] = (byte)'S'; // text, in 8-bit format, is "SAT"
text[1] = (byte)'A';
text[2] = (byte)'T';
// build and send a DisplayText command
result = proHdlr.initDisplayText((byte)0x80, DCS_8_BIT_DATA,
text, (short)0, (short)3);
result = proHdlr.send();
version
8.3.0
see
ViewHandler
see
EditHandler
see
ProactiveResponseHandler
see
ToolkitException

Fields Summary
Constructors Summary
private ProactiveHandler()
Constructor

    
Methods Summary
public static sim.toolkit.ProactiveHandlergetTheHandler()
Returns the single system instance of the ProactiveHandler class. The applet shall get the reference of the handler at its triggering, the beginning of the processToolkit method.

return
reference of the system instance
exception
ToolkitException with the following reason codes:
  • HANDLER_NOT_AVAILABLE if the handler is busy.

        return null;
    
public voidinit(byte type, byte qualifier, byte dstDevice)
Initializes the next Proactive command with Command Details and Device Identities TLV. The source device is always the SIM card. The command number is generated by the method. The Comprehension Required flags are set. After the method invocation no TLV is selected.

param
type the command type
param
qualifier the command qualifier
param
dstDevice the destination device

    
public voidinitDisplayText(byte qualifier, byte dcs, byte[] buffer, short offset, short length)
Builds a Display Text Proactive command without sending the command. The Comprehension Required flags are all set to 1. After the method invocation no TLV is selected.

Notes:

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

param
qualifier Display Text command qualifier
param
dcs data coding scheme
param
buffer reference to the text string source buffer
param
offset offset of the text string in the source buffer
param
length length of the text string in the source buffer
exception
NullPointerException if buffer is null
exception
ArrayIndexOutOfBoundsException if initDisplayText would cause access of data outside array bounds
exception
ToolkitException with the following reason codes:
  • HANDLER_OVERFLOW if the ProactiveHandler buffer is to small to put the requested data

    
public voidinitGetInkey(byte qualifier, byte dcs, byte[] buffer, short offset, short length)
Builds a Get Inkey Proactive command without sending the command. The Comprehension Required flags are all set to 1. After the method invocation no TLV is selected.

Notes:

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

param
qualifier Get Inkey command qualifier
param
dcs data coding scheme
param
buffer reference to the displayed text string source buffer
param
offset offset of the displayed text string in the source buffer
param
length length of the displayed text string in the source buffer
exception
NullPointerException if buffer is null
exception
ArrayIndexOutOfBoundsException if initGetInkey would cause access of data outside array bounds.
exception
ToolkitException with the following reason codes:
  • HANDLER_OVERFLOW if the ProactiveHandler buffer is to small to put the requested data

    
public voidinitGetInput(byte qualifier, byte dcs, byte[] buffer, short offset, short length, short minRespLength, short maxRespLength)
Initialize the building of a Get Input Proactive command. The Comprehension Required flags are all set to 1. The following command parameters (i.e. TLVs) may be appended to the command before sending it: Default Text. After the method invocation no TLV is selected.

Notes:

  • If offset or length parameter is negative an ArrayIndexOutOfBoundsException exception is thrown and no proactive command is build.
  • If offset+lengthis greater than buffer.length, the length of the buffer array an ArrayIndexOutOfBoundsException exception is thrown and no proactive command is build.

param
qualifier Get Input command qualifier
param
dcs data coding scheme
param
buffer reference to the displayed text string source buffer
param
offset offset of the displayed text string in the source buffer
param
length length of the displayed text string in the source buffer
param
minRespLength minimal length of the response text string
param
maxRespLength maximal length of the response text string
exception
NullPointerException if buffer is null
exception
ArrayIndexOutOfBoundsException if initGetInput would cause access of data outside array bounds.
exception
ToolkitException with the following reason codes:
  • HANDLER_OVERFLOW if the ProactiveHandler buffer is to small to put the requested data

    
public bytesend()
Sends the current Proactive command.

return
general result of the command (first byte of Result TLV in Terminal Response)
exception
ToolkitException with the following reason codes:
  • UNAVAILABLE_ELEMENT if the Result Simple TLV is missing.
  • OUT_OF_TLV_BOUNDARIES if the general result byte is missing in the Result Simple TLV.

        return 0;