edu.rice.cs.drjava.model.definitions.reducedmodel
Interface BraceReduction

All Known Implementing Classes:
ReducedModelControl

public interface BraceReduction

The interface BraceReduction serves as the template for our reduced view of a java document, which stores only the information necessary for parenthesis matching.

Version:
$Id: BraceReduction.java,v 1.26 2002/03/15 08:51:11 csreis Exp $
Author:
JavaPLT

Method Summary
 int absOffset()
          Get the absolute character offset of the document represented by BraceReduction.
 int balanceBackward()
          Finds the open brace that matches the previous significant brace iff that brace is an closing brace.
 int balanceForward()
          Finds the closing brace that matches the next significant brace iff that brace is an open brace.
 ReducedToken currentToken()
          Get the current token in the BraceReduction.
 void delete(int count)
          Update the BraceReduction to reflect text deletion.
 int getDistToNextNewline()
          Gets distance to next new line.
 int getDistToPreviousNewline(int relativeLoc)
          Gets distance to enclosing new line
 gj.util.Vector getHighlightStatus(int start, int length)
          Return all highlight status info for text between the current location and current location + end.
 IndentInfo getIndentInformation()
          Gets the distance to the enclosing brace.
 ReducedModelState getStateAtCurrent()
          Get the state of the token at the current cursor position.
 void insertChar(char ch)
          Insert a character into the BraceReduction.
 void move(int count)
          Updates the BraceReduction to reflect cursor movement.
 void resetLocation()
          Resets the location of the walker in the comment list to where the current cursor is.
 String simpleString()
          A simplified toString() method.
 ReducedModelState stateAtRelLocation(int relLocation)
          Returns the state at the relLocation, where relLocation is the location relative to the walker
 

Method Detail

absOffset

public int absOffset()
Get the absolute character offset of the document represented by BraceReduction.

currentToken

public ReducedToken currentToken()
Get the current token in the BraceReduction.
Returns:
the current token

getStateAtCurrent

public ReducedModelState getStateAtCurrent()
Get the state of the token at the current cursor position.
Returns:
the current state

insertChar

public void insertChar(char ch)
Insert a character into the BraceReduction.
Parameters:
ch - the character to be inserted

move

public void move(int count)

Updates the BraceReduction to reflect cursor movement. Negative values move left from the cursor, positive values move right.

Parameters:
count - indicates the direction and magnitude of cursor movement

delete

public void delete(int count)

Update the BraceReduction to reflect text deletion.

Parameters:
count - indicates the size and direction of text deletion. Negative values delete text to the left of the cursor, positive values delete text to the right.

balanceForward

public int balanceForward()

Finds the closing brace that matches the next significant brace iff that brace is an open brace.

Returns:
the distance until the matching closing brace. On failure, returns -1.
See Also:
#nextBrace()

balanceBackward

public int balanceBackward()

Finds the open brace that matches the previous significant brace iff that brace is an closing brace.

Returns:
the distance until the matching open brace. On failure, returns -1.
See Also:
#previousBrace()

getIndentInformation

public IndentInfo getIndentInformation()
Gets the distance to the enclosing brace.

getDistToPreviousNewline

public int getDistToPreviousNewline(int relativeLoc)
Gets distance to enclosing new line

getDistToNextNewline

public int getDistToNextNewline()
Gets distance to next new line.

simpleString

public String simpleString()
A simplified toString() method.

getHighlightStatus

public gj.util.Vector getHighlightStatus(int start,
                                         int length)
Return all highlight status info for text between the current location and current location + end. This should collapse adjoining blocks with the same status into one.
Parameters:
start - The starting location of the area we want to get status of. The reduced model is already at this position, but the parameter is needed to determine the absolute positions needed in the HighlightStatus objects we return.
length - How far should we generate info for?

stateAtRelLocation

public ReducedModelState stateAtRelLocation(int relLocation)
Returns the state at the relLocation, where relLocation is the location relative to the walker
Parameters:
relLocation - distance from walker to get state at.

resetLocation

public void resetLocation()
Resets the location of the walker in the comment list to where the current cursor is.