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

java.lang.Object
  extended by edu.rice.cs.drjava.model.definitions.reducedmodel.ReducedToken
All Implemented Interfaces:
ReducedModelStates

public abstract class ReducedToken
extends Object
implements ReducedModelStates

The representation of document text in the reduced model. ReducedToken :: = Brace | Gap

Version:
$Id: ReducedToken.java 4519 2008-06-15 07:14:29Z rcartwright $

Field Summary
 
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
ReducedToken(ReducedModelState state)
           
 
Method Summary
abstract  void flip()
          Return the opposite of this ReducedToken in the same state.
 int getHighlightState()
          Returns whether the current char is highlighted.
abstract  int getSize()
          Get the size of the token.
 ReducedModelState getState()
          Get the shadowing state of the token.
abstract  String getType()
          Get the type of the token.
abstract  void grow(int delta)
          Increases the size of the gap.
abstract  boolean isBlockCommentEnd()
          Determines whether the current location is the end of a block comment
abstract  boolean isBlockCommentStart()
          Determines if current location is the beginning of a block comment
abstract  boolean isClosed()
          Determines whether the current location is a closing parenthesis.
abstract  boolean isClosedBrace()
          Determines whether the current location is a closed brace.
 boolean isCommentStart()
          Determine whether this token is a comment start "brace" ("//" or "/*')
abstract  boolean isDoubleEscape()
          Returns whether this is a double escape
abstract  boolean isDoubleEscapeSequence()
          Returns whether this is a double escape sequence
abstract  boolean isDoubleQuote()
          Returns whether this is a double quote
abstract  boolean isEscapedDoubleQuote()
          Return whether this is an escaped double quote
abstract  boolean isEscapedSingleQuote()
          Returns whether this is an escaped single quote
abstract  boolean isGap()
          Determines whether the current location is within in gap.
abstract  boolean isLineComment()
          Determines whether the current location is a line comment
abstract  boolean isMatch(edu.rice.cs.drjava.model.definitions.reducedmodel.Brace other)
          Determine if the given token is a open/close match with this.
abstract  boolean isMatchable()
          Return true iff this ReducedToken is a matchable, i.e.
abstract  boolean isMultipleCharBrace()
          Determines whether the current location is part of a multiple char brace.
abstract  boolean isNewline()
          Determines whether the current location is a new line.
abstract  boolean isOpen()
          Determines whether the current location is an opening parenthesis.
abstract  boolean isOpenBrace()
          Determines whether the current location is an open brace.
 boolean isQuoted()
          Indicates whether this brace is inside quotes.
 boolean isShadowed()
          Indicates whether this brace is shadowed.
abstract  boolean isSingleQuote()
          Returns whether this is a single quote
abstract  boolean isSlash()
          Returns whether the current location is a slash
abstract  boolean isStar()
          Returns whether this is a star
 void setState(ReducedModelState state)
          Set the shadowing state of the token.
abstract  void setType(String type)
          Set the type of the token
abstract  void shrink(int delta)
          Decreases the size of the gap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReducedToken

public ReducedToken(ReducedModelState state)
Method Detail

getSize

public abstract int getSize()
Get the size of the token.

Returns:
the number of characters represented by the token

getType

public abstract String getType()
Get the type of the token.

Returns:
a String representation of the token type

setType

public abstract void setType(String type)
Set the type of the token

Parameters:
type - a String representation of the new token type

flip

public abstract void flip()
Return the opposite of this ReducedToken in the same state. Valid only for braces.


isMatch

public abstract boolean isMatch(edu.rice.cs.drjava.model.definitions.reducedmodel.Brace other)
Determine if the given token is a open/close match with this.

Parameters:
other - another ReducedToken
Returns:
true if there is a match

isMatchable

public abstract boolean isMatchable()
Return true iff this ReducedToken is a matchable, i.e. is one of "{", "}", "(", ")", "[", "]"


getState

public ReducedModelState getState()
Get the shadowing state of the token.

Returns:
FREE | INSIDE_SINGLE_QUOTE | INSIDE_DOUBLE_QUOTE | INSIDE_LINE_COMMENT| INSIDE_BLOCK_COMMENT

getHighlightState

public int getHighlightState()
Returns whether the current char is highlighted. / / beginning a comment would be highlighted but free, so its not the same as getState.


setState

public void setState(ReducedModelState state)
Set the shadowing state of the token.

Parameters:
state -

grow

public abstract void grow(int delta)
Increases the size of the gap.

Parameters:
delta -

shrink

public abstract void shrink(int delta)
Decreases the size of the gap.

Parameters:
delta -

isShadowed

public boolean isShadowed()
Indicates whether this brace is shadowed. Shadowing occurs when a brace has been swallowed by a comment or an open quote.

Returns:
true if the brace is shadowed.

isQuoted

public boolean isQuoted()
Indicates whether this brace is inside quotes.

Returns:
true if the brace is inside quotes.

isMultipleCharBrace

public abstract boolean isMultipleCharBrace()
Determines whether the current location is part of a multiple char brace.

Returns:
true or false

isGap

public abstract boolean isGap()
Determines whether the current location is within in gap.

Returns:
true or false

isLineComment

public abstract boolean isLineComment()
Determines whether the current location is a line comment

Returns:
true or false

isBlockCommentStart

public abstract boolean isBlockCommentStart()
Determines if current location is the beginning of a block comment

Returns:
true or false

isBlockCommentEnd

public abstract boolean isBlockCommentEnd()
Determines whether the current location is the end of a block comment

Returns:
boolean

isNewline

public abstract boolean isNewline()
Determines whether the current location is a new line.

Returns:
boolean

isSlash

public abstract boolean isSlash()
Returns whether the current location is a slash

Returns:
boolean

isStar

public abstract boolean isStar()
Returns whether this is a star

Returns:
boolean

isDoubleQuote

public abstract boolean isDoubleQuote()
Returns whether this is a double quote

Returns:
boolean

isSingleQuote

public abstract boolean isSingleQuote()
Returns whether this is a single quote

Returns:
boolean

isDoubleEscapeSequence

public abstract boolean isDoubleEscapeSequence()
Returns whether this is a double escape sequence

Returns:
boolean

isDoubleEscape

public abstract boolean isDoubleEscape()
Returns whether this is a double escape

Returns:
boolean

isEscapedSingleQuote

public abstract boolean isEscapedSingleQuote()
Returns whether this is an escaped single quote

Returns:
boolean

isEscapedDoubleQuote

public abstract boolean isEscapedDoubleQuote()
Return whether this is an escaped double quote

Returns:
boolean

isOpen

public abstract boolean isOpen()
Determines whether the current location is an opening parenthesis.

Returns:
boolean

isClosed

public abstract boolean isClosed()
Determines whether the current location is a closing parenthesis.

Returns:
boolean

isOpenBrace

public abstract boolean isOpenBrace()
Determines whether the current location is an open brace.

Returns:
boolean

isClosedBrace

public abstract boolean isClosedBrace()
Determines whether the current location is a closed brace.

Returns:
boolean

isCommentStart

public boolean isCommentStart()
Determine whether this token is a comment start "brace" ("//" or "/*')