de.ispsoft.jaxme.generator
Class Generator

java.lang.Object
  extended byde.ispsoft.jaxme.generator.Generator

public class Generator
extends java.lang.Object

The Generator is reading an input schema. The schema is converted into a DOM tree. Finally one or more source writers are executed.

Author:
Jochen Wiedmann

Constructor Summary
Generator()
          Creates new Generator
 
Method Summary
 void addOption(SchemaOption pOption)
          Adds an option to the list of options.
 void addSourceWriter(SourceWriter pWriter)
          Adds a SourceWriter to the end of the list of registered SourceWriters.
 void clearOptions()
          Clears the list of options.
 void clearSourceWriters()
          Clears the list of currently registered SourceWriters.
 void configure(Configurable pConfigurable)
          Configures the given Configurable with the options returned by getOptions().
 void generate(java.io.File pFile)
          Opens the given file, calls the specified SchemaReaders () method and SourceWriters write() method.
 void generate(java.lang.String pSchema)
          Calls the specified SchemaReaders parse() method and the SourceWriters write() method.
 void generate(java.net.URL pURL)
          Opens the given URL, calls the specified SchemaReaders () method and SourceWriters write() method.
protected  SchemaReader getConfiguredSchemaReader()
          Returns a SchemaReader configured with the options returned by getOptions.
 java.io.File getDestFile()
          Returns the destination file.
 boolean getForce()
          Returns whether generated files should be overwritten.
static java.lang.String getJaxMeRuntimePackage()
          Returns the JaxMe runtime package.
 java.util.Iterator getOptions()
          Returns an iterator to the list of options.
 java.util.Date getSchemaDate()
          Returns the schema creation date.
 SchemaReader getSchemaReader()
          Returns the SchemaReader.
 java.io.File getSourceDirectory()
          Returns the Generators target directory.
 java.util.Iterator getSourceWriters()
          Returns an Iterator to the list of currently registered SourceWriters.
 void setDestFile(java.io.File pDestFile)
          Sets the destination file.
 void setForce(boolean pForce)
          Sets whether generated files should be overwritten.
 void setSchemaDate(java.util.Date pDate)
          Sets the schema creation date.
 void setSchemaReader(SchemaReader pReader)
          Sets the SchemaReader.
 void setSourceDirectory(java.io.File pDirectory)
          Sets the Generators target directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Generator

public Generator()
Creates new Generator

Method Detail

setSchemaReader

public void setSchemaReader(SchemaReader pReader)

Sets the SchemaReader.


getSchemaReader

public SchemaReader getSchemaReader()

Returns the SchemaReader.


setDestFile

public void setDestFile(java.io.File pDestFile)

Sets the destination file. If such a file is set and exists and the Generator can determine the time and date of the input file, then the Generator won't do anything, unless the schema file is newer than the destination file.


getDestFile

public java.io.File getDestFile()

Returns the destination file. If such a file is set and exists and the Generator can determine the time and date of the input file, then the Generator won't do anything, unless the schema file is newer than the destination file.


setSchemaDate

public void setSchemaDate(java.util.Date pDate)

Sets the schema creation date.


getForce

public boolean getForce()

Returns whether generated files should be overwritten. Defaults to false.


setForce

public void setForce(boolean pForce)

Sets whether generated files should be overwritten. Defaults to false.


getSchemaDate

public java.util.Date getSchemaDate()

Returns the schema creation date. May be null, if the date is unknown.


addSourceWriter

public void addSourceWriter(SourceWriter pWriter)

Adds a SourceWriter to the end of the list of registered SourceWriters.

See Also:
clearSourceWriters(), getSourceWriters()

getSourceWriters

public java.util.Iterator getSourceWriters()

Returns an Iterator to the list of currently registered SourceWriters. This iterator is not "live": Changes in the actual list won't be reflected in the iteration. Likewise, calling the iterators remove() method won't affect the actual list.

See Also:
addSourceWriter(de.ispsoft.jaxme.generator.SourceWriter), clearSourceWriters()

clearSourceWriters

public void clearSourceWriters()

Clears the list of currently registered SourceWriters.

See Also:
getSourceWriters(), addSourceWriter(de.ispsoft.jaxme.generator.SourceWriter)

setSourceDirectory

public void setSourceDirectory(java.io.File pDirectory)

Sets the Generators target directory. Generated sources will appear in that directory.

Parameters:
pDirectory - Directory where to create sources; may be null, in which case the current directory is used (default).

getSourceDirectory

public java.io.File getSourceDirectory()

Returns the Generators target directory. Generated sources will appear in that directory.

Returns:
Target directory or null (current directory, default)

clearOptions

public void clearOptions()

Clears the list of options.


addOption

public void addOption(SchemaOption pOption)

Adds an option to the list of options.


getOptions

public java.util.Iterator getOptions()

Returns an iterator to the list of options.


configure

public void configure(Configurable pConfigurable)

Configures the given Configurable with the options returned by getOptions().


getConfiguredSchemaReader

protected SchemaReader getConfiguredSchemaReader()

Returns a SchemaReader configured with the options returned by getOptions.


generate

public void generate(java.lang.String pSchema)
              throws java.lang.Exception

Calls the specified SchemaReaders parse() method and the SourceWriters write() method.

Throws:
java.lang.Exception

generate

public void generate(java.io.File pFile)
              throws java.lang.Exception

Opens the given file, calls the specified SchemaReaders () method and SourceWriters write() method.

Throws:
java.lang.Exception

generate

public void generate(java.net.URL pURL)
              throws java.lang.Exception

Opens the given URL, calls the specified SchemaReaders () method and SourceWriters write() method.

Throws:
java.lang.Exception

getJaxMeRuntimePackage

public static java.lang.String getJaxMeRuntimePackage()

Returns the JaxMe runtime package.