Source Code Cross Referenced for LocationImpl.java in  » IDE-Eclipse » jdt » org » eclipse » jdi » internal » 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 » IDE Eclipse » jdt » org.eclipse.jdi.internal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 IBM Corporation and others.
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:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.jdi.internal;
011:
012:        import java.io.DataInputStream;
013:        import java.io.DataOutputStream;
014:        import java.io.IOException;
015:        import com.ibm.icu.text.MessageFormat;
016:
017:        import com.sun.jdi.AbsentInformationException;
018:        import com.sun.jdi.Location;
019:        import com.sun.jdi.Method;
020:        import com.sun.jdi.ReferenceType;
021:
022:        /**
023:         * this class implements the corresponding interfaces
024:         * declared by the JDI specification. See the com.sun.jdi package
025:         * for more information.
026:         *
027:         */
028:        public class LocationImpl extends MirrorImpl implements  Location {
029:            /** Line nr used if line numbers are not available. */
030:            public static final int LINE_NR_NOT_AVAILABLE = -1;
031:
032:            /** Method that holds the location. */
033:            MethodImpl fMethod;
034:            /** Index of location within the method, note: this value must be treated as UNSIGNED! */
035:            long fIndex;
036:
037:            /**
038:             * Creates new instance.
039:             */
040:            public LocationImpl(VirtualMachineImpl vmImpl, MethodImpl method,
041:                    long index) {
042:                super ("Location", vmImpl); //$NON-NLS-1$
043:                fMethod = method;
044:                fIndex = index;
045:            }
046:
047:            /**
048:             * @return Returns the code position within this location's method.
049:             */
050:            public long codeIndex() {
051:                return fIndex;
052:            }
053:
054:            /**
055:             * @return Returns the type to which this Location belongs. 
056:             */
057:            public ReferenceType declaringType() {
058:                return fMethod.declaringType();
059:            }
060:
061:            /** 
062:             * @return Returns the hash code value.
063:             */
064:            public int hashCode() {
065:                return fMethod.hashCode() + (int) fIndex;
066:            }
067:
068:            /**
069:             * @return Returns true if two mirrors refer to the same entity in the target VM.
070:             * @see java.lang.Object#equals(Object)
071:             */
072:            public boolean equals(Object object) {
073:                if (object != null && object.getClass().equals(this .getClass())) {
074:                    LocationImpl loc = (LocationImpl) object;
075:                    return fMethod.equals(loc.fMethod) && fIndex == loc.fIndex;
076:                }
077:                return false;
078:            }
079:
080:            /**
081:             * @return Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
082:             */
083:            public int compareTo(Object object) {
084:                if (object == null
085:                        || !object.getClass().equals(this .getClass()))
086:                    throw new ClassCastException(
087:                            JDIMessages.LocationImpl_Can__t_compare_location_to_given_object_1);
088:
089:                // See if methods are the same, if not return comparison between methods.
090:                LocationImpl location2 = (LocationImpl) object;
091:                if (!method().equals(location2.method()))
092:                    return method().compareTo(location2.method());
093:
094:                // Return comparison between code-indexes.		
095:                // Code indexes must be treated as unsigned. This matters if you have to compare them.
096:                if (codeIndex() < 0 || location2.codeIndex() < 0)
097:                    throw new InternalError(
098:                            JDIMessages.LocationImpl_Code_indexes_are_assumed_to_be_always_positive_2);
099:
100:                if (codeIndex() < location2.codeIndex())
101:                    return -1;
102:                else if (codeIndex() > location2.codeIndex())
103:                    return 1;
104:                else
105:                    return 0;
106:            }
107:
108:            /** 
109:             * @return Returns an int specifying the line in the source, return -1 if the information is not available.
110:             */
111:            public int lineNumber() {
112:                return lineNumber(virtualMachine().getDefaultStratum());
113:            }
114:
115:            /** 
116:             * @return Returns the Method if this location is in a method.
117:             */
118:            public Method method() {
119:                return fMethod;
120:            }
121:
122:            /** 
123:             * @return a string specifying the source.
124:             */
125:            public String sourceName() throws AbsentInformationException {
126:                return sourceName(virtualMachine().getDefaultStratum());
127:            }
128:
129:            /**
130:             * @return Returns description of Mirror object.
131:             */
132:            public String toString() {
133:                try {
134:                    return MessageFormat
135:                            .format(
136:                                    JDIMessages.LocationImpl_sourcename___0___line___1__3,
137:                                    new String[] { sourceName(),
138:                                            Integer.toString(lineNumber()) });
139:                } catch (Exception e) {
140:                    return fDescription;
141:                }
142:            }
143:
144:            /**
145:             * Writes JDWP representation.
146:             */
147:            public void write(MirrorImpl target, DataOutputStream out)
148:                    throws IOException {
149:                fMethod.writeWithReferenceTypeWithTag(target, out);
150:                target.writeLong(fIndex, "index", out); //$NON-NLS-1$
151:            }
152:
153:            /**
154:             * @return Reads JDWP representation and returns new instance.
155:             */
156:            public static LocationImpl read(MirrorImpl target,
157:                    DataInputStream in) throws IOException {
158:                VirtualMachineImpl vmImpl = target.virtualMachineImpl();
159:                // Notice that Locations are not stored or cached because they don't 'remember' any information.
160:                MethodImpl method = MethodImpl.readWithReferenceTypeWithTag(
161:                        target, in);
162:                long index = target.readLong("index", in); //$NON-NLS-1$
163:                if (method == null) {
164:                    return null;
165:                }
166:                return new LocationImpl(vmImpl, method, index);
167:            }
168:
169:            /**
170:             * @see Location#lineNumber(String)
171:             */
172:            public int lineNumber(String stratum) {
173:                return fMethod.referenceTypeImpl().lineNumber(fIndex, fMethod,
174:                        stratum);
175:            }
176:
177:            /**
178:             * @see Location#sourceName(String)
179:             */
180:            public String sourceName(String stratum)
181:                    throws AbsentInformationException {
182:                return fMethod.referenceTypeImpl().sourceName(fIndex, fMethod,
183:                        stratum);
184:            }
185:
186:            /**
187:             * @see Location#sourcePath(String)
188:             */
189:            public String sourcePath(String stratum)
190:                    throws AbsentInformationException {
191:                return fMethod.referenceTypeImpl().sourcePath(fIndex, fMethod,
192:                        stratum);
193:            }
194:
195:            /**
196:             * @see Location#sourcePath()
197:             */
198:            public String sourcePath() throws AbsentInformationException {
199:                return sourcePath(virtualMachine().getDefaultStratum());
200:            }
201:
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.