de.zeigermann.xpa.treeParser
Class XMLASTFactory

java.lang.Object
  |
  +--antlr.ASTFactory
        |
        +--de.zeigermann.xpa.treeParser.XMLASTFactory

public class XMLASTFactory
extends ASTFactory

This class replaces ANTLRs default ASTFactory to make creation of XMLASTs possible for all kinds of sources.

You must set it in your parsers and tree parsers using Parser.setASTFactory(antlr.ASTFactory) resp. TreeParser.setASTFactory(antlr.ASTFactory) to create the right AST classes.


Field Summary
protected  Parser2XMLASTAdapter parser
           
 
Fields inherited from class antlr.ASTFactory
theASTNodeType, theASTNodeTypeClass, tokenTypeToASTClassMap
 
Constructor Summary
XMLASTFactory(Parser2XMLASTAdapter parser)
          Creates a new XMLASTFactory for XMLAST creation.
 
Method Summary
 AST create()
          Creates an empty XMLAST.
 AST create(AST tr)
          Creates a copy of an AST.
 AST create(int type)
          Creates a new XMLAST with text ""
 AST create(int type, String txt)
          Creates a new XMLAST.
 AST create(String txt)
          Creates an XMLAST from a string.
 AST create(Token tok)
          Creates a new AST from a Token.
 AST create(XMLAST xa)
          Creates a copy of an XMLAST.
 AST create(XMLStartAST xa)
          Creates a copy of an XMLStartAST.
 void setParser(Parser2XMLASTAdapter parser)
          Sets the parser to create XMLASTs from strings.
 
Methods inherited from class antlr.ASTFactory
addASTChild, create, create, create, createUsingCtor, dup, dupList, dupTree, error, getASTNodeType, getTokenTypeToASTClassMap, make, make, makeASTRoot, setASTNodeClass, setASTNodeType, setTokenTypeASTNodeType, setTokenTypeToASTClassMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parser

protected Parser2XMLASTAdapter parser
Constructor Detail

XMLASTFactory

public XMLASTFactory(Parser2XMLASTAdapter parser)
Creates a new XMLASTFactory for XMLAST creation. This factory needs an XML parser to create XMLASTs from strings.

Parameters:
parser - the parser used to create XMLASTs from strings
Method Detail

setParser

public void setParser(Parser2XMLASTAdapter parser)
Sets the parser to create XMLASTs from strings.

Parameters:
parser - the parser used to create XMLASTs from strings

create

public AST create(XMLAST xa)
Creates a copy of an XMLAST.


create

public AST create(XMLStartAST xa)
Creates a copy of an XMLStartAST.


create

public AST create(AST tr)
Creates a copy of an AST. As there is no dynamic dispatch over parameters, we need to simulate it here. If the given AST is of type XMLAST or XMLStartAST this method delegates this call to create(XMLAST) resp. create(XMLStartAST). Otherwise the method of the super class will be called.

Overrides:
create in class ASTFactory

create

public AST create(String txt)
Creates an XMLAST from a string. To create the AST this method parses the string using the parser set with setParser(de.zeigermann.xpa.treeParser.Parser2XMLASTAdapter).

Overrides:
create in class ASTFactory
Returns:
XMLAST generated by parser or null if parsing failes
See Also:
setParser(de.zeigermann.xpa.treeParser.Parser2XMLASTAdapter)

create

public AST create()
Creates an empty XMLAST.

Overrides:
create in class ASTFactory

create

public AST create(int type,
                  String txt)
Creates a new XMLAST.

Overrides:
create in class ASTFactory
Parameters:
type - the type of the newly created XMLAST

create

public AST create(int type)
Creates a new XMLAST with text ""

Overrides:
create in class ASTFactory
Parameters:
type - the type of the newly created XMLAST

create

public AST create(Token tok)
Creates a new AST from a Token. As with create(AST) we have the problem there is no dynamic dispatch over parameters. If the given Token is of type XMLToken or XMLStartToken this method creates a new XMLAST resp. XMLStartAST. If it is an XMLEndToken an empty XMLAST will be created, as no end tags are allowed. In all other cases the method of the super class will be called.

Overrides:
create in class ASTFactory
See Also:
create(AST)


Copyright © 1999-2003 Oliver Zeigermann. All Rights Reserved.