Source Code Cross Referenced for LiteralValues.java in  » Net » Terracotta » com » tc » object » 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 » Net » Terracotta » com.tc.object 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003:         * notice. All rights reserved.
004:         */
005:        package com.tc.object;
006:
007:        import com.tc.util.Assert;
008:        import com.tc.util.ClassUtils;
009:
010:        import java.math.BigDecimal;
011:        import java.math.BigInteger;
012:        import java.util.Collections;
013:        import java.util.Currency;
014:        import java.util.HashMap;
015:        import java.util.Map;
016:
017:        /**
018:         * Responsible for handling literal values
019:         */
020:        public class LiteralValues {
021:
022:            public final static String ENUM_CLASS_DOTS = "java.lang.Enum";
023:
024:            /*********************************************************************************************************************
025:             * NOTE:: READ THIS IF YOU ARE ADDING NEW TYPES TO THIS FILE. XXX:: If you are adding more types, please see
026:             * PhysicalStateClassLoader and DNAEncoding. You need to be adding New code in both those classes or else some things
027:             * will be broken.
028:             ********************************************************************************************************************/
029:            public final static int INTEGER = 0;
030:            public final static int LONG = 1;
031:            public final static int CHARACTER = 2;
032:            public final static int FLOAT = 3;
033:            public final static int DOUBLE = 4;
034:            public final static int BYTE = 5;
035:            public final static int STRING = 6;
036:            public final static int BOOLEAN = 7;
037:            public final static int SHORT = 8;
038:            public final static int ARRAY = 9;
039:            public final static int OBJECT = 10;
040:            public final static int OBJECT_ID = 11;
041:            public final static int STRING_BYTES = 12;
042:            public final static int JAVA_LANG_CLASS = 13;
043:            public final static int JAVA_LANG_CLASS_HOLDER = 14;
044:            public final static int STACK_TRACE_ELEMENT = 15;
045:            public final static int BIG_INTEGER = 16;
046:            public final static int BIG_DECIMAL = 17;
047:            public final static int JAVA_LANG_CLASSLOADER = 18;
048:            public final static int JAVA_LANG_CLASSLOADER_HOLDER = 19;
049:            public final static int ENUM = 20;
050:            public final static int ENUM_HOLDER = 21;
051:            public final static int CURRENCY = 22;
052:
053:            private final Map values;
054:
055:            public LiteralValues() {
056:                super ();
057:
058:                Map tmp = new HashMap();
059:
060:                addMapping(tmp, Integer.class.getName(), INTEGER);
061:                addMapping(tmp, int.class.getName(), INTEGER);
062:                addMapping(tmp, Long.class.getName(), LONG);
063:                addMapping(tmp, long.class.getName(), LONG);
064:                addMapping(tmp, Character.class.getName(), CHARACTER);
065:                addMapping(tmp, char.class.getName(), CHARACTER);
066:                addMapping(tmp, Float.class.getName(), FLOAT);
067:                addMapping(tmp, float.class.getName(), FLOAT);
068:                addMapping(tmp, Double.class.getName(), DOUBLE);
069:                addMapping(tmp, double.class.getName(), DOUBLE);
070:                addMapping(tmp, Byte.class.getName(), BYTE);
071:                addMapping(tmp, byte.class.getName(), BYTE);
072:                addMapping(tmp, String.class.getName(), STRING);
073:
074:                addMapping(tmp, "com.tc.object.dna.impl.UTF8ByteDataHolder",
075:                        STRING_BYTES);
076:
077:                addMapping(tmp, Short.class.getName(), SHORT);
078:                addMapping(tmp, short.class.getName(), SHORT);
079:                addMapping(tmp, Boolean.class.getName(), BOOLEAN);
080:                addMapping(tmp, boolean.class.getName(), BOOLEAN);
081:
082:                addMapping(tmp, BigInteger.class.getName(), BIG_INTEGER);
083:                addMapping(tmp, BigDecimal.class.getName(), BIG_DECIMAL);
084:
085:                addMapping(tmp, java.lang.Class.class.getName(),
086:                        JAVA_LANG_CLASS);
087:
088:                addMapping(tmp, "com.tc.object.dna.impl.ClassInstance",
089:                        JAVA_LANG_CLASS_HOLDER);
090:
091:                addMapping(tmp, ObjectID.class.getName(), OBJECT_ID);
092:                addMapping(tmp, StackTraceElement.class.getName(),
093:                        STACK_TRACE_ELEMENT);
094:
095:                addMapping(tmp, "com.tc.object.dna.impl.ClassLoaderInstance",
096:                        JAVA_LANG_CLASSLOADER_HOLDER);
097:
098:                addMapping(tmp, ENUM_CLASS_DOTS, ENUM);
099:
100:                addMapping(tmp, "com.tc.object.dna.impl.EnumInstance",
101:                        ENUM_HOLDER);
102:
103:                addMapping(tmp, Currency.class.getName(), CURRENCY);
104:
105:                values = Collections.unmodifiableMap(tmp);
106:            }
107:
108:            /**
109:             * Determine LiteralValue code for an instance object
110:             * @param pojo Object instance, should never be null
111:             * @return Literal value code for the pojo's class
112:             */
113:            public int valueFor(Object pojo) {
114:                if (pojo instanceof  ClassLoader) {
115:                    return JAVA_LANG_CLASSLOADER;
116:                }
117:
118:                Class clazz = pojo.getClass();
119:                int i = valueForClassName(clazz.getName());
120:                if (i == OBJECT && ClassUtils.isEnum(pojo.getClass())) {
121:                    return ENUM;
122:                }
123:                return i;
124:            }
125:
126:            /**
127:             * Determine whether a class is a literal
128:             * @param className Class name
129:             * @return True if literal value class
130:             */
131:            public boolean isLiteral(String className) {
132:                int i = valueForClassName(className);
133:                return i != OBJECT && i != ARRAY;
134:            }
135:
136:            /**
137:             * Determine whether the instance is a literal
138:             * @param obj Instance object, may be null
139:             * @return True if literal value instance, false if null or not literal value instance
140:             */
141:            public boolean isLiteralInstance(Object obj) {
142:                if (obj == null) {
143:                    return false;
144:                }
145:                int i = valueFor(obj);
146:                return i != OBJECT && i != ARRAY;
147:            }
148:
149:            private static void addMapping(Map map, String className, int i) {
150:                Object prev = map.put(className, new Integer(i));
151:                Assert.assertNull(className, prev);
152:            }
153:
154:            /**
155:             * Get literal value code for class name
156:             * @param className Class name, may be null
157:             * @return Literal value marker or {@link #OBJECT} if className is null
158:             */
159:            public int valueForClassName(String className) {
160:                if ((className != null) && className.startsWith("[")) {
161:                    return ARRAY;
162:                }
163:                Integer i = (Integer) values.get(className);
164:                if (i == null)
165:                    return OBJECT;
166:                return i.intValue();
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.