edu.rice.cs.drjava.model.definitions.reducedmodel
Class Brace

java.lang.Object
  |
  +--edu.rice.cs.drjava.model.definitions.reducedmodel.ReducedToken
        |
        +--edu.rice.cs.drjava.model.definitions.reducedmodel.Brace
All Implemented Interfaces:
ReducedModelStates

class Brace
extends ReducedToken
implements ReducedModelStates

This class acts as the representation of a brace in the reduced view. It also includes information about the gap of plaintext preceding the actual brace before the previous brace or the start of the file.

Version:
$Id: Brace.java,v 1.17 2002/08/10 23:52:51 cmcgraw Exp $

Field Summary
protected  int _type
          the type of the brace
static String BLK_CMT_BEG
           
static String BLK_CMT_END
           
static String[] braces
          An array of the special characters that signify areas of text other than gaps.
static String DOUBLE_QUOTE
           
static String EOLN
           
static String LINE_CMT
           
static String SINGLE_QUOTE
           
static String SLASH
           
static String STAR
           
 
Fields inherited from class edu.rice.cs.drjava.model.definitions.reducedmodel.ReducedToken
_state
 
Fields inherited from interface edu.rice.cs.drjava.model.definitions.reducedmodel.ReducedModelStates
FREE, INSIDE_BLOCK_COMMENT, INSIDE_DOUBLE_QUOTE, INSIDE_LINE_COMMENT, INSIDE_SINGLE_QUOTE, STUTTER
 
Constructor Summary
private Brace(int type, ReducedModelState state)
          Constructor.
 
Method Summary
protected static int findBrace(String type)
          Determine the brace type of a given String.
 void flip()
          Flips the orientation of the brace.
 int getSize()
          Get the size of the token.
 String getType()
          Get the text of the brace.
 void grow(int delta)
          Braces can't grow.
 boolean isBlockCommentEnd()
          7
 boolean isBlockCommentStart()
          put your documentation comment here
 boolean isClosed()
          Indicates whether this is a closing brace.
 boolean isClosedBrace()
          put your documentation comment here
 boolean isDoubleEscape()
          put your documentation comment here
 boolean isDoubleEscapeSequence()
          put your documentation comment here
 boolean isDoubleQuote()
          put your documentation comment here
 boolean isEscapedDoubleQuote()
          put your documentation comment here
 boolean isEscapedSingleQuote()
          put your documentation comment here
 boolean isGap()
          Implementation of abstract function.
 boolean isLineComment()
          put your documentation comment here
 boolean isMatch(ReducedToken other)
          Check if two braces match.
 boolean isMultipleCharBrace()
          put your documentation comment here
 boolean isNewline()
          put your documentation comment here
 boolean isOpen()
          Indicates whether this is an opening brace.
 boolean isOpenBrace()
          put your documentation comment here
 boolean isSingleQuote()
          put your documentation comment here
 boolean isSlash()
          put your documentation comment here
 boolean isStar()
          put your documentation comment here
static Brace MakeBrace(String type, ReducedModelState state)
          Virtual constructor.
 void setType(String type)
          Reset the type of this brace.
 void shrink(int delta)
          Braces can't shrink.
 String toString()
          Converts a Brace to a String.
 
Methods inherited from class edu.rice.cs.drjava.model.definitions.reducedmodel.ReducedToken
getHighlightState, getState, isCommented, isInBlockComment, isInLineComment, isQuoted, isShadowed, setState
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

braces

public static final String[] braces
An array of the special characters that signify areas of text other than gaps. This really isn't the best datastructure to hold this information; there is more structure to the elements than a flat array. Specifically, matching characters are placed next to each other (except for the trailing elements, which have no matches). Notice that single and double quotes match themselves.
See Also:
String

BLK_CMT_BEG

public static final String BLK_CMT_BEG

BLK_CMT_END

public static final String BLK_CMT_END

EOLN

public static final String EOLN

LINE_CMT

public static final String LINE_CMT

SINGLE_QUOTE

public static final String SINGLE_QUOTE

DOUBLE_QUOTE

public static final String DOUBLE_QUOTE

STAR

public static final String STAR

SLASH

public static final String SLASH

_type

protected int _type
the type of the brace
Constructor Detail

Brace

private Brace(int type,
              ReducedModelState state)
Constructor.
Parameters:
type - the brace type
width - the size of the brace and its gap
Method Detail

MakeBrace

public static Brace MakeBrace(String type,
                              ReducedModelState state)
Virtual constructor. This method throws an exception if the given type is not a valid brace type.
Parameters:
type - the brace text
state - whether the brace is shadwowed by a comment, quote etc
Returns:
a new Brace if type is valid, otherwise null

getType

public String getType()
Get the text of the brace.
Overrides:
getType in class ReducedToken
Returns:
the text of the Brace

getSize

