Source Code Cross Referenced for TLP224Message.java in  » 6.0-JDK-Modules » j2me » com » sun » io » j2me » apdu » 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 » com.sun.io.j2me.apdu 
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:        package com.sun.io.j2me.apdu;
028:
029:        /**
030:         * The TLP224Message class represents the link level message between a CAD
031:         * (Card Acceptance Device) and a Terminal. All messages exchanged between 
032:         * the CAD and the Terminal are encoded using the TLP224 protocol. 
033:         * TLP224Messages are used internally to maintain context on the server 
034:         * side and to send commands to and from the client.
035:         */
036:        class TLP224Message extends Exception {
037:
038:            /**
039:             * This field contains the EOT code which is always sent as the last 
040:             * octet of any TLP224 message.
041:             */
042:            static final byte EOT = 0x03;
043:
044:            /**
045:             * This field contains the ACK code which is returned to the sender as 
046:             * the first octet of a TLP224 response when a message has been 
047:             * successfully received.
048:             */
049:            static final byte ACK = 0x60;
050:
051:            /**
052:             * This field contains the NACK code which is returned to the sender as 
053:             * the first octet of a TLP224 response when a transmission error occurs.
054:             */
055:            static final byte NACK = (byte) 0xe0;
056:
057:            /**
058:             * This field contains the TLP224 command to power up the CAD.
059:             */
060:            static final byte POWER_UP = 0x6e;
061:
062:            /**
063:             * This field contains the TLP224 command to send data to the card.
064:             */
065:            static final byte ISO_INPUT = (byte) 0xda;
066:
067:            /**
068:             * This field contains the TLP224 command to read data from the card.
069:             */
070:            static final byte ISO_OUTPUT = (byte) 0xdb;
071:
072:            /**
073:             * This status code is returned by both the Client and Server CAD's when
074:             * a command has been successfully executed.
075:             */
076:            static final byte STATUS_SUCCESS = 0;
077:
078:            /**
079:             * This status code is returned by both the Client and Server CAD's when 
080:             * the first byte of a received message is neither an ACK or NACK.
081:             */
082:            static final byte STATUS_PROTOCOL_ERROR = 0x09;
083:
084:            /**
085:             * This status code is returned by both the Client and Server CAD's 
086:             * when a received message exceeds the length of the internal buffers.
087:             */
088:            static final byte STATUS_MESSAGE_TOO_LONG = 0x12;
089:
090:            /**
091:             * This status code is returned by the reader or ServerCad if the card
092:             * sends a Procedure Byte which aborts a ISO_IN or ISO_OUT command.
093:             */
094:            static final byte STATUS_INTERRUPTED_EXCHANGE = (byte) 0xe5;
095:
096:            /**
097:             * This status code is returned by the reader or ServerCad
098:             * if SW1 SW2 are not equal to 0x9000.
099:             */
100:            static final byte STATUS_CARD_ERROR = (byte) 0xe7;
101:
102:            /**
103:             * This status code is returned by the reader or ServerCad if the card was
104:             * removed between exchanges.
105:             */
106:            static final byte STATUS_CARD_REMOVED = (byte) 0xf7;
107:
108:            /**
109:             * This status code is returned by the reader or ServerCad if there is
110:             * no card in the reader.
111:             */
112:            static final byte STATUS_CARD_MISSING = (byte) 0xfb;
113:
114:            /**
115:             * This field contains the size of the largest possible TLP224 Message.
116:             * This message would be <ACK><LEN><255 bytes of 
117:             * command><LRC>
118:             */
119:            private static final int MAX_MESSAGE_LEN = 264;
120:
121:            /**
122:             * Local buffer for this TLP224 message.
123:             */
124:            private byte[] buf;
125:
126:            /**
127:             * Current length of data in local buffer.
128:             */
129:            private int len;
130:
131:            /**
132:             * Construct a new TLP224Message using the default (MAX_MESSAGE_LEN) 
133:             * message size.
134:             */
135:            TLP224Message() {
136:                this .buf = new byte[MAX_MESSAGE_LEN];
137:                this .len = 0;
138:            }
139:
140:            /**
141:             * Retrieves the contents of this TLP224Message.
142:             * @return The non-null byte array containing the data to be sent or 
143:             * received. Any changes
144:             * to this byte array also affect the TLP224Message from which it came.
145:             */
146:            byte[] getData() {
147:                return buf;
148:            }
149:
150:            /**
151:             * Retrieves the length of this TLP224Message.
152:             * @return The length in bytes of the internal buffer as previously set 
153:             * by setLength().
154:             */
155:            int getLength() {
156:                return len;
157:            }
158:
159:            /**
160:             * Set the length of the data in this TLP224Message.
161:             * The length must be less than or equal to the length of the internal 
162:             * buffer.
163:             * @param newLen The length to set.
164:             * @exception IllegalArgumentException if newLen is greater than the 
165:             * length of the internal buffer.
166:             */
167:            void setLength(int newLen) {
168:                this .len = newLen;
169:            }
170:
171:            /**
172:             * Compute the TLP224 LRC of this object.
173:             * The TLP224 LRC is the exclusive-or of all the bytes in the message.
174:             * @param length The number of bytes to compute the LRC over.
175:             * @return The computed LRC.
176:             */
177:            byte computeLRC(int length) {
178:                int lrc = 0;
179:                for (int i = 0; i < length; i++)
180:                    lrc ^= buf[i];
181:                return (byte) lrc;
182:            }
183:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.