rabbit.html
Class Token

java.lang.Object
  extended by rabbit.html.Token

public class Token
extends Object

This class is used to describe a small part of a html page. A small part is the text between the tags, a tag, a comment or a script.

Author:
Robert Olofsson

Constructor Summary
Token(char[] page, TokenType type, int startindex, int len)
          Create a new Token with given arguments.
Token(String text)
          Create a new Token of type TEXT with given text.
Token(String text, TokenType type, int startindex)
          Create a new Token with given arguments.
Token(Tag tag)
          Create a new Token of type Tag with given Tag.
Token(Tag tag, boolean changed)
          Create a new Token of type Tag with given Tag.
Token(Tag tag, int startindex)
          Create a new Token with given arguments and of type TAG.
 
Method Summary
 void empty()
          Empty this token, That is set its type to EMPTY and set the text and tag to null.
 boolean getChanged()
          Has this Token changed since it was created?
 int getLength()
          Get the length of this token.
 int getStartIndex()
          Get the start index of this Token.
 Tag getTag()
          Get the tag of this token.
 String getText()
          Get the text of this token.
 TokenType getType()
          Get the type of this token.
 void setChanged(boolean changed)
          Set the change value of this Token.
 void setStartIndex(int startindex)
          Set the start index of this Token.
 void setTag(Tag tag)
          Set the tag of this token, also set the type to TAG.
 void setText(String text)
          Set the text of this Token, also sets the type to TEXT.
 String toString()
          Get the String representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Token

public Token(String text)
Create a new Token of type TEXT with given text.

Parameters:
text - the String of this Token.

Token

public Token(Tag tag)
Create a new Token of type Tag with given Tag.

Parameters:
tag - the Tag of this Token.

Token

public Token(Tag tag,
             boolean changed)
Create a new Token of type Tag with given Tag.

Parameters:
tag - the Tag of this Token.
changed - if true this tag is considered changed, if false this tag is unmodified.

Token

public Token(String text,
             TokenType type,
             int startindex)
Create a new Token with given arguments.

Parameters:
text - the text of this Token.
type - the type of this token.
startindex - the start index of this token.

Token

public Token(char[] page,
             TokenType type,
             int startindex,
             int len)
Create a new Token with given arguments.

Parameters:
page - the text of this Token.
type - the type of this token.
startindex - the start index of this token.
len - the length of this token.

Token

public Token(Tag tag,
             int startindex)
Create a new Token with given arguments and of type TAG.

Parameters:
tag - the Tag of this Token.
startindex - the start index of this token.
Method Detail

getTag

public Tag getTag()
Get the tag of this token.

Returns:
the Tag or null if type is other than TAG.

setTag

public void setTag(Tag tag)
Set the tag of this token, also set the type to TAG.

Parameters:
tag - the Tag to hold.

getText

public String getText()
Get the text of this token.

Returns:
the text or null if type is other than TEXT.

setText

public void setText(String text)
Set the text of this Token, also sets the type to TEXT.

Parameters:
text - the text of this token.

getType

public TokenType getType()
Get the type of this token.

Returns:
the type of this token.

getChanged

public boolean getChanged()
Has this Token changed since it was created?

Returns:
true if this Token has changed, false otherwise.

setChanged

public void setChanged(boolean changed)
Set the change value of this Token.

Parameters:
changed - the new change value of this Token.

getStartIndex

public int getStartIndex()
Get the start index of this Token.

Returns:
the start index.

setStartIndex

public void setStartIndex(int startindex)
Set the start index of this Token.

Parameters:
startindex - the new startindex.

getLength

public int getLength()
Get the length of this token.


empty

public void empty()
Empty this token, That is set its type to EMPTY and set the text and tag to null.


toString

public String toString()
Get the String representation of this object.

Overrides:
toString in class Object
Returns:
a String representation of this object.