Source Code Cross Referenced for Location.java in  » Scripting » Nice » bossa » util » 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 » Scripting » Nice » bossa.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**************************************************************************/
002:        /*                                N I C E                                 */
003:        /*             A high-level object-oriented research language             */
004:        /*                        (c) Daniel Bonniot 2003                         */
005:        /*                                                                        */
006:        /*  This program is free software; you can redistribute it and/or modify  */
007:        /*  it under the terms of the GNU General Public License as published by  */
008:        /*  the Free Software Foundation; either version 2 of the License, or     */
009:        /*  (at your option) any later version.                                   */
010:        /*                                                                        */
011:        /**************************************************************************/package bossa.util;
012:
013:        import java.util.*;
014:
015:        /**
016:         Represents a portion of the input file.
017:         Used to report errors to the user.
018:        
019:         @see Located
020:
021:         @author Daniel Bonniot (bonniot@users.sourceforge.net)
022:         */
023:        public abstract class Location implements  Located {
024:            public static Location make(java.io.File file, int startLine,
025:                    int startColumn, int endLine, int endColumn) {
026:                return new Source(file, startLine, startColumn, endLine,
027:                        endColumn);
028:            }
029:
030:            public static Location make(java.io.File file, int startLine,
031:                    int startColumn) {
032:                return make(file, startLine, startColumn, -1, -1);
033:            }
034:
035:            public static Location make(int startLine, int startColumn,
036:                    int endLine, int endColumn) {
037:                return make(currentFile, startLine, startColumn, endLine,
038:                        endColumn);
039:            }
040:
041:            public static Location make(int startLine, int startColumn) {
042:                return make(currentFile, startLine, startColumn, -1, -1);
043:            }
044:
045:            /**
046:             * The file beeing parsed.
047:             * Enables to set the file name just once,
048:             * not at each Location construction.
049:             */
050:            public static void setCurrentFile(java.io.File file) {
051:                currentFile = file;
052:            }
053:
054:            private static java.io.File currentFile = null;
055:
056:            public static final Location option = new Option();
057:
058:            public static Location nowhere() {
059:                return new Location.File(currentFile);
060:            }
061:
062:            public Location location() {
063:                return this ;
064:            }
065:
066:            /**
067:               Return an identifier, which is guaranteed to be different for
068:               different locations.
069:             */
070:            public String uniqueIdentifier(String root) {
071:                StringBuffer uniq = new StringBuffer(super .toString());
072:                // Replace the '@' in bossa.util.Location@12345 with '_'
073:                uniq.setCharAt("bossa.util.Location".length(), '_');
074:
075:                return root + uniq.toString();
076:            }
077:
078:            public String toShortString() {
079:                return toString();
080:            }
081:
082:            /****************************************************************
083:             * Setting source location in the generated bytecode.
084:             ****************************************************************/
085:
086:            public void write(gnu.expr.Expression exp) {
087:            }
088:
089:            public void writeEnd(gnu.expr.Expression exp) {
090:            }
091:
092:            public void write(gnu.expr.Declaration decl) {
093:            }
094:
095:            /****************************************************************
096:             * Different behaviour wether compiler is invoked by an editor.
097:             ****************************************************************/
098:
099:            public static boolean editorMode = false;
100:
101:            /****************************************************************
102:             * File location
103:             ****************************************************************/
104:
105:            public static class File extends Location {
106:                private File(java.io.File file) {
107:                    this .file = file;
108:                }
109:
110:                private java.io.File file;
111:
112:                public java.io.File getFile() {
113:                    return file;
114:                }
115:
116:                public String toString() {
117:                    if (file == null)
118:                        return "";
119:                    else
120:                        return nice.tools.util.System.prettyPrint(file);
121:                }
122:
123:                public String toShortString() {
124:                    return (file == null) ? "" : file.getName();
125:                }
126:
127:                public void write(gnu.expr.Expression exp) {
128:                    if (file == null)
129:                        return;
130:
131:                    // In the bytecode, the fully qualified name is not wanted.
132:                    exp.setFile(file.getName());
133:                }
134:
135:                public void write(gnu.expr.Declaration decl) {
136:                    if (file == null)
137:                        return;
138:
139:                    // In the bytecode, the fully qualified name is not wanted.
140:                    decl.setFile(file.getName());
141:                }
142:            }
143:
144:            /****************************************************************
145:             * Source location
146:             ****************************************************************/
147:
148:            public static class Source extends File {
149:                private Source(java.io.File file, int startLine,
150:                        int startColumn, int endLine, int endColumn) {
151:                    super (file);
152:                    this .startLine = startLine;
153:                    this .startColumn = startColumn;
154:                    this .endLine = endLine;
155:                    this .endColumn = endColumn;
156:                }
157:
158:                private int startLine, startColumn, endLine, endColumn;
159:
160:                public int getLine() {
161:                    return startLine;
162:                }
163:
164:                public int getColumn() {
165:                    return startColumn;
166:                }
167:
168:                public String toString() {
169:                    String res = super .toString();
170:                    if (editorMode)
171:                        return (res.length() > 0 ? (res + ":") : "")
172:                                + startLine + ":" + startColumn;
173:                    else
174:                        return (res.length() > 0 ? (res + ": ") : "") + "line "
175:                                + startLine + ", column " + startColumn;
176:                }
177:
178:                public String toShortString() {
179:                    return super .toShortString() + ":" + startLine;
180:                }
181:
182:                public String uniqueIdentifier(String root) {
183:                    return root + startLine + "_" + startColumn;
184:                }
185:
186:                public void write(gnu.expr.Expression exp) {
187:                    super .write(exp);
188:                    exp.setLine(getLine(), getColumn());
189:                }
190:
191:                public void writeEnd(gnu.expr.Expression exp) {
192:                    super .write(exp);
193:                    exp.setLine(endLine, endColumn);
194:                }
195:
196:                public void write(gnu.expr.Declaration decl) {
197:                    super .write(decl);
198:                    decl.setLine(getLine(), getColumn());
199:                }
200:            }
201:
202:            public static Location make(gnu.expr.Expression expr) {
203:                String file = expr.getFile();
204:                return new Source(file != null ? new java.io.File(file) : null,
205:                        expr.getLine(), expr.getColumn(), -1, -1);
206:            }
207:
208:            /****************************************************************
209:             * A compilation option
210:             ****************************************************************/
211:
212:            public static class Option extends Location {
213:                public String toString() {
214:                    return "Command line";
215:                }
216:            }
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.