Source Code Cross Referenced for Field.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » jpda » tests » framework » jdwp » 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 » Apache Harmony Java SE » org package » org.apache.harmony.jpda.tests.framework.jdwp 
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:         *
015:         *  See the License for the specific language governing permissions and
016:         *  limitations under the License.
017:         */
018:
019:        /**
020:         * @author Alexei S. Vaskin
021:         * @version $Revision: 1.4 $
022:         */
023:
024:        /**
025:         * Created on 03.05.2005 
026:         */package org.apache.harmony.jpda.tests.framework.jdwp;
027:
028:        /**
029:         * This class provides description of class field.
030:         * 
031:         */
032:        public final class Field {
033:
034:            private long id;
035:
036:            private long classID;
037:
038:            private String name;
039:
040:            private String signature;
041:
042:            private int modBits;
043:
044:            private byte tag;
045:
046:            /**
047:             * Default constructor.
048:             */
049:            public Field() {
050:                id = -1;
051:                classID = -1;
052:                name = "unknown";
053:                signature = "unknown";
054:                modBits = -1;
055:            }
056:
057:            /**
058:             * Constructor initializing all members of the Field instance.
059:             * 
060:             * @param id
061:             *            field id
062:             * @param classID
063:             *            class id
064:             * @param name
065:             *            field name
066:             * @param signature
067:             *            signature signature of the field class
068:             * @param modBits
069:             *            field modifiers
070:             */
071:            public Field(long id, long classID, String name, String signature,
072:                    int modBits) {
073:                this .id = id;
074:                this .classID = classID;
075:                this .name = name;
076:                this .modBits = modBits;
077:                setSignature(signature);
078:            }
079:
080:            /**
081:             * Sets signature and detects type tag from it.
082:             * 
083:             * @param signature
084:             *            signature of the field class
085:             */
086:            private void setSignature(String signature) {
087:                switch (signature.charAt(0)) {
088:                case '[':
089:                    tag = JDWPConstants.Tag.ARRAY_TAG;
090:                    break;
091:                case 'B':
092:                    tag = JDWPConstants.Tag.BYTE_TAG;
093:                    break;
094:                case 'C':
095:                    tag = JDWPConstants.Tag.CHAR_TAG;
096:                    break;
097:                case 'L':
098:                    tag = JDWPConstants.Tag.OBJECT_TAG;
099:                    break;
100:                case 'F':
101:                    tag = JDWPConstants.Tag.FLOAT_TAG;
102:                    break;
103:                case 'D':
104:                    tag = JDWPConstants.Tag.DOUBLE_TAG;
105:                    break;
106:                case 'I':
107:                    tag = JDWPConstants.Tag.INT_TAG;
108:                    break;
109:                case 'J':
110:                    tag = JDWPConstants.Tag.LONG_TAG;
111:                    break;
112:                case 'S':
113:                    tag = JDWPConstants.Tag.SHORT_TAG;
114:                    break;
115:                case 'V':
116:                    tag = JDWPConstants.Tag.VOID_TAG;
117:                    break;
118:                case 'Z':
119:                    tag = JDWPConstants.Tag.BOOLEAN_TAG;
120:                    break;
121:                case 's':
122:                    tag = JDWPConstants.Tag.STRING_TAG;
123:                    break;
124:                case 't':
125:                    tag = JDWPConstants.Tag.THREAD_TAG;
126:                    break;
127:                case 'g':
128:                    tag = JDWPConstants.Tag.THREAD_GROUP_TAG;
129:                    break;
130:                case 'l':
131:                    tag = JDWPConstants.Tag.CLASS_LOADER_TAG;
132:                    break;
133:                case 'c':
134:                    tag = JDWPConstants.Tag.CLASS_OBJECT_TAG;
135:                    break;
136:                }
137:
138:                this .signature = signature;
139:            }
140:
141:            /**
142:             * Gets field id.
143:             * 
144:             * @return long
145:             */
146:            public long getID() {
147:                return this .id;
148:            }
149:
150:            /**
151:             * Gets id of the field reference type.
152:             * 
153:             * @return long
154:             */
155:            public long getClassID() {
156:                return classID;
157:            }
158:
159:            /**
160:             * Gets field name.
161:             * 
162:             * @return String
163:             */
164:            public String getName() {
165:                return name;
166:            }
167:
168:            /**
169:             * Gets signature of field type.
170:             * 
171:             * @return String
172:             */
173:            public String getSignature() {
174:                return signature;
175:            }
176:
177:            /**
178:             * Gets field modifiers.
179:             * 
180:             * @return int
181:             */
182:            public int getModBits() {
183:                return modBits;
184:            }
185:
186:            /**
187:             * Gets field java type.
188:             * 
189:             * @return String
190:             */
191:            public String getType() {
192:                String type = "unknown type";
193:                switch (tag) {
194:                case JDWPConstants.Tag.ARRAY_TAG:
195:                    switch (signature.charAt(1)) {
196:                    case 'B':
197:                        type = "byte[]";
198:                        break;
199:                    case 'C':
200:                        type = "char[]";
201:                        break;
202:                    case 'J':
203:                        type = "long[]";
204:                        break;
205:                    case 'F':
206:                        type = "float[]";
207:                        break;
208:                    case 'D':
209:                        type = "double[]";
210:                        break;
211:                    case 'I':
212:                        type = "int[]";
213:                        break;
214:                    case 'S':
215:                        type = "short[]";
216:                        break;
217:                    case 'V':
218:                        type = "void[]";
219:                        break;
220:                    case 'Z':
221:                        type = "boolean[]";
222:                        break;
223:                    case 's':
224:                        type = "java.Lang.String[]";
225:                        break;
226:                    case 'L':
227:                        type = signature.substring(2, signature.length() - 1 /*
228:                         * skip ending
229:                         * ';'
230:                         */).replaceAll("/", ".") + "[]"; // skip ending ';'
231:                        break;
232:                    }
233:                    break;
234:                case JDWPConstants.Tag.OBJECT_TAG:
235:                    type = signature
236:                            .substring(1, signature.length() - 1 /* skip ending ';' */)
237:                            .replaceAll("/", "."); // skip ending ';'
238:                    break;
239:                case JDWPConstants.Tag.BOOLEAN_TAG:
240:                    type = "boolean";
241:                    break;
242:                case JDWPConstants.Tag.BYTE_TAG:
243:                    type = "byte";
244:                    break;
245:                case JDWPConstants.Tag.CHAR_TAG:
246:                    type = "char";
247:                    break;
248:                case JDWPConstants.Tag.DOUBLE_TAG:
249:                    type = "double";
250:                    break;
251:                case JDWPConstants.Tag.FLOAT_TAG:
252:                    type = "float";
253:                    break;
254:                case JDWPConstants.Tag.INT_TAG:
255:                    type = "int";
256:                    break;
257:                case JDWPConstants.Tag.LONG_TAG:
258:                    type = "long";
259:                    break;
260:                case JDWPConstants.Tag.SHORT_TAG:
261:                    type = "short";
262:                    break;
263:                case JDWPConstants.Tag.STRING_TAG:
264:                    type = "string";
265:                    break;
266:                default:
267:                    break;
268:                }
269:
270:                return type;
271:            }
272:
273:            /**
274:             * Compares two Field objects.
275:             * 
276:             * @see java.lang.Object#equals(java.lang.Object)
277:             * @return boolean
278:             */
279:            public boolean equals(Object obj) {
280:                if (!(obj instanceof  Field)) {
281:                    return false;
282:                }
283:
284:                if (this .getClass() != obj.getClass()) {
285:                    return false;
286:                }
287:
288:                Field field = (Field) obj;
289:                return this .id == field.id && this .classID == field.classID
290:                        && this .name.equals(field.name)
291:                        && this .signature.equals(field.signature)
292:                        && this .modBits == field.modBits;
293:            }
294:
295:            /**
296:             * Converts Field object to String.
297:             * 
298:             * @see java.lang.Object#toString()
299:             * @return String
300:             */
301:            public String toString() {
302:                String str = "Field: id=" + id + ", classID=" + classID
303:                        + ", name='" + name + "', signature='" + signature
304:                        + "', modBits=";
305:                String access = "";
306:                if ((this .modBits & JDWPConstants.FieldAccess.ACC_PRIVATE) == JDWPConstants.FieldAccess.ACC_PRIVATE) {
307:                    access += JDWPConstants.FieldAccess
308:                            .getName(JDWPConstants.FieldAccess.ACC_PRIVATE)
309:                            + " ";
310:                } else if ((this .modBits & JDWPConstants.FieldAccess.ACC_PROTECTED) == JDWPConstants.FieldAccess.ACC_PROTECTED) {
311:                    access += JDWPConstants.FieldAccess
312:                            .getName(JDWPConstants.FieldAccess.ACC_PROTECTED)
313:                            + " ";
314:                } else if ((this .modBits & JDWPConstants.FieldAccess.ACC_PUBLIC) == JDWPConstants.FieldAccess.ACC_PUBLIC) {
315:                    access += JDWPConstants.FieldAccess
316:                            .getName(JDWPConstants.FieldAccess.ACC_PUBLIC)
317:                            + " ";
318:                }
319:                if ((this .modBits & JDWPConstants.FieldAccess.ACC_FINAL) == JDWPConstants.FieldAccess.ACC_FINAL) {
320:                    access += JDWPConstants.FieldAccess
321:                            .getName(JDWPConstants.FieldAccess.ACC_FINAL)
322:                            + " ";
323:                }
324:                if ((this .modBits & JDWPConstants.FieldAccess.ACC_STATIC) == JDWPConstants.FieldAccess.ACC_STATIC) {
325:                    access += JDWPConstants.FieldAccess
326:                            .getName(JDWPConstants.FieldAccess.ACC_STATIC)
327:                            + " ";
328:                }
329:                if ((this .modBits & JDWPConstants.FieldAccess.ACC_TRANSIENT) == JDWPConstants.FieldAccess.ACC_TRANSIENT) {
330:                    access += JDWPConstants.FieldAccess
331:                            .getName(JDWPConstants.FieldAccess.ACC_TRANSIENT)
332:                            + " ";
333:                }
334:                if ((this .modBits & JDWPConstants.FieldAccess.ACC_VOLATILE) == JDWPConstants.FieldAccess.ACC_VOLATILE) {
335:                    access += JDWPConstants.FieldAccess
336:                            .getName(JDWPConstants.FieldAccess.ACC_VOLATILE)
337:                            + " ";
338:                }
339:
340:                return str + access;
341:            }
342:
343:            /**
344:             * Tells whether this field is private.
345:             * 
346:             * @return boolean
347:             */
348:            public boolean isPrivate() {
349:                return (modBits & JDWPConstants.FieldAccess.ACC_PRIVATE) == JDWPConstants.FieldAccess.ACC_PRIVATE;
350:            }
351:
352:            /**
353:             * Tells whether this field is protected.
354:             * 
355:             * @return boolean
356:             */
357:            public boolean isProtected() {
358:                return (modBits & JDWPConstants.FieldAccess.ACC_PROTECTED) == JDWPConstants.FieldAccess.ACC_PROTECTED;
359:            }
360:
361:            /**
362:             * Tells whether this field is public.
363:             * 
364:             * @return boolean
365:             */
366:            public boolean isPublic() {
367:                return (modBits & JDWPConstants.FieldAccess.ACC_PUBLIC) == JDWPConstants.FieldAccess.ACC_PUBLIC;
368:            }
369:
370:            /**
371:             * Tells whether this field is final.
372:             * 
373:             * @return boolean
374:             */
375:            public boolean isFinal() {
376:                return (modBits & JDWPConstants.FieldAccess.ACC_FINAL) == JDWPConstants.FieldAccess.ACC_FINAL;
377:            }
378:
379:            /**
380:             * Tells whether this field is static.
381:             * 
382:             * @return boolean
383:             */
384:            public boolean isStatic() {
385:                return (modBits & JDWPConstants.FieldAccess.ACC_STATIC) == JDWPConstants.FieldAccess.ACC_STATIC;
386:            }
387:        }
ww___w.__j__av___a2___s_.__c___o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.