scone.util.tokenstream
Class HtmlTagToken

java.lang.Object
  extended by adc.parser.HtmlTag
      extended by scone.util.tokenstream.HtmlTagToken
All Implemented Interfaces:
Token
Direct Known Subclasses:
HtmlScriptToken, HtmlStyleToken, LinkToken

public class HtmlTagToken
extends adc.parser.HtmlTag
implements Token

an HTML tag.

Author:
Harald Weinreich, Volkert Buchmann

Field Summary
static java.lang.String COPYRIGHT
           
protected  adc.parser.HtmlTag tag
          the tag
protected  java.lang.String whiteSpaces
          preceding whitespaces
 
Fields inherited from class adc.parser.HtmlTag
P_ALIGN, P_BACKGROUND, P_BORDER, P_CHECKED, P_CLEAR, P_CODE, P_COLS, P_COLSPAN, P_FACE, P_HEIGHT, P_HREF, P_LANGUAGE, P_LOWSRC, P_MAXLENGTH, P_MULTIPLE, P_NAME, P_ROWS, P_ROWSPAN, P_SIZE, P_SRC, P_TARGET, P_TYPE, P_VALUE, P_WIDTH, T__DOCTYPE, T_A, T_ABBREV, T_ACRONYM, T_ADDRESS, T_APPLET, T_AREA, T_AU, T_B, T_BANNER, T_BASE, T_BASEFONT, T_BGSOUND, T_BIG, T_BLINK, T_BLOCKQUOTE, T_BODY, T_BR, T_CAPTION, T_CENTER, T_CITE, T_CODE, T_COL, T_COLGROUP, T_CREDIT, T_DD, T_DEL, T_DFN, T_DIR, T_DIV, T_DL, T_DT, T_EM, T_EMBED, T_FIG, T_FN, T_FONT, T_FORM, T_FRAME, T_FRAMESET, T_H1, T_H2, T_H3, T_H4, T_H5, T_H6, T_HEAD, T_HR, T_HTML, T_I, T_IFRAME, T_IMG, T_INPUT, T_INS, T_ISINDEX, T_KBD, T_LANG, T_LH, T_LI, T_LINK, T_MAP, T_MARQUEE, T_MENU, T_META, T_NEXTID, T_NOBR, T_NOEMBED, T_NOFRAME, T_NOFRAMES, T_NOTE, T_OBJECT, T_OL, T_OPTION, T_OVERLAY, T_P, T_PARAM, T_PERSON, T_PRE, T_Q, T_RANGE, T_S, T_SAMP, T_SCRIPT, T_SELECT, T_SMALL, T_SPOT, T_STRONG, T_STYLE, T_SUB, T_SUP, T_TAB, T_TABLE, T_TBODY, T_TD, T_TEXTAREA, T_TFOOT, T_TH, T_THEAD, T_TITLE, T_TR, T_TT, T_U, T_UL, T_UNKNOWN, T_VAR, T_WBR
 
Constructor Summary
protected HtmlTagToken()
           
  HtmlTagToken(adc.parser.HtmlTag tag, java.lang.StringBuffer whiteSpaces)
          creates a HtmlTagToken
  HtmlTagToken(java.lang.String tagType)
          creates an empty HtmlTagToken of the specified type.
 
Method Summary
 Token getClone()
          returns a clone of this Token
 int getIntParam(java.lang.String name)
          returns the vlaue of the specified parameter as an int
 java.lang.String getParam(java.lang.String name)
          Looks up a tag param name and returns the associated value, if any.
 java.lang.String getTagString()
          returns the tag name, for example table
 int getTagType()
          returns the type of the tag.
 java.lang.String getWhiteSpaces()
          returns the preceding whitespaces of the tag
 boolean hasParam(java.lang.String name)
          returns true if this tag has the specified parameter
 boolean isEndTag()
          returns true if this tag is an end tag
 boolean isInBody()
          returns true if the tag type is h1-4, table, a, area, img, form, or pre
 void removeParam(java.lang.String name)
          Remove association of a param name with a value.
 void setParam(java.lang.String name, java.lang.String value)
          Associates a param name with a value.
 void setParam(java.lang.String name, java.lang.String value, java.lang.String originalName)
          Associates a param name with a value, preserving the original name.
 java.lang.String toString()
          returns a string representation of the tag, preceded by the whitespaces
 