public int getSize()
Description copied from class: ReducedToken
Get the size of the token.
Overrides:
getSize in class ReducedToken
Returns:
the size of the brace and its preceding gap

toString

public String toString()
Converts a Brace to a String. Used for debugging.
Overrides:
toString in class Object
Returns:
the string representation of the Brace.

flip

public void flip()
Flips the orientation of the brace. Useful for updating quote information.
Overrides:
flip in class ReducedToken

isOpen

public boolean isOpen()
Indicates whether this is an opening brace.
Overrides:
isOpen in class ReducedToken
Returns:
true if the brace is an opening brace.

isOpenBrace

public boolean isOpenBrace()
Description copied from class: ReducedToken
put your documentation comment here
Overrides:
isOpenBrace in class ReducedToken
Returns:
true if this is {|(|[

isClosedBrace

public boolean isClosedBrace()
Description copied from class: ReducedToken
put your documentation comment here
Overrides:
isClosedBrace in class ReducedToken
Returns:
true if this is }|)|]

isClosed

public boolean isClosed()
Indicates whether this is a closing brace.
Overrides:
isClosed in class ReducedToken
Returns:
true if the brace is a closing brace.

setType

public void setType(String type)
Reset the type of this brace.
Overrides:
setType in class ReducedToken
Parameters:
type - the new String type for the brace

findBrace

protected static int findBrace(String type)
Determine the brace type of a given String. The integer value returned is only used internally. Externally, the brace shows the text as its "type".
Parameters:
type - the text of the brace
Returns:
an integer indicating the type of brace

isMatch

public boolean isMatch(ReducedToken other)
Check if two braces match.
Overrides:
isMatch in class ReducedToken
Parameters:
other - the brace to compare
Returns:
true if this is a match for other.

isDoubleQuote

public boolean isDoubleQuote()
Description copied from class: ReducedToken
put your documentation comment here
Overrides:
isDoubleQuote in class ReducedToken
Returns:
true if this is a quote

isSingleQuote

public boolean isSingleQuote()
Description copied from class: ReducedToken
put your documentation comment here
Overrides:
isSingleQuote in class ReducedToken
Following copied from class: edu.rice.cs.drjava.model.definitions.reducedmodel.ReducedToken
Returns:
 

isLineComment

public boolean isLineComment()
Description copied from class: ReducedToken
put your documentation comment here
Overrides:
isLineComment in class ReducedToken
Returns:
true if this is a line comment delimiter

isBlockCommentStart

public boolean isBlockCommentStart()
Description copied from class: ReducedToken
put your documentation comment here
Overrides:
isBlockCommentStart in class ReducedToken
Returns:
true if this is a block comment open delimiter

isBlockCommentEnd

public boolean isBlockCommentEnd()
7
Overrides:
isBlockCommentEnd in class ReducedToken
Returns:
true if this is a block comment close delimiter

isNewline

public boolean isNewline()
Description copied from class: ReducedToken
put your documentation comment here
Overrides:
isNewline in class ReducedToken
Returns:
true if this is a newline delimiter

isMultipleCharBrace

public boolean isMultipleCharBrace()
Description copied from class: ReducedToken
put your documentation comment here
Overrides:
isMultipleCharBrace in class ReducedToken
Returns:
true if this is a multiple character brace

isDoubleEscapeSequence

public boolean isDoubleEscapeSequence()
Description copied from class: ReducedToken
put your documentation comment here
Overrides:
isDoubleEscapeSequence in class ReducedToken
Returns:
true if this is \\ or \"

isDoubleEscape

public boolean isDoubleEscape()
Description copied from class: ReducedToken
put your documentation comment here
Overrides:
isDoubleEscape in class ReducedToken
Returns:
true if this is \\

isEscapedDoubleQuote

public boolean isEscapedDoubleQuote()
Description copied from class: ReducedToken
put your documentation comment here
Overrides:
isEscapedDoubleQuote in class ReducedToken
Returns:
true if this is \"

isEscapedSingleQuote

public boolean isEscapedSingleQuote()
Description copied from class: ReducedToken
put your documentation comment here
Overrides:
isEscapedSingleQuote in class ReducedToken
Returns:
true if this is \'

isGap

public boolean isGap()
Implementation of abstract function. Braces, of course, are never Gaps.
Overrides:
isGap in class ReducedToken
Returns:
false

isSlash

public boolean isSlash()
Description copied from class: ReducedToken
put your documentation comment here
Overrides:
isSlash in class ReducedToken
Returns:
true if this is /

isStar

public boolean isStar()
Description copied from class: ReducedToken
put your documentation comment here
Overrides:
isStar in class ReducedToken
Returns:
true if this is *

grow

public void grow(int delta)
Braces can't grow.
Overrides:
grow in class ReducedToken
Throws:
RuntimeException -  

shrink

public void shrink(int delta)
Braces can't shrink.
Overrides:
shrink in class ReducedToken
Throws:
RuntimeException -