KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > rice > cs > drjava > model > definitions > reducedmodel > Gap


1 /*BEGIN_COPYRIGHT_BLOCK
2  *
3  * This file is part of DrJava. Download the current version of this project from http://www.drjava.org/
4  * or http://sourceforge.net/projects/drjava/
5  *
6  * DrJava Open Source License
7  *
8  * Copyright (C) 2001-2005 JavaPLT group at Rice University (javaplt@rice.edu). All rights reserved.
9  *
10  * Developed by: Java Programming Languages Team, Rice University, http://www.cs.rice.edu/~javaplt/
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13  * documentation files (the "Software"), to deal with the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
15  * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16  *
17  * - Redistributions of source code must retain the above copyright notice, this list of conditions and the
18  * following disclaimers.
19  * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
20  * following disclaimers in the documentation and/or other materials provided with the distribution.
21  * - Neither the names of DrJava, the JavaPLT, Rice University, nor the names of its contributors may be used to
22  * endorse or promote products derived from this Software without specific prior written permission.
23  * - Products derived from this software may not be called "DrJava" nor use the term "DrJava" as part of their
24  * names without prior written permission from the JavaPLT group. For permission, write to javaplt@rice.edu.
25  *
26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
27  * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28  * CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
29  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30  * WITH THE SOFTWARE.
31  *
32  *END_COPYRIGHT_BLOCK*/

33
34 package edu.rice.cs.drjava.model.definitions.reducedmodel;
35
36 /** A subclass of ReducedToken that represents sequences of non-special characters.
37  * @version $Id: Gap.java 3903 2006-07-05 20:03:06Z rcartwright $
38  */

39 class Gap extends ReducedToken {
40   private int _size;
41
42   /** Creates a new Gap.
43    * @param size the size of the gap
44    * @param state the state of the reduced model
45    */

46   Gap(int size, ReducedModelState state) {
47     super(state);
48     _size = size;
49   }
50
51   /** Gets the size of this gap.
52    * @return _size
53    */

54   public int getSize() { return _size; }
55
56   /** Gets the token type.
57    * @return the empty string
58    */

59   public String JavaDoc getType() { return ""; }
60
61   /** Blows up. The type of a Gap cannot be set.
62    * @param type the type to set to
63    * @throws RuntimeException always
64    */

65   public void setType(String JavaDoc type) {
66     throw new RuntimeException JavaDoc("Can't set type on Gap!");
67   }
68
69   /** Blows up. A Gap cannot be flipped.
70    * @throws RuntimeException always
71    */

72   public void flip() {
73     throw new RuntimeException JavaDoc("Can't flip a Gap!");
74   }
75
76   /** Increases the size of the gap.
77    * @param delta the amount by which the gap is augmented.
78    */

79   public void grow(int delta) {
80     if (delta >= 0)
81       _size += delta;
82   }
83
84   /** Decreases the size of the gap.
85    * @param delta the amount by which the gap is diminished.
86    */

87   public void shrink(int delta) {
88     if ((delta <= _size) && (delta >= 0)) _size -= delta;
89   }
90
91   /** Converts a Brace to a String. Used for debugging.
92    * @return the String representation of the Brace
93    */

94   public String JavaDoc toString() {
95 // String val = "Gap(size: "+_size+"): ";
96
final StringBuilder JavaDoc val = new StringBuilder JavaDoc();
97     int i;
98     for (i = 0; i < _size; i++) val.append(" _");
99     return val.toString();
100   }
101
102   /** Determines that this is not a multi-char brace.
103    * @return <code>false</code>
104    */

105   public boolean isMultipleCharBrace() { return false; }
106
107   /** Determines that this is a gap.
108    * @return <code>true</code>
109    */

110   public boolean isGap() { return true; }
111
112   /** Determines that this is not a line comment.
113    * @return <code>false</code>
114    */

115   public boolean isLineComment() { return false; }
116
117   /** Determines that this is not the start of a block comment.
118    * @return <code>false</code>
119    */

120   public boolean isBlockCommentStart() { return false; }
121
122   /** Determines that this is not the end of a block comment.
123    * @return <code>false</code>
124    */

125   public boolean isBlockCommentEnd() { return false; }
126
127   /** Determines that this is not a newline.
128    * @return <code>false</code>
129    */

130   public boolean isNewline() { return false; }
131
132   /** Determines that this is not a /.
133    * @return <code>false</code>
134    */

135   public boolean isSlash() { return false; }
136
137   /** Determines that this is not a *.
138    * @return <code>false</code>
139    */

140   public boolean isStar() { return false; }
141
142   /** Determines that this is not a ".
143    * @return <code>false</code>
144    */

145   public boolean isDoubleQuote() { return false; }
146
147   /** Determines that this is not a '.
148    * @return <code>false</code>
149    */

150   public boolean isSingleQuote() { return false; }
151
152   /** Determines that this is not a double escape sequence.
153    * @return <code>false</code>
154    */

155   public boolean isDoubleEscapeSequence() { return false; }
156
157   /** Determines that this is not a double escape.
158    * @return <code>false</code>
159    */

160   public boolean isDoubleEscape() { return false; }
161
162   /** Determines that this is not a \'.
163    * @return <code>false</code>
164    */

165   public boolean isEscapedSingleQuote() { return false; }
166
167   /** Determines that this is not a \".
168    * @return <code>false</code>
169    */

170   public boolean isEscapedDoubleQuote() { return false; }
171
172   /** Determines that this is not open.
173    * @return <code>false</code>
174    */

175   public boolean isOpen() { return false; }
176
177   /** Determines that this is not closed.
178    * @return <code>false</code>
179    */

180   public boolean isClosed() { return false; }
181
182   /** Determines that this is not a match.
183    * @param other the token to compare to
184    * @return <code>false</code>
185    */

186   public boolean isMatch(ReducedToken other) { return false; }
187
188   /** Determines that this is not an open brace.
189    * @return <code>false</code>
190    */

191   public boolean isOpenBrace() { return false; }
192
193   /** Determines that this is not a closed brace.
194    * @return <code>false</code>
195    */

196   public boolean isClosedBrace() { return false; }
197 }
198
Popular Tags