de.zeigermann.xpa
Class XMLTokenTypeManager

java.lang.Object
  |
  +--de.zeigermann.xpa.XMLTokenTypeManager

public class XMLTokenTypeManager
extends Object

The utility class XMLTokenTypeManager stores token type informations about all tags used in transformation. They are retrieved from the text file generated by the antlr tool along with the parser resp. treeparser files.


Field Summary
static String CDATA
          This is the name of the token that should be used for character data (unused, but reserved for future extensions).
static String COMMENT
          This is the name of the token that should be used for comments (unused, but reserved for future extensions).
static String PCDATA
          This is the name of the token that should be used for parseable character data.
static String PI
          This is the name of the token that should be used for processing instructions (unused, but reserved for future extensions).
static String WS
          This is the name of the token that should be used for ignorable whitespace
 
Constructor Summary
XMLTokenTypeManager()
           
 
Method Summary
 int getType(String token)
          Gets the type of a token as used by ANTLR parser that generated token type definition text.
 String getWildCardTag()
          Gets the name of the wildcard tag as described in setWildCardTag(java.lang.String).
 void insert(String token, int value)
          Inserts the name of a token along with its type.
 void parse(InputStream in)
          Parses that token type definition in text format generated by ANTLR using input stream in as input.
 void setWildCardTag(String wildCardTag)
          Sets the name of the token to be used as wildcard.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PCDATA

public static final String PCDATA
This is the name of the token that should be used for parseable character data.

See Also:
Constant Field Values

CDATA

public static final String CDATA
This is the name of the token that should be used for character data (unused, but reserved for future extensions).

See Also:
Constant Field Values

PI

public static final String PI
This is the name of the token that should be used for processing instructions (unused, but reserved for future extensions).

See Also:
Constant Field Values

COMMENT

public static final String COMMENT
This is the name of the token that should be used for comments (unused, but reserved for future extensions).

See Also:
Constant Field Values

WS

public static final String WS
This is the name of the token that should be used for ignorable whitespace

See Also:
Constant Field Values
Constructor Detail

XMLTokenTypeManager

public XMLTokenTypeManager()
Method Detail

parse

public void parse(InputStream in)
Parses that token type definition in text format generated by ANTLR using input stream in as input.

Parameters:
in - the input stream to read token type definition from
See Also:
getType(java.lang.String), setWildCardTag(java.lang.String), insert(java.lang.String, int)

setWildCardTag

public void setWildCardTag(String wildCardTag)
Sets the name of the token to be used as wildcard. Have a look at getType(java.lang.String) for definition and use. You should usually get along with the default one, and should not be forced to use this method.

Parameters:
wildCardTag - case insensitive name of the token
See Also:
getType(java.lang.String), getWildCardTag()

getWildCardTag

public String getWildCardTag()
Gets the name of the wildcard tag as described in setWildCardTag(java.lang.String).

See Also:
getType(java.lang.String), setWildCardTag(java.lang.String)

insert

public void insert(String token,
                   int value)
Inserts the name of a token along with its type. This method is usually called by underlying parser.

Parameters:
token - case insensitive name of the token
value - type of the token
See Also:
getType(java.lang.String)

getType

public int getType(String token)
Gets the type of a token as used by ANTLR parser that generated token type definition text. If it has not been defined by ANTLR parser three things can happen:
  1. name of token matches a token defined by ANTLR parser: its type is returned
  2. name of token matches WS which is not defined by ANTLR parser: Token.INVALID_TYPE will be returned as token manager supposes you do not care for whitespace in your grammar
  3. name of the token matches default wildcard token name or wildcard name defined by setWildCardTag(java.lang.String)
    • if this wildcard token name has been defined and is used by ANTLR parser its type will be returned
    • otherwise Token.INVALID_TYPE will be returned

Parameters:
token - case insensitive name of a token
Returns:
type of the token or fallback as described above
See Also:
setWildCardTag(java.lang.String), getWildCardTag(), insert(java.lang.String, int), parse(java.io.InputStream)


Copyright 1999-2003 Oliver Zeigermann. All Rights Reserved.