KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.Vector JavaDoc;
37
38 /**
39  * The interface BraceReduction serves as the template for our reduced
40  * view of a java document, which stores only the information necessary
41  * for parenthesis matching.
42  * @version $Id: BraceReduction.java 4043 2006-11-22 23:04:59Z rcartwright $
43  * @author JavaPLT
44  */

45
46 public interface BraceReduction {
47   /**
48    * Get the absolute character offset of the document represented by BraceReduction.
49    */

50   public int absOffset();
51
52   /**
53    * Get the current token in the BraceReduction.
54    * @return the current token
55    */

56   ReducedToken currentToken();
57
58   /**
59    * Get the state of the token at the current cursor position.
60    * @return the current state
61    */

62   ReducedModelState getStateAtCurrent();
63
64   /**
65    * Insert a character into the BraceReduction.
66    * @param ch the character to be inserted
67    */

68   public void insertChar(char ch);
69
70   /**
71    * <P>Updates the BraceReduction to reflect cursor movement.
72    * Negative values move left from the cursor, positive values move
73    * right. </P>
74    * @param count indicates the direction and magnitude of cursor movement
75    */

76   public void move( int count );
77
78   /**
79    * <P>Update the BraceReduction to reflect text deletion.</P>
80    * @param count indicates the size and direction of text deletion.
81    * Negative values delete text to the left of the cursor, positive
82    * values delete text to the right.
83    */

84   public void delete( int count );
85
86
87   /**
88    * <P>Finds the closing brace that matches the next significant
89    * brace iff that brace is an open brace.</P>
90    * @return the distance until the matching closing brace. On
91    * failure, returns -1.
92    * @see #balanceBackward()
93    */

94   public int balanceForward();
95
96   /**
97    * <P>Finds the open brace that matches the previous significant
98    * brace iff that brace is an closing brace.</P>
99    * @return the distance until the matching open brace. On
100    * failure, returns -1.
101    * @see #balanceForward()
102    */

103   public int balanceBackward();
104
105   /** Gets the distance to the enclosing brace. */
106   public IndentInfo getIndentInformation();
107
108   /** Gets distance to enclosing new line */
109   public int getDistToPreviousNewline(int relativeLoc);
110
111   /** Gets distance to next new line. */
112   public int getDistToNextNewline();
113
114   /** A simplified toString() method. */
115   public String JavaDoc simpleString();
116
117   /**
118    * Return all highlight status info for text between the current
119    * location and current location + end.
120    * This should collapse adjoining blocks with the same status into one.
121    * @param start The starting location of the area we want to get status of.
122    * The reduced model is already at this position, but the
123    * parameter is needed to determine the absolute positions
124    * needed in the HighlightStatus objects we return.
125    * @param length How far should we generate info for?
126    */

127   public Vector JavaDoc<HighlightStatus> getHighlightStatus(int start, int length);
128
129   /**
130    *Returns the state at the relLocation, where relLocation is the location
131    *relative to the walker
132    *@param relLocation distance from walker to get state at.
133    */

134   public ReducedModelState moveWalkerGetState(int relLocation);
135
136   /**
137    * Resets the location of the walker in the comment list to where the
138    * current cursor is.
139    */

140   public void resetLocation();
141 }
142
Popular Tags