001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: //-----------------------------------------------------------------------------
028: // PACKAGE DEFINITION
029: //-----------------------------------------------------------------------------
030: package sim.toolkit;
031:
032: //-----------------------------------------------------------------------------
033: // IMPORTS
034: //-----------------------------------------------------------------------------
035:
036: /**
037: *
038: * The ProactiveResponseHandler class contains basic methods to handle the
039: * <b>Terminal
040: * Response</b> data field. This class will be used by the Toolkit applet to
041: * get the response to the Proactive commands. No constructor is available for
042: * the Toolkit applet. The ProactiveResponseHandler class is a <b>Temporary
043: * JCRE Entry Point Object</b>. The only way to get a ProactiveResponseHandler
044: * reference is through the <code>getTheHandler()</code> static method.<p>
045: *
046: * Example of use:<pre><code>
047: *
048: * private byte[] data;
049: * data = new byte[32]; // build a buffer
050: *
051: * ProactiveResponseHandler ProRespHdlr; // get the system instance
052: * ProRespHdlr = ProactiveResponseHandler.getTheHandler();
053: *
054: * // get General Result
055: * byte result = ProRespHdlr.getGeneralResult();
056: *
057: * // look for Device Identities
058: * respHdlr.findTLV(TAG_DEVICE_IDENTITIES, 1);
059: *
060: * // read Device Identities
061: * byte sourceDev = ProRespHdlr.getValueByte((short)0);
062: * byte destinDev = ProRespHdlr.getValueByte((short)1);
063: *
064: * // look for Text String element
065: * if (ProRespHdlr.findTLV(TAG_TEXT_STRING, (byte)1) == TLV_FOUND_CR_SET) {
066: * if ((short len = ProRespHdlr.getValueLength()) > 1) {
067: * // not empty string: to be copied
068: * ProRespHdlr.copyValue((short)1, data, (short)0, (short)(len - 1));
069: * }
070: * }
071: * </code></pre>
072: *
073: * @version 8.3.0
074: * @see ViewHandler
075: * @see ProactiveHandler
076: * @see ToolkitException
077: */
078: public final class ProactiveResponseHandler extends ViewHandler {
079:
080: // ------------------------------- Constructors ---------------------------
081: /**
082: * Constructor
083: */
084: private ProactiveResponseHandler() {
085: }
086:
087: // ------------------------------- Public methods -------------------------
088: /**
089: * Returns the single system instance of the
090: * ProactiveResponseHandler class. The applet shall get the
091: * reference of the handler at its triggering, the beginning of
092: * the processToolkit method.
093: *
094: * @return reference of the system instance
095: *
096: * @exception ToolkitException with the following reason codes:
097: * <ul> <li><code>HANDLER_NOT_AVAILABLE</code> if the handler
098: * is busy.</ul>
099: */
100: public static ProactiveResponseHandler getTheHandler()
101: throws ToolkitException {
102: return null;
103: }
104:
105: /**
106: * Returns the general result byte of the Proactive command.
107: * If the element is available it becomes the TLV selected.
108: *
109: * @return general result of the command (first byte of Result TLV in
110: * Terminal Response)
111: *
112: * @exception ToolkitException with the following reason codes: <ul>
113: * <li><code>UNAVAILABLE_ELEMENT</code> in case of unavailable
114: * Result TLV element
115: * <li><code>OUT_OF_TLV_BOUNDARIES</code> if the general result
116: * byte is missing in the Result Simple TLV</ul>
117: */
118: public byte getGeneralResult() throws ToolkitException {
119: return 0;
120: }
121:
122: /**
123: * Returns the length of the additional information field from the first
124: * Result TLV element of the current response data field.
125: * If the element is available it becomes the TLV selected.
126: *
127: * @return additional information length
128: *
129: * @exception ToolkitException with the following reason codes: <ul>
130: * <li><code>UNAVAILABLE_ELEMENT</code> in case of unavailable Result
131: * TLV element</ul>
132: */
133: public short getAdditionalInformationLength()
134: throws ToolkitException {
135: return 0;
136: }
137:
138: /**
139: * Copies a part of the additional information field from the first Result
140: * TLV element of the current response data field.
141: * If the element is available it becomes the TLV selected.
142: *
143: * <p>
144: * Notes:<ul>
145: * <li><em>If </em><code>dstOffset</code><em> or
146: * </em><code>dstLength</code><em> parameter is negative an
147: * </em><code>ArrayIndexOutOfBoundsException</code>
148: * <em> exception is thrown and no copy is performed.</em>
149: * <li><em>If </em><code>dstOffset+dstLength</code><em> is
150: * greater than </em><code>dstBuffer.length</code><em>, the length
151: * of the </em><code>dstBuffer</code><em> array an
152: * </em><code>ArrayIndexOutOfBoundsException</code><em> exception is thrown
153: * and no copy is performed.</em>
154: * </ul>
155: *
156: * @param dstBuffer a reference to the destination buffer
157: * @param dstOffset the position in the destination buffer
158: * @param dstLength the data length to be copied
159: *
160: * @return <code>dstOffset+dstLength</code>
161: *
162: * @exception NullPointerException if <code>dstBuffer</code> is
163: * <code>null</code>
164: * @exception ArrayIndexOutOfBoundsException if copyAdditionalInformation
165: * would cause access of data outside array bounds.
166: * @exception ToolkitException with the following reason codes: <ul>
167: * <li><code>UNAVAILABLE_ELEMENT</code> in case of unavailable
168: * Result TLV element
169: * <li><code>OUT_OF_TLV_BOUNDARIES</code> if <code>dstLength</code>
170: * is greater than the value field of the available TLV</ul>
171: */
172: public short copyAdditionalInformation(byte[] dstBuffer,
173: short dstOffset, short dstLength)
174: throws NullPointerException,
175: ArrayIndexOutOfBoundsException, ToolkitException {
176: return 0;
177: }
178:
179: /**
180: * Returns the item identifier byte value from the first Item
181: * Identifier TLV element of the current response data field.
182: * If the element is available it becomes the TLV selected.
183: *
184: * @return item identifier
185: *
186: * @exception ToolkitException with the following reason codes: <ul>
187: * <li><code>UNAVAILABLE_ELEMENT</code> in case of unavailable
188: * Item Identifier TLV element
189: * <li><code>OUT_OF_TLV_BOUNDARIES</code> if the item identifier
190: * byte is missing in the Item Identifier Simple TLV</ul>
191: */
192: public byte getItemIdentifier() throws ToolkitException {
193: return 0;
194: }
195:
196: /**
197: * Returns the text string length value from the first Text String TLV
198: * element of the current response data field. The Data Coding Scheme byte
199: * is not taken into account.
200: * If the element is available it becomes the TLV selected.
201: *
202: * @return text string length
203: *
204: * @exception ToolkitException with the following reason codes: <ul>
205: * <li><code>UNAVAILABLE_ELEMENT</code> in case of unavailable Text
206: * String TLV element</ul>
207: */
208: public short getTextStringLength() throws ToolkitException {
209: return 0;
210: }
211:
212: /**
213: * Returns the data coding scheme byte from the first Text String TLV
214: * element of the current response data field.
215: * If the element is available it becomes the TLV selected.
216: *
217: * @return text string coding scheme
218: *
219: * @exception ToolkitException with the following reason codes: <ul>
220: * <li><code>UNAVAILABLE_ELEMENT</code> in case of unavailable Text
221: * String TLV element
222: * <li><code>OUT_OF_TLV_BOUNDARIES</code> if the Text String TLV is
223: * present with a length
224: * of 0 (no DCS byte)</ul>
225: */
226: public byte getTextStringCodingScheme() throws ToolkitException {
227: return 0;
228: }
229:
230: /**
231: * Copies the text string value from the first Text String TLV element
232: * of the
233: * current response data field. The Data Coding Scheme byte is not copied.
234: * If the element is available it becomes the TLV selected.
235: *
236: * @param dstBuffer a reference to the destination buffer
237: * @param dstOffset the position in the destination buffer
238: *
239: * @return <code>dstOffset</code> + length of the copied value
240: *
241: * @exception NullPointerException if <code>dstBuffer</code> is
242: * <code>null</code>
243: * @exception ArrayIndexOutOfBoundsException if <code>dstOffset or
244: * dstOffset + (length of the TextString to be copied,
245: * without the Data Coding Scheme included)</code>, as specified for
246: * the returned value, would cause access outside array bounds.
247: * @exception ToolkitException with the following reason codes: <ul>
248: * <li><code>UNAVAILABLE_ELEMENT</code> in case of unavailable Text
249: * String TLV element</ul>
250: */
251: public short copyTextString(byte[] dstBuffer, short dstOffset)
252: throws NullPointerException,
253: ArrayIndexOutOfBoundsException, ToolkitException {
254: return 0;
255: }
256: }
|