Source Code Cross Referenced for Token.java in  » Template-Engine » bte » com » Ostermiller » bte » 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 » Template Engine » bte » com.Ostermiller.bte 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2000-2001 Stephen Ostermiller
003:         * http://ostermiller.org/contact.pl?regarding=BTE
004:         * 
005:         * This program is free software; you can redistribute it and/or modify
006:         * it under the terms of the GNU General Public License as published by
007:         * the Free Software Foundation; either version 2 of the License, or
008:         * (at your option) any later version.
009:         * 
010:         * This program is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013:         * GNU General Public License for more details.
014:         * 
015:         * See COPYING.TXT for details.
016:         */
017:
018:        package com.Ostermiller.bte;
019:
020:        /** 
021:         * A Token is a token that is returned by a lexer that is lexing a bte
022:         * source file.  It has several attributes describing the token:
023:         * The type of token, the text of the token, the line number on which it
024:         * occurred, the number of characters into the input at which it started, and
025:         * similarly, the number of characters into the inut at which it ended. <br>
026:         */
027:        class Token {
028:
029:            private int ID;
030:            private String contents;
031:            private int lineNumber;
032:            private int charBegin;
033:            private int charEnd;
034:
035:            /** 
036:             * Create a new token.
037:             * The constructor is typically called by the lexer
038:             * 
039:             * @param ID the id number of the token
040:             * @param contents A string representing the text of the token
041:             * @param lineNumber the line number of the input on which this token started
042:             * @param charBegin the offset into the input in characters at which this token started
043:             * @param charEnd the offset into the input in characters at which this token ended
044:             */
045:            Token(int ID, String contents, int lineNumber, int charBegin,
046:                    int charEnd) {
047:                this .ID = ID;
048:                this .contents = new String(contents);
049:                this .lineNumber = lineNumber;
050:                this .charBegin = charBegin;
051:                this .charEnd = charEnd;
052:            }
053:
054:            /** 
055:             * get the ID number of this token
056:             * 
057:             * @return the id number of the token
058:             */
059:            int getID() {
060:                return ID;
061:            }
062:
063:            /** 
064:             * get the contents of this token
065:             * 
066:             * @return A string representing the text of the token
067:             */
068:            String getContents() {
069:                return (new String(contents));
070:            }
071:
072:            /** 
073:             * get the line number of the input on which this token started
074:             * 
075:             * @return the line number of the input on which this token started
076:             */
077:            int getLineNumber() {
078:                return lineNumber;
079:            }
080:
081:            /** 
082:             * get the offset into the input in characters at which this token started
083:             *
084:             * @return the offset into the input in characters at which this token started
085:             */
086:            int getCharBegin() {
087:                return charBegin;
088:            }
089:
090:            /** 
091:             * get the offset into the input in characters at which this token ended
092:             *
093:             * @return the offset into the input in characters at which this token ended
094:             */
095:            int getCharEnd() {
096:                return charEnd;
097:            }
098:
099:            /** 
100:             * Checks this token to see if it is a comment.
101:             * 
102:             * @return true if this token is a comment, false otherwise
103:             */
104:            boolean isComment() {
105:                return (false);
106:            }
107:
108:            /** 
109:             * Checks this token to see if it is White Space.
110:             * Usually tabs, line breaks, form feed, spaces, etc.
111:             * 
112:             * @return true if this token is White Space, false otherwise
113:             */
114:            boolean isWhiteSpace() {
115:                return (ID == sym.WHITESPACE);
116:            }
117:
118:            /** 
119:             * Checks this token to see if it is an Error.
120:             * Unfinished comments, numbers that are too big, unclosed strings, etc.
121:             * 
122:             * @return true if this token is an Error, false otherwise
123:             */
124:            boolean isError() {
125:                return (false);
126:            }
127:
128:            /**
129:             * get a String that explains the error, if this token is an error.
130:             * 
131:             * @return a  String that explains the error, if this token is an error, null otherwise.
132:             */
133:            String errorString() {
134:                return "";
135:            }
136:
137:            /** 
138:             * get a representation of this token as a human readable string.
139:             * The format of this string is subject to change and should only be used
140:             * for debugging purposes.
141:             *
142:             * @return a string representation of this token
143:             */
144:            public String toString() {
145:                return ("Token " + ID + " Line " + lineNumber + " from "
146:                        + charBegin + " to " + charEnd + " : " + contents);
147:            }
148:
149:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.