Source Code Cross Referenced for ReducedToken.java in  » IDE » DrJava » edu » rice » cs » drjava » model » definitions » reducedmodel » 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 » DrJava » edu.rice.cs.drjava.model.definitions.reducedmodel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*BEGIN_COPYRIGHT_BLOCK
002:         *
003:         * Copyright (c) 2001-2007, JavaPLT group at Rice University (javaplt@rice.edu)
004:         * All rights reserved.
005:         * 
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions are met:
008:         *    * Redistributions of source code must retain the above copyright
009:         *      notice, this list of conditions and the following disclaimer.
010:         *    * Redistributions in binary form must reproduce the above copyright
011:         *      notice, this list of conditions and the following disclaimer in the
012:         *      documentation and/or other materials provided with the distribution.
013:         *    * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
014:         *      names of its contributors may be used to endorse or promote products
015:         *      derived from this software without specific prior written permission.
016:         * 
017:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
018:         * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
019:         * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
020:         * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
021:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
022:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
023:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
024:         * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
025:         * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
026:         * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
027:         * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028:         *
029:         * This software is Open Source Initiative approved Open Source Software.
030:         * Open Source Initative Approved is a trademark of the Open Source Initiative.
031:         * 
032:         * This file is part of DrJava.  Download the current version of this project
033:         * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
034:         * 
035:         * END_COPYRIGHT_BLOCK*/
036:
037:        package edu.rice.cs.drjava.model.definitions.reducedmodel;
038:
039:        /** The representation of document text in the reduced model. ReducedToken ::= Brace | Gap
040:         *  @version $Id: ReducedToken.java 4255 2007-08-28 19:17:37Z mgricken $
041:         */
042:        public abstract class ReducedToken implements  ReducedModelStates {
043:            private ReducedModelState _state;
044:
045:            public ReducedToken(ReducedModelState state) {
046:                _state = state;
047:            }
048:
049:            /** Get the size of the token.
050:             *  @return the number of characters represented by the token
051:             */
052:            public abstract int getSize();
053:
054:            /** Get the type of the token.
055:             *  @return a String representation of the token type
056:             */
057:            public abstract String getType();
058:
059:            /** Set the type of the token
060:             *  @param type a String representation of the new token type
061:             */
062:            public abstract void setType(String type);
063:
064:            /** Flip between open and closed.  Valid only for braces. */
065:            public abstract void flip();
066:
067:            /** Determine if the given token is a open/close match with this.
068:             *  @param other another ReducedToken
069:             *  @return true if there is a match
070:             */
071:            public abstract boolean isMatch(Brace other);
072:
073:            /** Return true iff this ReducedToken is a matchable, i.e. is one of "{", "}", "(", ")", "[", "]" */
074:            public abstract boolean isMatchable();
075:
076:            /** Get the shadowing state of the token.
077:             *  @return FREE | INSIDE_SINGLE_QUOTE | INSIDE_DOUBLE_QUOTE | INSIDE_LINE_COMMENT| INSIDE_BLOCK_COMMENT
078:             */
079:            public ReducedModelState getState() {
080:                return _state;
081:            }
082:
083:            /** Returns whether the current char is highlighted. / / beginning a comment
084:             *  would be highlighted but free, so its not the same as getState
085:             */
086:            public int getHighlightState() {
087:                String type = getType();
088:                if (type.equals("//") || (_state == INSIDE_LINE_COMMENT)
089:                        || type.equals("/*") || type.equals("*/")
090:                        || (_state == INSIDE_BLOCK_COMMENT)) {
091:                    return HighlightStatus.COMMENTED;
092:                }
093:                if ((type.equals("'") && (_state == FREE))
094:                        || (_state == INSIDE_SINGLE_QUOTE)) {
095:                    return HighlightStatus.SINGLE_QUOTED;
096:                }
097:                if ((type.equals("\"") && (_state == FREE))
098:                        || (_state == INSIDE_DOUBLE_QUOTE)) {
099:                    return HighlightStatus.DOUBLE_QUOTED;
100:                }
101:                return HighlightStatus.NORMAL;
102:            }
103:
104:            /** Set the shadowing state of the token.
105:             *  @param state
106:             */
107:            public void setState(ReducedModelState state) {
108:                _state = state;
109:            }
110:
111:            /** Indicates whether this brace is shadowed. Shadowing occurs when a brace has been swallowed by a
112:             *  comment or an open quote.
113:             *  @return true if the brace is shadowed.
114:             */
115:            public boolean isShadowed() {
116:                return _state != FREE;
117:            }
118:
119:            /** Indicates whether this brace is inside quotes.
120:             *  @return true if the brace is inside quotes.
121:             */
122:            public boolean isQuoted() {
123:                return _state == INSIDE_DOUBLE_QUOTE;
124:            }
125:
126:            /** Indicates whether this brace is commented out.
127:             *  @return true if the brace is hidden by comments.
128:             */
129:            public boolean isCommented() {
130:                return inBlockComment() || inLineComment();
131:            }
132:
133:            /** Determines whether the current location is inside a block comment.
134:             *  @return true or false
135:             */
136:            public boolean inBlockComment() {
137:                return _state == INSIDE_BLOCK_COMMENT;
138:            }
139:
140:            /** Determines whether the current location is inside a line comment.
141:             *  @return true or false
142:             */
143:            public boolean inLineComment() {
144:                return _state == INSIDE_LINE_COMMENT;
145:            }
146:
147:            /** Determines whether the current location is part of a multiple char brace.
148:             *  @return true or false
149:             */
150:            public abstract boolean isMultipleCharBrace();
151:
152:            /** Determines whether the current location is within in gap.
153:             *  @return true or false
154:             */
155:            public abstract boolean isGap();
156:
157:            /** Determines whether the current location is a line comment
158:             *  @return true or false
159:             */
160:            public abstract boolean isLineComment();
161:
162:            /** Determines if current location is the beginning of a block comment
163:             * @return true or false
164:             */
165:            public abstract boolean isBlockCommentStart();
166:
167:            /** Determines whether the current location is the end of a block comment
168:             *  @return boolean
169:             */
170:            public abstract boolean isBlockCommentEnd();
171:
172:            /**
173:             * Determines whether the current location is a new line.
174:             * @return boolean
175:             */
176:            public abstract boolean isNewline();
177:
178:            /** Returns whether the current location is a slash
179:             * @return boolean
180:             */
181:            public abstract boolean isSlash();
182:
183:            /** Returns whether this is a star
184:             *  @return boolean
185:             */
186:            public abstract boolean isStar();
187:
188:            /** Returns whether this is a double quote
189:             *  @return boolean
190:             */
191:            public abstract boolean isDoubleQuote();
192:
193:            /** Returns whether this is a single quote
194:             *  @return boolean
195:             */
196:            public abstract boolean isSingleQuote();
197:
198:            /** Returns whether this is a double escape sequence
199:             *  @return boolean
200:             */
201:            public abstract boolean isDoubleEscapeSequence();
202:
203:            /** Returns whether this is a double escape
204:             *  @return boolean
205:             */
206:            public abstract boolean isDoubleEscape();
207:
208:            /** Returns whether this is an escaped single quote
209:             *  @return boolean
210:             */
211:            public abstract boolean isEscapedSingleQuote();
212:
213:            /** Return whether this is an escaped double quote
214:             *  @return boolean
215:             */
216:            public abstract boolean isEscapedDoubleQuote();
217:
218:            /** Increases the size of the gap.
219:             * @param delta
220:             */
221:            public abstract void grow(int delta);
222:
223:            /** Decreases the size of the gap.
224:             *  @param delta
225:             */
226:            public abstract void shrink(int delta);
227:
228:            /** Determines whether the current location is an opening parenthesis.
229:             *  @return boolean
230:             */
231:            public abstract boolean isOpen();
232:
233:            /** Determines whether the current location is a closing parenthesis.
234:             *  @return boolean
235:             */
236:            public abstract boolean isClosed();
237:
238:            /** Determines whether the current location is an open brace.
239:             * @return boolean
240:             */
241:            public abstract boolean isOpenBrace();
242:
243:            /** Determines whether the current location is a closed brace.
244:             *  @return boolean
245:             */
246:            public abstract boolean isClosedBrace();
247:        }
w_w___w___.j_a_va_2___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.