Source Code Cross Referenced for MDStaticUtils.java in  » Testing » PolePosition-0.20 » com » versant » core » metadata » 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 » Testing » PolePosition 0.20 » com.versant.core.metadata 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998 - 2005 Versant Corporation
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:         * Versant Corporation - initial API and implementation
010:         */
011:        package com.versant.core.metadata;
012:
013:        import com.versant.core.util.IntObjectHashMap;
014:
015:        import java.math.BigDecimal;
016:        import java.math.BigInteger;
017:        import java.util.*;
018:
019:        /**
020:         * Static utility methods to convert statics to and from Strings.
021:         */
022:        public class MDStaticUtils implements  MDStatics {
023:
024:            public static final int[] primToNumberMapping = new int[] { -1,
025:                    BOOLEANW, BYTEW, SHORTW, INTW, LONGW, FLOATW, DOUBLEW,
026:                    CHAR, BOOLEANW, BYTEW, SHORTW, INTW, LONGW, FLOATW,
027:                    DOUBLEW, CHARW, STRING, BIGDECIMAL, BIGINTEGER, DATE,
028:                    LOCALE, };
029:
030:            protected static final Map TYPE_MAP = new HashMap();
031:            protected static final Map TYPE_CODE_MAP = new HashMap();
032:            private static final IntObjectHashMap CODE_TYPE_MAP = new IntObjectHashMap();
033:            private static final Map TYPE_NAME_MAP = new HashMap();
034:
035:            private static void put(String name, Class t, int code) {
036:                TYPE_MAP.put(name, t);
037:                TYPE_NAME_MAP.put(t, name);
038:                TYPE_CODE_MAP.put(t, new Integer(code));
039:                CODE_TYPE_MAP.put(code, name);
040:            }
041:
042:            private static void put(String name, String name2, Class t, int code) {
043:                TYPE_MAP.put(name2, t);
044:                put(name, t, code);
045:            }
046:
047:            static {
048:                put("boolean", Boolean.TYPE, BOOLEAN);
049:                put("Boolean", "java.lang.Boolean", Boolean.class, BOOLEANW);
050:                put("byte", Byte.TYPE, BYTE);
051:                put("Byte", "java.lang.Byte", Byte.class, BYTEW);
052:                put("short", Short.TYPE, SHORT);
053:                put("Short", "java.lang.Short", Short.class, SHORTW);
054:                put("int", Integer.TYPE, INT);
055:                put("Integer", "java.lang.Integer", Integer.class, INTW);
056:                put("long", Long.TYPE, LONG);
057:                put("Long", "java.lang.Long", Long.class, LONGW);
058:                put("float", Float.TYPE, FLOAT);
059:                put("Float", "java.lang.Float", Float.class, FLOATW);
060:                put("double", Double.TYPE, DOUBLE);
061:                put("Double", "java.lang.Double", Double.class, DOUBLEW);
062:                put("char", Character.TYPE, CHAR);
063:                put("Character", "java.lang.Character", Character.class, CHARW);
064:
065:                put("String", "java.lang.String", String.class, STRING);
066:                put("BigDecimal", "java.math.BigDecimal", BigDecimal.class,
067:                        BIGDECIMAL);
068:                put("BigInteger", "java.math.BigInteger", BigInteger.class,
069:                        BIGINTEGER);
070:                put("Date", "java.util.Date", Date.class, DATE);
071:                put("Locale", "java.util.Locale", Locale.class, LOCALE);
072:
073:                //Collections
074:                put("Collection", "java.util.Collection",
075:                        java.util.Collection.class, COLLECTION);
076:                put("List", "java.util.List", java.util.List.class, LIST);
077:                put("ArrayList", "java.util.ArrayList",
078:                        java.util.ArrayList.class, ARRAYLIST);
079:                put("LinkedList", "java.util.LinkedList",
080:                        java.util.LinkedList.class, LINKEDLIST);
081:                put("Vector", "java.util.Vector", java.util.Vector.class,
082:                        VECTOR);
083:
084:                put("Set", "java.util.Set", java.util.Set.class, SET);
085:                put("HashSet", "java.util.HashSet", java.util.HashSet.class,
086:                        HASHSET);
087:                put("TreeSet", "java.util.TreeSet", java.util.TreeSet.class,
088:                        TREESET);
089:                put("SortedSet", "java.util.SortedSet",
090:                        java.util.SortedSet.class, SORTEDSET);
091:
092:                //Maps
093:                put("Map", "java.util.Map", java.util.Map.class, MAP);
094:                put("HashMap", "java.util.HashMap", java.util.HashMap.class,
095:                        HASHMAP);
096:                put("TreeMap", "java.util.TreeMap", java.util.TreeMap.class,
097:                        TREEMAP);
098:                put("SortedMap", "java.util.SortedMap",
099:                        java.util.SortedMap.class, SORTEDMAP);
100:                put("Hashtable", "java.util.Hashtable",
101:                        java.util.Hashtable.class, HASHTABLE);
102:            }
103:
104:            protected MDStaticUtils() {
105:            }
106:
107:            /**
108:             * Convert the name of a simple class (int, Integer, String etc.) into
109:             * its Class object or null if not found.
110:             */
111:            public static final Class toSimpleClass(String name) {
112:                return (Class) TYPE_MAP.get(name);
113:            }
114:
115:            /**
116:             * Convert a simple class (Integer.TYPE, Integer.class, String.class etc.)
117:             * into a type code (INT, INTW, STRING etc.) or less than 0 if not found.
118:             */
119:            public static final int toTypeCode(Class cls) {
120:
121:                Integer i = (Integer) TYPE_CODE_MAP.get(cls);
122:                return i == null ? -1 : i.intValue();
123:            }
124:
125:            public static String toSimpleName(Class cls) {
126:                return (String) TYPE_NAME_MAP.get(cls);
127:            }
128:
129:            /**
130:             * Return the simple name for a type code.
131:             *
132:             * @param code
133:             * @return
134:             */
135:            public static String toSimpleName(int code) {
136:                String name = (String) CODE_TYPE_MAP.get(code);
137:                return name;
138:            }
139:
140:            public static String toTriStateString(int t) {
141:                switch (t) {
142:                case NOT_SET:
143:                    return "notset";
144:                case TRUE:
145:                    return "true";
146:                case FALSE:
147:                    return "false";
148:                }
149:                return "unknown(" + t + ")";
150:            }
151:
152:            public static String toIdentityTypeString(int identityType) {
153:                switch (identityType) {
154:                case IDENTITY_TYPE_APPLICATION:
155:                    return "application";
156:                case IDENTITY_TYPE_DATASTORE:
157:                    return "datastore";
158:                case IDENTITY_TYPE_NONDURABLE:
159:                    return "none";
160:                }
161:                return "unknown(" + identityType + ")";
162:            }
163:
164:            public static String toPersistenceModifierString(int pm) {
165:                switch (pm) {
166:                case PERSISTENCE_MODIFIER_PERSISTENT:
167:                    return "persistent";
168:                case PERSISTENCE_MODIFIER_TRANSACTIONAL:
169:                    return "transactional";
170:                case PERSISTENCE_MODIFIER_NONE:
171:                    return "none";
172:                case NOT_SET:
173:                    return "";
174:                }
175:                return "unknown(" + pm + ")";
176:            }
177:
178:            public static String toNullValueString(int nullValue) {
179:                switch (nullValue) {
180:                case NULL_VALUE_EXCEPTION:
181:                    return "exception";
182:                case NULL_VALUE_DEFAULT:
183:                    return "default";
184:                case NULL_VALUE_NONE:
185:                    return "none";
186:                }
187:                return "unknown(" + nullValue + ")";
188:            }
189:
190:            public static String toCategoryString(int category) {
191:                switch (category) {
192:                case CATEGORY_SIMPLE:
193:                    return "Simple";
194:                case CATEGORY_REF:
195:                    return "Ref";
196:                case CATEGORY_POLYREF:
197:                    return "PolyRef";
198:                case CATEGORY_COLLECTION:
199:                    return "Collection";
200:                case CATEGORY_ARRAY:
201:                    return "Array";
202:                case CATEGORY_MAP:
203:                    return "Map";
204:                case CATEGORY_TRANSACTIONAL:
205:                    return "Transactional";
206:                case CATEGORY_NONE:
207:                    return "None";
208:                case CATEGORY_DATASTORE_PK:
209:                    return "Datastore Pk";
210:                case CATEGORY_OPT_LOCKING:
211:                    return "Opt Locking";
212:                case CATEGORY_CLASS_ID:
213:                    return "Class Id";
214:                case CATEGORY_EXTERNALIZED:
215:                    return "Externalized";
216:                }
217:                return "unknown(" + category + ")";
218:            }
219:
220:            public static String toAutoSetString(int autoSet) {
221:                switch (autoSet) {
222:                case AUTOSET_NO:
223:                    return "NONE";
224:                case AUTOSET_CREATED:
225:                    return "CREATED";
226:                case AUTOSET_MODIFIED:
227:                    return "MODIFIED";
228:                case AUTOSET_BOTH:
229:                    return "BOTH";
230:                }
231:                return "unknown(" + autoSet + ")";
232:            }
233:
234:            public static String toCacheString(int cache) {
235:                switch (cache) {
236:                case CACHE_STRATEGY_NO:
237:                    return "no";
238:                case CACHE_STRATEGY_YES:
239:                    return "yes";
240:                case CACHE_STRATEGY_ALL:
241:                    return "all";
242:                }
243:                return "unknown(" + cache + ")";
244:            }
245:
246:            public static final boolean isIntegerType(int type) {
247:                return isSignedIntegerType(type)
248:
249:                ;
250:            }
251:
252:            public static final boolean isSignedIntegerType(int type) {
253:                if ((type >= BOOLEAN && type <= LONGW) || type == CHARW) {
254:                    return true;
255:                } else {
256:                    return false;
257:                }
258:            }
259:
260:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.