Methods inherited from class adc.parser.HtmlTag
reset, setTag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
See Also:
Constant Field Values

whiteSpaces

protected java.lang.String whiteSpaces
preceding whitespaces


tag

protected adc.parser.HtmlTag tag
the tag

Constructor Detail

HtmlTagToken

protected HtmlTagToken()

HtmlTagToken

public HtmlTagToken(adc.parser.HtmlTag tag,
                    java.lang.StringBuffer whiteSpaces)
creates a HtmlTagToken

Parameters:
tag - the tag
whiteSpaces - preceding whitespaces

HtmlTagToken

public HtmlTagToken(java.lang.String tagType)
creates an empty HtmlTagToken of the specified type.

Parameters:
tagType - the type of the tag
Method Detail

getClone

public Token getClone()
returns a clone of this Token

Specified by:
getClone in interface Token
Returns:
the clone

getTagType

public int getTagType()
returns the type of the tag. see adc.parser.HtmlTag for tag type constants

Overrides:
getTagType in class adc.parser.HtmlTag
Returns:
tag type, e.g. one of the T_ constants.

getTagString

public java.lang.String getTagString()
returns the tag name, for example table

Overrides:
getTagString in class adc.parser.HtmlTag
Returns:
tag name, the same name as passed to the constructor.

isEndTag

public boolean isEndTag()
returns true if this tag is an end tag

Overrides:
isEndTag in class adc.parser.HtmlTag
Returns:
true if this is an end tag or not, i.e. if the tag has a slash before the name.

getParam

public java.lang.String getParam(java.lang.String name)
Looks up a tag param name and returns the associated value, if any.

Overrides:
getParam in class adc.parser.HtmlTag
Parameters:
name - name of param, must be lowercase
Returns:
the value associated with the name, or null.

hasParam

public boolean hasParam(java.lang.String name)
returns true if this tag has the specified parameter

Overrides:
hasParam in class adc.parser.HtmlTag
Parameters:
name - the name of the tag in lower case
Returns:
true if the parameter exists

getIntParam

public int getIntParam(java.lang.String name)
                throws java.lang.NumberFormatException
returns the vlaue of the specified parameter as an int

Overrides:
getIntParam in class adc.parser.HtmlTag
Parameters:
name - the name of the parameter, must be lower case
Returns:
the value of the parameter as an int (if possible)
Throws:
java.lang.NumberFormatException

setParam

public void setParam(java.lang.String name,
                     java.lang.String value)
Associates a param name with a value.

Overrides:
setParam in class adc.parser.HtmlTag
Parameters:
name - name of param, must be a lowercase name
value - value associated with name

setParam

public void setParam(java.lang.String name,
                     java.lang.String value,
                     java.lang.String originalName)
Associates a param name with a value, preserving the original name.

Overrides:
setParam in class adc.parser.HtmlTag
Parameters:
name - name of param, the convention is to use a lowercase name
value - value associated with name
originalName - preserve the orginal case of name

removeParam

public void removeParam(java.lang.String name)
Remove association of a param name with a value.

Overrides:
removeParam in class adc.parser.HtmlTag
Parameters:
name - name of param to remove, the convention is to use a lowercase name

getWhiteSpaces

public java.lang.String getWhiteSpaces()
returns the preceding whitespaces of the tag

Returns:
the whitespaces

toString

public java.lang.String toString()
returns a string representation of the tag, preceded by the whitespaces

Overrides:
toString in class adc.parser.HtmlTag
Returns:
the tag as a String

isInBody

public boolean isInBody()
returns true if the tag type is h1-4, table, a, area, img, form, or pre

Returns:
whether the tag is expected to be in the body