Source Code Cross Referenced for ValueFactory.java in  » Development » proguard » proguard » evaluation » value » 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 » Development » proguard » proguard.evaluation.value 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ProGuard -- shrinking, optimization, obfuscation, and preverification
003:         *             of Java bytecode.
004:         *
005:         * Copyright (c) 2002-2007 Eric Lafortune (eric@graphics.cornell.edu)
006:         *
007:         * This program is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU General Public License as published by the Free
009:         * Software Foundation; either version 2 of the License, or (at your option)
010:         * any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful, but WITHOUT
013:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
014:         * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
015:         * more details.
016:         *
017:         * You should have received a copy of the GNU General Public License along
018:         * with this program; if not, write to the Free Software Foundation, Inc.,
019:         * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020:         */
021:        package proguard.evaluation.value;
022:
023:        import proguard.classfile.*;
024:        import proguard.classfile.util.ClassUtil;
025:
026:        /**
027:         * This class provides methods to create and reuse Value objects.
028:         *
029:         * @author Eric Lafortune
030:         */
031:        public class ValueFactory {
032:            // Shared copies of Value objects, to avoid creating a lot of objects.
033:            static final IntegerValue INTEGER_VALUE = new IntegerValue();
034:            static final LongValue LONG_VALUE = new LongValue();
035:            static final FloatValue FLOAT_VALUE = new FloatValue();
036:            static final DoubleValue DOUBLE_VALUE = new DoubleValue();
037:
038:            static final ReferenceValue REFERENCE_VALUE_NULL = new ReferenceValue(
039:                    null, null, true);
040:            static final ReferenceValue REFERENCE_VALUE_JAVA_LANG_OBJECT_MAYBE_NULL = new ReferenceValue(
041:                    ClassConstants.INTERNAL_NAME_JAVA_LANG_OBJECT, null, true);
042:            static final ReferenceValue REFERENCE_VALUE_JAVA_LANG_OBJECT_NOT_NULL = new ReferenceValue(
043:                    ClassConstants.INTERNAL_NAME_JAVA_LANG_OBJECT, null, false);
044:
045:            /**
046:             * Creates a new undefined Value of the given type.
047:             * The type must be a fully specified internal type for primitives, classes,
048:             * or arrays.
049:             */
050:            public Value createValue(String type, Clazz referencedClass,
051:                    boolean mayBeNull) {
052:                switch (type.charAt(0)) {
053:                case ClassConstants.INTERNAL_TYPE_VOID:
054:                    return null;
055:                case ClassConstants.INTERNAL_TYPE_BOOLEAN:
056:                case ClassConstants.INTERNAL_TYPE_BYTE:
057:                case ClassConstants.INTERNAL_TYPE_CHAR:
058:                case ClassConstants.INTERNAL_TYPE_SHORT:
059:                case ClassConstants.INTERNAL_TYPE_INT:
060:                    return INTEGER_VALUE;
061:                case ClassConstants.INTERNAL_TYPE_LONG:
062:                    return LONG_VALUE;
063:                case ClassConstants.INTERNAL_TYPE_FLOAT:
064:                    return FLOAT_VALUE;
065:                case ClassConstants.INTERNAL_TYPE_DOUBLE:
066:                    return DOUBLE_VALUE;
067:                default:
068:                    return createReferenceValue(ClassUtil
069:                            .isInternalArrayType(type) ? type : ClassUtil
070:                            .internalClassNameFromClassType(type),
071:                            referencedClass, mayBeNull);
072:                }
073:            }
074:
075:            /**
076:             * Creates a new IntegerValue with an undefined value.
077:             */
078:            public IntegerValue createIntegerValue() {
079:                return INTEGER_VALUE;
080:            }
081:
082:            /**
083:             * Creates a new IntegerValue with a given specific value.
084:             */
085:            public IntegerValue createIntegerValue(int value) {
086:                return createIntegerValue();
087:            }
088:
089:            /**
090:             * Creates a new LongValue with an undefined value.
091:             */
092:            public LongValue createLongValue() {
093:                return LONG_VALUE;
094:            }
095:
096:            /**
097:             * Creates a new LongValue with a given specific value.
098:             */
099:            public LongValue createLongValue(long value) {
100:                return createLongValue();
101:            }
102:
103:            /**
104:             * Creates a new FloatValue with an undefined value.
105:             */
106:            public FloatValue createFloatValue() {
107:                return FLOAT_VALUE;
108:            }
109:
110:            /**
111:             * Creates a new FloatValue with a given specific value.
112:             */
113:            public FloatValue createFloatValue(float value) {
114:                return createFloatValue();
115:            }
116:
117:            /**
118:             * Creates a new DoubleValue with an undefined value.
119:             */
120:            public DoubleValue createDoubleValue() {
121:                return DOUBLE_VALUE;
122:            }
123:
124:            /**
125:             * Creates a new DoubleValue with a given specific value.
126:             */
127:            public DoubleValue createDoubleValue(double value) {
128:                return createDoubleValue();
129:            }
130:
131:            /**
132:             * Creates a new ReferenceValue that represents <code>null</code>.
133:             */
134:            public ReferenceValue createReferenceValueNull() {
135:                return REFERENCE_VALUE_NULL;
136:            }
137:
138:            /**
139:             * Creates a new ReferenceValue of the given type. The type must be an
140:             * internal class name or an array type. If the type is <code>null</code>,
141:             * the ReferenceValue represents <code>null</code>.
142:             */
143:            public ReferenceValue createReferenceValue(String type,
144:                    Clazz referencedClass, boolean mayBeNull) {
145:                return type == null ? REFERENCE_VALUE_NULL
146:                        : !type
147:                                .equals(ClassConstants.INTERNAL_NAME_JAVA_LANG_OBJECT) ? new ReferenceValue(
148:                                type, referencedClass, mayBeNull)
149:                                : mayBeNull ? REFERENCE_VALUE_JAVA_LANG_OBJECT_MAYBE_NULL
150:                                        : REFERENCE_VALUE_JAVA_LANG_OBJECT_NOT_NULL;
151:            }
152:
153:            /**
154:             * Creates a new ReferenceValue for arrays of the given type and length.
155:             * The type must be a fully specified internal type for primitives, classes,
156:             * or arrays.
157:             */
158:            public ReferenceValue createArrayReferenceValue(String type,
159:                    Clazz referencedClass, IntegerValue arrayLength) {
160:                return createArrayReferenceValue(type, referencedClass,
161:                        arrayLength, createValue(type, referencedClass, false));
162:            }
163:
164:            /**
165:             * Creates a new ReferenceValue for arrays of the given type and length,
166:             * containing the given element. The type must be a fully specified internal
167:             * type for primitives, classes, or arrays.
168:             */
169:            public ReferenceValue createArrayReferenceValue(String type,
170:                    Clazz referencedClass, IntegerValue arrayLength,
171:                    Value elementValue) {
172:                return createReferenceValue(ClassConstants.INTERNAL_TYPE_ARRAY
173:                        + type, referencedClass, false);
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.