Source Code Cross Referenced for Value.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » jpda » tests » framework » jdwp » 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 » Apache Harmony Java SE » org package » org.apache.harmony.jpda.tests.framework.jdwp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *
015:         *  See the License for the specific language governing permissions and
016:         *  limitations under the License.
017:         */
018:
019:        /**
020:         * @author Aleksey V. Yantsen
021:         * @version $Revision: 1.4 $
022:         */
023:
024:        /**
025:         * Created on 10.25.2004
026:         */package org.apache.harmony.jpda.tests.framework.jdwp;
027:
028:        import org.apache.harmony.jpda.tests.framework.TestErrorException;
029:        import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
030:
031:        /**
032:         * This class represents generic value used in JDWP packets.
033:         */
034:        public class Value {
035:
036:            private byte tag;
037:
038:            private Number numberValue;
039:
040:            private boolean booleanValue;
041:
042:            private char charValue;
043:
044:            /**
045:             * Creates new value with no tag.
046:             */
047:            public Value() {
048:                tag = JDWPConstants.Tag.NO_TAG;
049:            }
050:
051:            /**
052:             * Creates new ID value with specified tag.
053:             */
054:            public Value(byte tag, long value) {
055:                this .tag = tag;
056:                this .numberValue = new Long(value);
057:            }
058:
059:            /**
060:             * Creates new byte value.
061:             */
062:            public Value(byte value) {
063:                this .tag = JDWPConstants.Tag.BYTE_TAG;
064:                this .numberValue = new Byte(value);
065:            }
066:
067:            /**
068:             * Creates new short value.
069:             */
070:            public Value(short value) {
071:                this .tag = JDWPConstants.Tag.SHORT_TAG;
072:                this .numberValue = new Short(value);
073:            }
074:
075:            /**
076:             * Creates new int value.
077:             */
078:            public Value(int value) {
079:                this .tag = JDWPConstants.Tag.INT_TAG;
080:                this .numberValue = new Integer(value);
081:            }
082:
083:            /**
084:             * Creates new long value.
085:             */
086:            public Value(long value) {
087:                this .tag = JDWPConstants.Tag.LONG_TAG;
088:                this .numberValue = new Long(value);
089:            }
090:
091:            /**
092:             * Creates new short value.
093:             */
094:            public Value(float value) {
095:                this .tag = JDWPConstants.Tag.FLOAT_TAG;
096:                this .numberValue = new Float(value);
097:            }
098:
099:            /**
100:             * Creates new double value.
101:             */
102:            public Value(double value) {
103:                this .tag = JDWPConstants.Tag.DOUBLE_TAG;
104:                this .numberValue = new Double(value);
105:            }
106:
107:            /**
108:             * Creates new boolean value.
109:             */
110:            public Value(boolean value) {
111:                this .tag = JDWPConstants.Tag.BOOLEAN_TAG;
112:                this .booleanValue = value;
113:            }
114:
115:            /**
116:             * Creates new char value.
117:             */
118:            public Value(char value) {
119:                this .tag = JDWPConstants.Tag.CHAR_TAG;
120:                this .charValue = value;
121:            }
122:
123:            /**
124:             * Returns tag of this value.
125:             * 
126:             * @return Returns the tag.
127:             */
128:            public byte getTag() {
129:                return tag;
130:            }
131:
132:            /**
133:             * Returns byte representation of this value.
134:             * 
135:             * @return byte value
136:             */
137:            public byte getByteValue() {
138:                return numberValue.byteValue();
139:            }
140:
141:            /**
142:             * Returns short representation of this value.
143:             * 
144:             * @return short value
145:             */
146:            public short getShortValue() {
147:                return numberValue.shortValue();
148:            }
149:
150:            /**
151:             * Returns int representation of this value.
152:             * 
153:             * @return int value
154:             */
155:            public int getIntValue() {
156:                return numberValue.intValue();
157:            }
158:
159:            /**
160:             * Returns long representation of this value.
161:             * 
162:             * @return long value
163:             */
164:            public long getLongValue() {
165:                return numberValue.longValue();
166:            }
167:
168:            /**
169:             * Returns float representation of this value.
170:             * 
171:             * @return float value
172:             */
173:            public float getFloatValue() {
174:                return numberValue.floatValue();
175:            }
176:
177:            /**
178:             * Returns double representation of this value.
179:             * 
180:             * @return double value
181:             */
182:            public double getDoubleValue() {
183:                return numberValue.doubleValue();
184:            }
185:
186:            /**
187:             * Returns boolean representation of this value.
188:             * 
189:             * @return boolean value
190:             */
191:            public boolean getBooleanValue() {
192:                return booleanValue;
193:            }
194:
195:            /**
196:             * Returns char representation of this value.
197:             * 
198:             * @return char value
199:             */
200:            public char getCharValue() {
201:                return charValue;
202:            }
203:
204:            /**
205:             * Compares with other value.
206:             */
207:            public boolean equals(Object arg0) {
208:                if (!(arg0 instanceof  Value))
209:                    return false;
210:
211:                Value value0 = (Value) arg0;
212:                if (value0.tag != value0.tag)
213:                    return false;
214:
215:                switch (tag) {
216:                case JDWPConstants.Tag.BOOLEAN_TAG:
217:                    return getBooleanValue() == value0.getBooleanValue();
218:                case JDWPConstants.Tag.BYTE_TAG:
219:                    return getByteValue() == value0.getByteValue();
220:                case JDWPConstants.Tag.CHAR_TAG:
221:                    return getCharValue() == value0.getCharValue();
222:                case JDWPConstants.Tag.DOUBLE_TAG:
223:                    if (Double.isNaN(getDoubleValue())
224:                            && (Double.isNaN(value0.getDoubleValue())))
225:                        return true;
226:                    return getDoubleValue() == value0.getDoubleValue();
227:                case JDWPConstants.Tag.FLOAT_TAG:
228:                    if (Float.isNaN(getFloatValue())
229:                            && (Float.isNaN(value0.getFloatValue())))
230:                        return true;
231:                    return getFloatValue() == value0.getFloatValue();
232:                case JDWPConstants.Tag.INT_TAG:
233:                    return getIntValue() == value0.getIntValue();
234:                case JDWPConstants.Tag.LONG_TAG:
235:                    return getLongValue() == value0.getLongValue();
236:                case JDWPConstants.Tag.SHORT_TAG:
237:                    return getShortValue() == value0.getShortValue();
238:                case JDWPConstants.Tag.STRING_TAG:
239:                case JDWPConstants.Tag.ARRAY_TAG:
240:                case JDWPConstants.Tag.CLASS_LOADER_TAG:
241:                case JDWPConstants.Tag.CLASS_OBJECT_TAG:
242:                case JDWPConstants.Tag.OBJECT_TAG:
243:                case JDWPConstants.Tag.THREAD_GROUP_TAG:
244:                case JDWPConstants.Tag.THREAD_TAG:
245:                    return getLongValue() == value0.getLongValue();
246:                }
247:
248:                throw new TestErrorException("Illegal tag value");
249:            }
250:
251:            /**
252:             * Converts this value to string representation for printing.
253:             */
254:            public String toString() {
255:
256:                switch (tag) {
257:                case JDWPConstants.Tag.BOOLEAN_TAG:
258:                    return "boolean: " + getBooleanValue();
259:                case JDWPConstants.Tag.BYTE_TAG:
260:                    return "byte: " + getByteValue();
261:                case JDWPConstants.Tag.CHAR_TAG:
262:                    return "char: " + getCharValue();
263:                case JDWPConstants.Tag.DOUBLE_TAG:
264:                    return "double: " + getDoubleValue();
265:                case JDWPConstants.Tag.FLOAT_TAG:
266:                    return "float: " + getFloatValue();
267:                case JDWPConstants.Tag.INT_TAG:
268:                    return "int: " + getIntValue();
269:                case JDWPConstants.Tag.LONG_TAG:
270:                    return "long: " + getLongValue();
271:                case JDWPConstants.Tag.SHORT_TAG:
272:                    return "short: " + getShortValue();
273:                case JDWPConstants.Tag.STRING_TAG:
274:                    return "StringID: " + getLongValue();
275:                case JDWPConstants.Tag.ARRAY_TAG:
276:                    return "ObjectID: " + getLongValue();
277:
278:                case JDWPConstants.Tag.CLASS_LOADER_TAG:
279:                    return "ClassLoaderID: " + getLongValue();
280:                case JDWPConstants.Tag.CLASS_OBJECT_TAG:
281:                    return "ClassObjectID: " + getLongValue();
282:                case JDWPConstants.Tag.OBJECT_TAG:
283:                    return "ObjectID: " + getLongValue();
284:                case JDWPConstants.Tag.THREAD_GROUP_TAG:
285:                    return "ThreadGroupID: " + getLongValue();
286:                case JDWPConstants.Tag.THREAD_TAG:
287:                    return "ThreadID: " + getLongValue();
288:                }
289:
290:                throw new TestErrorException("Illegal tag value: " + tag);
291:            }
292:        }
w_w_w___.j_a___v_a2s_._c__om__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.