Source Code Cross Referenced for EditHandler.java in  » 6.0-JDK-Modules » j2me » sim » toolkit » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » sim.toolkit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:        import javacard.framework.Util;
036:
037:        /**
038:         * This class is the basic class for the construction of a list of simple TLV 
039:         * elements.
040:         * This class is able to handle Simple TLV with a value field no longer than
041:         * 255 bytes.
042:         *
043:         * @version 8.3.0
044:         *
045:         * @see ViewHandler
046:         * @see ProactiveHandler
047:         * @see EnvelopeResponseHandler
048:         * @see ToolkitException
049:         */
050:        public abstract class EditHandler extends ViewHandler {
051:
052:            /**
053:             * Default constructor.
054:             */
055:            EditHandler() {
056:            }
057:
058:            // ------------------------------- Constructors ---------------------------
059:            /**
060:             * Builds a new EditHandler object.
061:             *
062:             * @param buffer the buffer containg the TLV list
063:             * @param offset the position of the TLV list
064:             * @param length the length of the TLV list
065:             *
066:             * @exception NullPointerException if <code>buffer</code> 
067:             * is <code>null</code>
068:             * @exception ArrayIndexOutOfBoundsException if <code>offset</code> or 
069:             * <code>length</code> or both would cause access outside array bounds
070:             */
071:            EditHandler(byte[] buffer, short offset, short length)
072:                    throws NullPointerException, ArrayIndexOutOfBoundsException {
073:            }
074:
075:            // ------------------------------- Public methods -------------------------
076:            /**
077:             * Clears the TLV list of an EditHandler and resets the current 
078:             * TLV selected.
079:             *
080:             * @exception ToolkitException with the following reason codes: <ul>
081:             *      <li><code>HANDLER_NOT_AVAILABLE</code> if the handler is busy</ul>
082:             */
083:            public void clear() throws ToolkitException {
084:            }
085:
086:            /**
087:             * Appends a buffer into the EditHandler buffer.
088:             * A successful append does not modify the TLV selected.
089:             * The TLV list structure of the handler should be maintained by the 
090:             * applet in the appended array (e.g. the length of the TLV element 
091:             * should be coded according to ISO 7816-6), if the TLV manipulation 
092:             * methods are to be used afterwards with the handler.
093:             *
094:             * <p>
095:             * Notes:<ul>
096:             * <li><em>If </em><code>offset</code><em> or 
097:             * </em><code>length</code><em> parameter is negative an 
098:             * </em><code>ArrayIndexOutOfBoundsException</code>
099:             * <em> exception is thrown and no append is performed.</em>
100:             * <li><em>If </em><code>offset+length</code><em> is greater than 
101:             * </em><code>buffer.length</code><em>, the length of the 
102:             * </em><code>buffer</code><em> array an 
103:             * </em><code>ArrayIndexOutOfBoundsException</code><em> exception is 
104:             * thrown and no append is performed.</em> 
105:             * </ul> 
106:             *
107:             * @param buffer the buffer containing data for copy
108:             * @param offset the offset in the buffer
109:             * @param length the value length of the buffer
110:             *
111:             * @exception NullPointerException if <code>buffer</code> 
112:             * is <code>null</code>
113:             * @exception ArrayIndexOutOfBoundsException if append would cause 
114:             * access of data outside array bounds
115:             * @exception ToolkitException with the following reason codes: <ul>
116:             *      <li><code>HANDLER_OVERFLOW</code> if the EditHandler buffer 
117:             *      is to small to append the requested data
118:             *      <li><code>HANDLER_NOT_AVAILABLE</code> if the handler is busy</ul>
119:             */
120:            public void appendArray(byte[] buffer, short offset, short length)
121:                    throws NullPointerException,
122:                    ArrayIndexOutOfBoundsException, ToolkitException {
123:                byte[] APDUBuffer = ViewHandler.getAPDUBuffer();
124:                Util.arrayCopy(buffer, offset, APDUBuffer, (short) 0, length);
125:                ViewHandler.setOutBufferData(length);
126:            }
127:
128:            /**
129:             * Appends a TLV element to the current TLV list (byte array format).
130:             * A successful append does not modify the TLV selected.
131:             *
132:             * <p>
133:             * Notes:<ul>
134:             * <li><em>If </em><code>valueOffset</code><em> or 
135:             * </em><code>valueLength</code><em> parameter is negative an 
136:             * </em><code>ArrayIndexOutOfBoundsException</code>
137:             * <em> exception is thrown and no append is performed.</em>
138:             * <li><em>If </em><code>valueOffset+valueLength</code><em> is 
139:             * greater than </em><code>value.length</code><em>, the length
140:             * of the </em><code>value</code><em> array an 
141:             * </em><code>ArrayIndexOutOfBoundsException</code><em> exception 
142:             * is thrown and no append is performed.</em> 
143:             * </ul>
144:             *
145:             * @param tag the tag of the TLV to append, including the Comprehension
146:             * Required flag
147:             * @param value the buffer containing the TLV value
148:             * @param valueOffset the offset of the TLV value in the buffer
149:             * @param valueLength the value length of the TLV to append
150:             *
151:             * @exception NullPointerException if <code>value</code> 
152:             * is <code>null</code>
153:             * @exception ArrayIndexOutOfBoundsException if append would cause 
154:             * access of data outside array bounds
155:             * @exception ToolkitException with the following reason codes: <ul>
156:             *      <li><code>HANDLER_OVERFLOW</code> if the EditHandler buffer 
157:             *           is to small to append the requested data
158:             *      <li><code>HANDLER_NOT_AVAILABLE</code> if the handler is busy
159:             *      <li><code>BAD_INPUT_PARAMETER</code> if <code>valueLength</code> 
160:             *          is greater than 255</ul>
161:             */
162:            public void appendTLV(byte tag, byte[] value, short valueOffset,
163:                    short valueLength) throws NullPointerException,
164:                    ArrayIndexOutOfBoundsException, ToolkitException {
165:                byte[] APDUBuffer = ViewHandler.getAPDUBuffer();
166:                // prepare the data to be appended to the TLV list
167:                APDUBuffer[0] = tag;
168:                APDUBuffer[1] = (byte) valueLength;
169:                Util.arrayCopy(value, valueOffset, APDUBuffer, (short) 2,
170:                        valueLength);
171:                ViewHandler.setOutBufferData((short) (valueLength + 2));
172:            }
173:
174:            /**
175:             * Appends a TLV element to the current TLV list (1-byte element).
176:             * This method is useful to add single byte elements as Item Identifier
177:             * or Tone.
178:             * A successful append does not modify the TLV selected.
179:             *
180:             * @param tag the tag of the TLV to append, including the Comprehension 
181:             * Required flag
182:             * @param value the TLV value on 1 byte
183:             *
184:             * @exception ToolkitException with the following reason codes: <ul>
185:             *      <li><code>HANDLER_OVERFLOW</code> if the EditHandler buffer 
186:             *          is to small to append the requested data
187:             *      <li><code>HANDLER_NOT_AVAILABLE</code> if the handler is busy</ul>
188:             */
189:            public void appendTLV(byte tag, byte value) throws ToolkitException {
190:                byte[] APDUBuffer = ViewHandler.getAPDUBuffer();
191:                // prepare the data to be appended to the TLV list
192:                APDUBuffer[0] = tag; // set the tag
193:                APDUBuffer[1] = (byte) 1; // 1-byte element so length is 1
194:                APDUBuffer[2] = value; // 1-byte element
195:                ViewHandler.setOutBufferData((short) 3);
196:            }
197:
198:            /**
199:             * Appends a TLV element to the current TLV list (2-byte element)
200:             * This method is useful to add double byte elements as Device Identities,
201:             * Duration or Response Length. A successful append does not modify the 
202:             * TLV selected.
203:             *
204:             *
205:             * @param tag the tag of the TLV to append, including the Comprehension 
206:             * Required flag
207:             * @param value1 the 1st byte (msb) of the TLV value
208:             * @param value2 the 2nd byte (lsb) of the TLV value
209:             *
210:             * @exception ToolkitException with the following reason codes: <ul>
211:             *      <li><code>HANDLER_OVERFLOW</code> if the EditHandler buffer 
212:             *      is to small to append the requested data
213:             *      <li><code>HANDLER_NOT_AVAILABLE</code> if the handler is busy</ul>
214:             */
215:            public void appendTLV(byte tag, byte value1, byte value2)
216:                    throws ToolkitException {
217:                byte[] APDUBuffer = ViewHandler.getAPDUBuffer();
218:                // prepare the data to be appended to the TLV list
219:                APDUBuffer[0] = tag; // set the tag
220:                APDUBuffer[1] = (byte) 1; // 2-byte element so length is 1
221:                APDUBuffer[2] = value1; // 1-byte element
222:                APDUBuffer[3] = value2; // 1-byte element
223:                ViewHandler.setOutBufferData((short) 4);
224:            }
225:
226:            /**
227:             * Appends a TLV element to the current TLV list (1 byte and a 
228:             * byte array format).
229:             * A successful append does not modify the TLV selected.
230:             *
231:             * <p>
232:             * Notes:<ul>
233:             * <li><em>If </em><code>value2Offset</code><em> or 
234:             * </em><code>value2Length</code><em> parameter is negative 
235:             * an </em><code>ArrayIndexOutOfBoundsException</code><em> 
236:             * exception is thrown and no append is performed.</em>
237:             * <li><em>If </em><code>value2Offset+value2Length</code><em> is greater 
238:             * than </em><code>value2.length</code><em>, the length
239:             * of the </em><code>value2</code><em> array an 
240:             * </em><code>ArrayIndexOutOfBoundsException</code><em> exception is thrown
241:             * and no append is performed.</em> 
242:             * </ul>
243:             *
244:             * @param tag the tag of the TLV to append, including the 
245:             * Comprehension Required flag
246:             * @param value1 the first byte in the value field
247:             * @param value2 the buffer containing the rest of the TLV field
248:             * @param value2Offset the offset of the rest of the TLV field in the buffer
249:             * @param value2Length the value length of the rest of the TLV
250:             * field to append
251:             *
252:             * @exception NullPointerException if <code>value2</code> is 
253:             * <code>null</code>
254:             * @exception ArrayIndexOutOfBoundsException if append would 
255:             * cause access of data outside array bounds.
256:             * @exception ToolkitException with the following reason codes: <ul>
257:             *      <li><code>HANDLER_OVERFLOW</code> if the EditHandler buffer is to 
258:             *      small to append the requested data
259:             *      <li><code>HANDLER_NOT_AVAILABLE</code> if the handler is busy
260:             *      <li><code>BAD_INPUT_PARAMETER</code> if <code>value2Length</code> 
261:             *      is greater than 254</ul> */
262:            public void appendTLV(byte tag, byte value1, byte[] value2,
263:                    short value2Offset, short value2Length)
264:                    throws NullPointerException,
265:                    ArrayIndexOutOfBoundsException, ToolkitException {
266:                byte[] APDUBuffer = ViewHandler.getAPDUBuffer();
267:                // prepare the data to be appended to the TLV list
268:                APDUBuffer[0] = tag; // set the tag
269:                APDUBuffer[1] = (byte) (value2Length + 1); // 1-byte element 
270:                // so length is 1
271:                APDUBuffer[2] = value1; // 1-byte element
272:                Util.arrayCopy(value2, value2Offset, APDUBuffer, (short) 3,
273:                        value2Length);
274:                ViewHandler.setOutBufferData((short) (value2Length + 3));
275:            }
276:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.