Source Code Cross Referenced for Location.java in  » Build » ANT » org » apache » tools » ant » 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 
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:
019:        package org.apache.tools.ant;
020:
021:        import java.io.Serializable;
022:        import org.apache.tools.ant.util.FileUtils;
023:        import org.xml.sax.Locator;
024:
025:        /**
026:         * Stores the location of a piece of text within a file (file name,
027:         * line number and column number). Note that the column number is
028:         * currently ignored.
029:         *
030:         */
031:        public class Location implements  Serializable {
032:
033:            /** Name of the file. */
034:            private String fileName;
035:            /** Line number within the file. */
036:            private int lineNumber;
037:            /** Column number within the file. */
038:            private int columnNumber;
039:
040:            /** Location to use when one is needed but no information is available */
041:            public static final Location UNKNOWN_LOCATION = new Location();
042:
043:            private static final FileUtils FILE_UTILS = FileUtils
044:                    .getFileUtils();
045:
046:            /**
047:             * Creates an "unknown" location.
048:             */
049:            private Location() {
050:                this (null, 0, 0);
051:            }
052:
053:            /**
054:             * Creates a location consisting of a file name but no line number or
055:             * column number.
056:             *
057:             * @param fileName The name of the file. May be <code>null</code>,
058:             *                 in which case the location is equivalent to
059:             *                 {@link #UNKNOWN_LOCATION UNKNOWN_LOCATION}.
060:             */
061:            public Location(String fileName) {
062:                this (fileName, 0, 0);
063:            }
064:
065:            /**
066:             * Creates a location from the SAX locator using the system ID as
067:             * the filename.
068:             *
069:             * @param loc Must not be <code>null</code>.
070:             *
071:             * @since Ant 1.6
072:             */
073:            public Location(Locator loc) {
074:                this (loc.getSystemId(), loc.getLineNumber(), loc
075:                        .getColumnNumber());
076:            }
077:
078:            /**
079:             * Creates a location consisting of a file name, line number and
080:             * column number.
081:             *
082:             * @param fileName The name of the file. May be <code>null</code>,
083:             *                 in which case the location is equivalent to
084:             *                 {@link #UNKNOWN_LOCATION UNKNOWN_LOCATION}.
085:             *
086:             * @param lineNumber Line number within the file. Use 0 for unknown
087:             *                   positions within a file.
088:             * @param columnNumber Column number within the line.
089:             */
090:            public Location(String fileName, int lineNumber, int columnNumber) {
091:                if (fileName != null && fileName.startsWith("file:")) {
092:                    this .fileName = FILE_UTILS.fromURI(fileName);
093:                } else {
094:                    this .fileName = fileName;
095:                }
096:                this .lineNumber = lineNumber;
097:                this .columnNumber = columnNumber;
098:            }
099:
100:            /**
101:             * @return the filename portion of the location
102:             * @since Ant 1.6
103:             */
104:            public String getFileName() {
105:                return fileName;
106:            }
107:
108:            /**
109:             * @return the line number
110:             * @since Ant 1.6
111:             */
112:            public int getLineNumber() {
113:                return lineNumber;
114:            }
115:
116:            /**
117:             * @return the column number
118:             * @since Ant 1.7
119:             */
120:            public int getColumnNumber() {
121:                return columnNumber;
122:            }
123:
124:            /**
125:             * Returns the file name, line number, a colon and a trailing space.
126:             * An error message can be appended easily. For unknown locations, an
127:             * empty string is returned.
128:             *
129:             * @return a String of the form <code>"fileName:lineNumber: "</code>
130:             *         if both file name and line number are known,
131:             *         <code>"fileName: "</code> if only the file name is known,
132:             *         and the empty string for unknown locations.
133:             */
134:            public String toString() {
135:                StringBuffer buf = new StringBuffer();
136:
137:                if (fileName != null) {
138:                    buf.append(fileName);
139:
140:                    if (lineNumber != 0) {
141:                        buf.append(":");
142:                        buf.append(lineNumber);
143:                    }
144:
145:                    buf.append(": ");
146:                }
147:
148:                return buf.toString();
149:            }
150:
151:            /**
152:             * Equality operation.
153:             * @param other the object to compare to.
154:             * @return true if the other object contains the same information
155:             *              as this object.
156:             * @since Ant 1.6.3
157:             */
158:            public boolean equals(Object other) {
159:                if (this  == other) {
160:                    return true;
161:                }
162:                if (other == null) {
163:                    return false;
164:                }
165:                if (!(other.getClass() == getClass())) {
166:                    return false;
167:                }
168:                return toString().equals(other.toString());
169:            }
170:
171:            /**
172:             * Hash operation.
173:             * @return a hash code value for this location.
174:             * @since Ant 1.6.3
175:             */
176:            public int hashCode() {
177:                return toString().hashCode();
178:            }
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.