org.sf.codejen
Class TemplateConfigurationParser

java.lang.Object
  extended by org.apache.commons.digester.AbstractObjectCreationFactory
      extended by org.sf.codejen.TemplateConfigurationParser
All Implemented Interfaces:
ObjectCreationFactory

public class TemplateConfigurationParser
extends AbstractObjectCreationFactory

Parser to parse the codegen config.

Author:
Shane Ng

Field Summary
 
Fields inherited from class org.apache.commons.digester.AbstractObjectCreationFactory
digester
 
Constructor Summary
TemplateConfigurationParser()
           
 
Method Summary
 Object createObject(Attributes attrs)
           
static TemplateConfigurationParser getInstance()
           
 TemplateConfiguration parse(InputStream in)
          The main method to do the parsing.
 TemplateConfiguration parseFile(String fileName)
          Parses the file in specified file name.
 TemplateConfiguration parseResource(String resourceString)
          Parses the resource from class loader.
 TemplateConfiguration parseUrl(String urlString)
          Parses the file in specified URL.
 TemplateConfiguration parseUrl(URL url)
          Parses the file in specified URL.
 
Methods inherited from class org.apache.commons.digester.AbstractObjectCreationFactory
getDigester, setDigester
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateConfigurationParser

public TemplateConfigurationParser()
Method Detail

getInstance

public static TemplateConfigurationParser getInstance()

createObject

public Object createObject(Attributes attrs)
                    throws Exception
Specified by:
createObject in interface ObjectCreationFactory
Specified by:
createObject in class AbstractObjectCreationFactory
Throws:
Exception

parseResource

public TemplateConfiguration parseResource(String resourceString)
                                    throws IOException,
                                           SAXException
Parses the resource from class loader.

Parameters:
resourceString - resource string to be parsed.
Returns:
the codegen config.
Throws:
IOException - when error is encounter in file reading
SAXException - when error is encounter in config parsing

parseUrl

public TemplateConfiguration parseUrl(String urlString)
                               throws IOException,
                                      SAXException
Parses the file in specified URL.

Parameters:
urlString - URL string to be parsed.
Returns:
the codegen config.
Throws:
IOException - when error is encounter in file reading
SAXException - when error is encounter in config parsing

parseUrl

public TemplateConfiguration parseUrl(URL url)
                               throws IOException,
                                      SAXException
Parses the file in specified URL.

Parameters:
url - URL instance to be parsed.
Returns:
the codegen config.
Throws:
IOException - when error is encounter in file reading
SAXException - when error is encounter in config parsing

parseFile

public TemplateConfiguration parseFile(String fileName)
                                throws IOException,
                                       SAXException
Parses the file in specified file name.

Parameters:
fileName - codegen config file to be parsed.
Returns:
the codegen config.
Throws:
IOException - when error is encounter in file reading
SAXException - when error is encounter in config parsing

parse

public TemplateConfiguration parse(InputStream in)
                            throws IOException,
                                   SAXException
The main method to do the parsing. class attribute should be specified in config/template/postProcessor and config/template/modelExtractor. config/template/fileNameGenerator.

Attributes in config/include will be evaluated in this order:

  1. file
  2. url
  3. resource

Parameters:
in - input stream to be parsed.
Returns:
the codegen config.
Throws:
IOException - when error is encounter in file reading
SAXException - when error is encounter in config parsing