Source Code Cross Referenced for PrimitiveValueImpl.java in  » IDE-Eclipse » jdt » org » eclipse » jdi » internal » 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 » IDE Eclipse » jdt » org.eclipse.jdi.internal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2005 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         * 
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.jdi.internal;
011:
012:        import java.io.DataInputStream;
013:        import java.io.DataOutputStream;
014:        import java.io.IOException;
015:
016:        import com.sun.jdi.InternalException;
017:        import com.sun.jdi.PrimitiveType;
018:        import com.sun.jdi.PrimitiveValue;
019:
020:        /**
021:         * this class implements the corresponding interfaces
022:         * declared by the JDI specification. See the com.sun.jdi package
023:         * for more information.
024:         *
025:         */
026:        public abstract class PrimitiveValueImpl extends ValueImpl implements 
027:                PrimitiveValue, Comparable {
028:            /** Primitive value in wrapper. */
029:            Object fValue;
030:
031:            /**
032:             * Creates new ValueImpl.
033:             */
034:            public PrimitiveValueImpl(String description,
035:                    VirtualMachineImpl vmImpl, Object value) {
036:                super (description, vmImpl);
037:                fValue = value;
038:            }
039:
040:            /**
041:             * @return Returns Primitive Value converted to required type.
042:             */
043:            public boolean booleanValue() {
044:                if (fValue instanceof  Boolean)
045:                    return ((Boolean) fValue).booleanValue();
046:                else if (fValue instanceof  Character)
047:                    return ((Character) fValue).charValue() != 0;
048:                else
049:                    return ((Number) fValue).doubleValue() != 0;
050:            }
051:
052:            /**
053:             * @return Returns Primitive Value converted to required type.
054:             */
055:            public char charValue() {
056:                if (fValue instanceof  Boolean)
057:                    return ((Boolean) fValue).booleanValue() ? (char) 1
058:                            : (char) 0;
059:                else if (fValue instanceof  Character)
060:                    return ((Character) fValue).charValue();
061:                else
062:                    return (char) ((Number) fValue).intValue();
063:            }
064:
065:            /**
066:             * @return Returns Primitive Value converted to required type.
067:             */
068:            public byte byteValue() {
069:                if (fValue instanceof  Boolean)
070:                    return ((Boolean) fValue).booleanValue() ? (byte) 1
071:                            : (byte) 0;
072:                else if (fValue instanceof  Character)
073:                    return (byte) ((Character) fValue).charValue();
074:                else
075:                    return ((Number) fValue).byteValue();
076:            }
077:
078:            /**
079:             * @return Returns Primitive Value converted to required type.
080:             */
081:            public double doubleValue() {
082:                if (fValue instanceof  Boolean)
083:                    return ((Boolean) fValue).booleanValue() ? (double) 1
084:                            : (double) 0;
085:                else if (fValue instanceof  Character)
086:                    return ((Character) fValue).charValue();
087:                else
088:                    return ((Number) fValue).doubleValue();
089:            }
090:
091:            /**
092:             * @return Returns Primitive Value converted to required type.
093:             */
094:            public float floatValue() {
095:                if (fValue instanceof  Boolean)
096:                    return ((Boolean) fValue).booleanValue() ? (float) 1
097:                            : (float) 0;
098:                else if (fValue instanceof  Character)
099:                    return ((Character) fValue).charValue();
100:                else
101:                    return ((Number) fValue).floatValue();
102:            }
103:
104:            /**
105:             * @return Returns Primitive Value converted to required type.
106:             */
107:            public int intValue() {
108:                if (fValue instanceof  Boolean)
109:                    return ((Boolean) fValue).booleanValue() ? (int) 1
110:                            : (int) 0;
111:                else if (fValue instanceof  Character)
112:                    return ((Character) fValue).charValue();
113:                else
114:                    return ((Number) fValue).intValue();
115:            }
116:
117:            /**
118:             * @return Returns Primitive Value converted to required type.
119:             */
120:            public long longValue() {
121:                if (fValue instanceof  Boolean)
122:                    return ((Boolean) fValue).booleanValue() ? (long) 1
123:                            : (long) 0;
124:                else if (fValue instanceof  Character)
125:                    return ((Character) fValue).charValue();
126:                else
127:                    return ((Number) fValue).longValue();
128:            }
129:
130:            /**
131:             * @return Returns Primitive Value converted to required type.
132:             */
133:            public short shortValue() {
134:                if (fValue instanceof  Boolean)
135:                    return ((Boolean) fValue).booleanValue() ? (short) 1
136:                            : (short) 0;
137:                else if (fValue instanceof  Character)
138:                    return (short) ((Character) fValue).charValue();
139:                else
140:                    return ((Number) fValue).shortValue();
141:            }
142:
143:            /**
144:             * @return Returns true if two values are equal.
145:             * @see java.lang.Object#equals(Object)
146:             */
147:            public boolean equals(Object object) {
148:                return object != null
149:                        && object.getClass().equals(this .getClass())
150:                        && fValue.equals(((PrimitiveValueImpl) object).fValue);
151:            }
152:
153:            /**
154:             * @return Returns a has code for this object.
155:             * @see java.lang.Object#hashCode
156:             */
157:            public int hashCode() {
158:                return fValue.hashCode();
159:            }
160:
161:            /**
162:             * Compares this object with the specified object for order.
163:             * Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
164:             * 
165:             * May throw a ClassCastException if obj is not comparable. This is in accordance
166:             * with Java 1.4 compareTo(Object) methods.
167:             */
168:            public int compareTo(Object obj) {
169:                if (fValue instanceof  Character)
170:                    return ((Character) fValue).compareTo((Character) obj);
171:                else if (fValue instanceof  Byte)
172:                    return ((Byte) fValue).compareTo((Byte) obj);
173:                else if (fValue instanceof  Double)
174:                    return ((Double) fValue).compareTo((Double) obj);
175:                else if (fValue instanceof  Float)
176:                    return ((Float) fValue).compareTo((Float) obj);
177:                else if (fValue instanceof  Integer)
178:                    return ((Integer) fValue).compareTo((Integer) obj);
179:                else if (fValue instanceof  Long)
180:                    return ((Long) fValue).compareTo((Long) obj);
181:                else if (fValue instanceof  Short)
182:                    return ((Short) fValue).compareTo((Short) obj);
183:
184:                throw new InternalException(
185:                        JDIMessages.PrimitiveValueImpl_Invalid_Primitive_Value_encountered_1);
186:
187:            }
188:
189:            /**
190:             * @return Returns description of Mirror object.
191:             */
192:            public String toString() {
193:                return fValue.toString();
194:            }
195:
196:            /**
197:             * Writes value without value tag.
198:             */
199:            public abstract void write(MirrorImpl target, DataOutputStream out)
200:                    throws IOException;
201:
202:            /**
203:             * @return Reads JDWP representation and returns new instance.
204:             */
205:            public static PrimitiveValueImpl readWithoutTag(MirrorImpl target,
206:                    PrimitiveType type, DataInputStream in) throws IOException {
207:                switch (((PrimitiveTypeImpl) type).tag()) {
208:                case 0:
209:                    return null;
210:                case BooleanValueImpl.tag:
211:                    return BooleanValueImpl.read(target, in);
212:                case ByteValueImpl.tag:
213:                    return ByteValueImpl.read(target, in);
214:                case CharValueImpl.tag:
215:                    return CharValueImpl.read(target, in);
216:                case DoubleValueImpl.tag:
217:                    return DoubleValueImpl.read(target, in);
218:                case FloatValueImpl.tag:
219:                    return FloatValueImpl.read(target, in);
220:                case IntegerValueImpl.tag:
221:                    return IntegerValueImpl.read(target, in);
222:                case LongValueImpl.tag:
223:                    return LongValueImpl.read(target, in);
224:                case ShortValueImpl.tag:
225:                    return ShortValueImpl.read(target, in);
226:                }
227:                throw new InternalException(
228:                        JDIMessages.PrimitiveValueImpl_Invalid_Primitive_Value_tag_encountered___2
229:                                + type);
230:            }
231:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.