Source Code Cross Referenced for ConstantPoolEntry.java in  » Build » ANT » org » apache » tools » ant » taskdefs » optional » depend » constantpool » 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 » Build » ANT » org.apache.tools.ant.taskdefs.optional.depend.constantpool 
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:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:        package org.apache.tools.ant.taskdefs.optional.depend.constantpool;
019:
020:        import java.io.DataInputStream;
021:        import java.io.IOException;
022:
023:        /**
024:         * An entry in the constant pool. This class contains a representation of the
025:         * constant pool entries. It is an abstract base class for all the different
026:         * forms of constant pool entry.
027:         *
028:         * @see ConstantPool
029:         */
030:        public abstract class ConstantPoolEntry {
031:
032:            /** Tag value for UTF8 entries. */
033:            public static final int CONSTANT_UTF8 = 1;
034:
035:            /** Tag value for Integer entries. */
036:            public static final int CONSTANT_INTEGER = 3;
037:
038:            /** Tag value for Float entries. */
039:            public static final int CONSTANT_FLOAT = 4;
040:
041:            /** Tag value for Long entries. */
042:            public static final int CONSTANT_LONG = 5;
043:
044:            /** Tag value for Double entries. */
045:            public static final int CONSTANT_DOUBLE = 6;
046:
047:            /** Tag value for Class entries. */
048:            public static final int CONSTANT_CLASS = 7;
049:
050:            /** Tag value for String entries. */
051:            public static final int CONSTANT_STRING = 8;
052:
053:            /** Tag value for Field Reference entries. */
054:            public static final int CONSTANT_FIELDREF = 9;
055:
056:            /** Tag value for Method Reference entries. */
057:            public static final int CONSTANT_METHODREF = 10;
058:
059:            /** Tag value for Interface Method Reference entries. */
060:            public static final int CONSTANT_INTERFACEMETHODREF = 11;
061:
062:            /** Tag value for Name and Type entries. */
063:            public static final int CONSTANT_NAMEANDTYPE = 12;
064:
065:            /**
066:             * This entry's tag which identifies the type of this constant pool
067:             * entry.
068:             */
069:            private int tag;
070:
071:            /**
072:             * The number of slots in the constant pool, occupied by this entry.
073:             */
074:            private int numEntries;
075:
076:            /**
077:             * A flag which indicates if this entry has been resolved or not.
078:             */
079:            private boolean resolved;
080:
081:            /**
082:             * Initialise the constant pool entry.
083:             *
084:             * @param tagValue the tag value which identifies which type of constant
085:             *      pool entry this is.
086:             * @param entries the number of constant pool entry slots this entry
087:             *      occupies.
088:             */
089:            public ConstantPoolEntry(int tagValue, int entries) {
090:                tag = tagValue;
091:                numEntries = entries;
092:                resolved = false;
093:            }
094:
095:            /**
096:             * Read a constant pool entry from a stream. This is a factory method
097:             * which reads a constant pool entry form a stream and returns the
098:             * appropriate subclass for the entry.
099:             *
100:             * @param cpStream the stream from which the constant pool entry is to
101:             *      be read.
102:             * @return the appropriate ConstantPoolEntry subclass representing the
103:             *      constant pool entry from the stream.
104:             * @exception IOException if the constant pool entry cannot be read
105:             *      from the stream
106:             */
107:            public static ConstantPoolEntry readEntry(DataInputStream cpStream)
108:                    throws IOException {
109:                ConstantPoolEntry cpInfo = null;
110:                int cpTag = cpStream.readUnsignedByte();
111:
112:                switch (cpTag) {
113:
114:                case CONSTANT_UTF8:
115:                    cpInfo = new Utf8CPInfo();
116:
117:                    break;
118:                case CONSTANT_INTEGER:
119:                    cpInfo = new IntegerCPInfo();
120:
121:                    break;
122:                case CONSTANT_FLOAT:
123:                    cpInfo = new FloatCPInfo();
124:
125:                    break;
126:                case CONSTANT_LONG:
127:                    cpInfo = new LongCPInfo();
128:
129:                    break;
130:                case CONSTANT_DOUBLE:
131:                    cpInfo = new DoubleCPInfo();
132:
133:                    break;
134:                case CONSTANT_CLASS:
135:                    cpInfo = new ClassCPInfo();
136:
137:                    break;
138:                case CONSTANT_STRING:
139:                    cpInfo = new StringCPInfo();
140:
141:                    break;
142:                case CONSTANT_FIELDREF:
143:                    cpInfo = new FieldRefCPInfo();
144:
145:                    break;
146:                case CONSTANT_METHODREF:
147:                    cpInfo = new MethodRefCPInfo();
148:
149:                    break;
150:                case CONSTANT_INTERFACEMETHODREF:
151:                    cpInfo = new InterfaceMethodRefCPInfo();
152:
153:                    break;
154:                case CONSTANT_NAMEANDTYPE:
155:                    cpInfo = new NameAndTypeCPInfo();
156:
157:                    break;
158:                default:
159:                    throw new ClassFormatError(
160:                            "Invalid Constant Pool entry Type " + cpTag);
161:                }
162:
163:                cpInfo.read(cpStream);
164:
165:                return cpInfo;
166:            }
167:
168:            /**
169:             * Indicates whether this entry has been resolved. In general a constant
170:             * pool entry can reference another constant pool entry by its index
171:             * value. Resolution involves replacing this index value with the
172:             * constant pool entry at that index.
173:             *
174:             * @return true if this entry has been resolved.
175:             */
176:            public boolean isResolved() {
177:                return resolved;
178:            }
179:
180:            /**
181:             * Resolve this constant pool entry with respect to its dependents in
182:             * the constant pool.
183:             *
184:             * @param constantPool the constant pool of which this entry is a member
185:             *      and against which this entry is to be resolved.
186:             */
187:            public void resolve(ConstantPool constantPool) {
188:                resolved = true;
189:            }
190:
191:            /**
192:             * read a constant pool entry from a class stream.
193:             *
194:             * @param cpStream the DataInputStream which contains the constant pool
195:             *      entry to be read.
196:             * @exception IOException if there is a problem reading the entry from
197:             *      the stream.
198:             */
199:            public abstract void read(DataInputStream cpStream)
200:                    throws IOException;
201:
202:            /**
203:             * Get the Entry's type tag.
204:             *
205:             * @return The Tag value of this entry
206:             */
207:            public int getTag() {
208:                return tag;
209:            }
210:
211:            /**
212:             * Get the number of Constant Pool Entry slots within the constant pool
213:             * occupied by this entry.
214:             *
215:             * @return the number of slots used.
216:             */
217:            public final int getNumEntries() {
218:                return numEntries;
219:            }
220:
221:        }
w_w_w_.__j___a___v__a___2___s__.__co_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.