com.mcdermottroe.exemplar.output.dtd
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.dtd.Generator
All Implemented Interfaces:
Copyable<Generator>, Comparable<Generator>
Direct Known Subclasses:
XMLParserSourceGeneratorTest.ExtendedDTDSourceGenerator

public class Generator
extends XMLParserSourceGenerator<Generator>

A class which generates a DTD for this XML vocabulary.

Since:
0.1

Field Summary
 
Fields inherited from class com.mcdermottroe.exemplar.output.XMLParserSourceGenerator
codeFragments, timestamp
 
Constructor Summary
  Generator()
          Creates a source generator that produces DTDs.
protected Generator(Map<String,String> code, String time)
          Copy constructor, see XMLParserSourceGenerator.XMLParserSourceGenerator(Map, String) for details.
 
Method Summary
 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 the DTD and places it in the given file.
 Generator getCopy()
          Creates a deep copy of the current object and returns it.
private static String objectTreeToContentSpec(Object o)
          Convert either an XMLSequence or XMLAlternative to a contentspec portion of an element declaration.
 
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
 

Constructor Detail

Generator

public Generator()
          throws XMLParserGeneratorException
Creates a source generator that produces DTDs.

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

Generator

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

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

generateParser

public void generateParser(XMLDocumentType doctype,
                           File targetDirectory)
                    throws XMLParserGeneratorException
Generates the DTD and places it in the given file.

Specified by:
generateParser in class XMLParserSourceGenerator<Generator>
Parameters:
doctype - The description of the vocabulary of XML to generate a parser for.
targetDirectory - The directory in which to place the source.
Throws:
XMLParserGeneratorException - if the code fragments could not be loaded or if the output file could not be written to.

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.

objectTreeToContentSpec

private static String objectTreeToContentSpec(Object o)
Convert either an XMLSequence or XMLAlternative to a contentspec portion of an element declaration.

Parameters:
o - An XMLObject or String which is part of a contentspec declaration. If the object is a String it must be an element name, otherwise it should be an XMLAlternative or an XMLSequence.
Returns:
A String representation of the contentspec.

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.