com.mcdermottroe.exemplar.output.java.binding
Class Generator

java.lang.Object
  extended by com.mcdermottroe.exemplar.output.XMLParserGenerator<T>
      extended by com.mcdermottroe.exemplar.output.XMLParserSourceGenerator<Generator>
          extended by com.mcdermottroe.exemplar.output.java.binding.Generator
All Implemented Interfaces:
Copyable<Generator>, Comparable<Generator>

public class Generator
extends XMLParserSourceGenerator<Generator>

A class which generates data binding Java parsers.

Since:
0.2

Field Summary
protected  String basePackage
          The base package, if any, where the output code is going to live.
 
Fields inherited from class com.mcdermottroe.exemplar.output.XMLParserSourceGenerator
codeFragments, timestamp
 
Constructor Summary
  Generator()
          Creates a source generator which produces data binding parsers in the Java language.
protected Generator(Map<String,String> code, String time, String pkg)
          Copy constructor, see XMLParserSourceGenerator.XMLParserSourceGenerator(Map, String) for details.
 
Method Summary
protected  void createAbstractElementClass(File dir)
          Create the abstract element class which is the root of all element classes.
protected  void createElementClass(XMLElement element, File dir)
          Create a class for a given element.
protected  void createProcessingInstructionClass(File dir)
          Create the ProcessingInstruction class.
protected  void createRootParserClass(File dir)
          Create the base parser class which can be used to parse the input.
protected  void createXMLComponentClass(File dir)
          Create the XMLComponent class.
protected  void createXMLContentClass(File dir)
          Create the XMLContent class.
 String describeAPI()
          Describe the API that the generated code implements/conforms to.
 String describeLanguage()
          Describe the language that this generator outputs in.
 void generateParser(XMLDocumentType doctype, File targetDirectory)
          Generates a parser and places the source (if any) in the given directory.
 Generator getCopy()
          Creates a deep copy of the current object and returns it.
 
Methods inherited from class com.mcdermottroe.exemplar.output.XMLParserSourceGenerator
compareTo, create, getCodeFragments, getSourceDirectory, getTimestamp, loadCodeFragment
 
Methods inherited from class com.mcdermottroe.exemplar.output.XMLParserGenerator
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

basePackage

protected String basePackage
The base package, if any, where the output code is going to live.

Constructor Detail

Generator

public Generator()
          throws XMLParserGeneratorException
Creates a source generator which produces data binding parsers in the Java language.

Throws:
XMLParserGeneratorException - if the super-class constructor throws one.

Generator

protected Generator(Map<String,String> code,
                    String time,
                    String pkg)
Copy constructor, see XMLParserSourceGenerator.XMLParserSourceGenerator(Map, String) for details.

Parameters:
code - The code fragments.
time - The timestamp.
pkg - The basePackage.
Method Detail

generateParser

public void generateParser(XMLDocumentType doctype,
                           File targetDirectory)
                    throws XMLParserGeneratorException
Generates a parser and places the source (if any) in the given directory.

Specified by:
generateParser in class XMLParserSourceGenerator<Generator>
Parameters:
doctype - The description of the vocabulary of XML to generate a parser for.
targetDirectory - The directory to place the source (if any).
Throws:
XMLParserGeneratorException - if an error occurs during code generation. If the implementation wishes to report any error it should be via this mechanism.

describeLanguage

public String describeLanguage()
Describe the language that this generator outputs in.

Specified by:
describeLanguage in class XMLParserGenerator<Generator>
Returns:
A String that can be used in help messages and in documentation to describe the language that this generator outputs.

describeAPI

public String describeAPI()
Describe the API that the generated code implements/conforms to.

Specified by:
describeAPI in class XMLParserGenerator<Generator>
Returns:
A String that can be used in help messages and in documentation to describe the API that the generated code implements.

createRootParserClass

protected void createRootParserClass(File dir)
                              throws XMLParserGeneratorException
Create the base parser class which can be used to parse the input.

Parameters:
dir - The directory in which the base parser class will be put.
Throws:
XMLParserGeneratorException - if the base parser class cannot be created.

createAbstractElementClass

protected void createAbstractElementClass(File dir)
                                   throws XMLParserGeneratorException
Create the abstract element class which is the root of all element classes.

Parameters:
dir - The directory in which to place the class.
Throws:
XMLParserGeneratorException - if the abstract element class cannot be generated.

createElementClass

protected void createElementClass(XMLElement element,
                                  File dir)
                           throws XMLParserGeneratorException
Create a class for a given element.

Parameters:
element - The element to create the class for.
dir - The directory in which to create the class.
Throws:
XMLParserGeneratorException - if the abstract element class cannot be generated.

createXMLContentClass

protected void createXMLContentClass(File dir)
                              throws XMLParserGeneratorException
Create the XMLContent class.

Parameters:
dir - The directory in which to create the class.
Throws:
XMLParserGeneratorException - if the XMLContent class cannot be generated.

createXMLComponentClass

protected void createXMLComponentClass(File dir)
                                throws XMLParserGeneratorException
Create the XMLComponent class.

Parameters:
dir - The directory in which to create the class.
Throws:
XMLParserGeneratorException - if the XMLComponent class cannot be generated.

createProcessingInstructionClass

protected void createProcessingInstructionClass(File dir)
                                         throws XMLParserGeneratorException
Create the ProcessingInstruction class.

Parameters:
dir - The directory in which to create the class.
Throws:
XMLParserGeneratorException - if the ProcessingInstruction class cannot be generated.

getCopy

public Generator getCopy()
                  throws CopyException
Creates a deep copy of the current object and returns it.

Returns:
A deep copy of the current object.
Throws:
CopyException - if the copying encountered an exception.