Reader Overview

Readers provide a means of populating the Dictionary: -

Class Hierarchy

The Reader class hierarchy is illustrated below: -

Dictionary Reader (com.javelin.generator.DictionaryReader)

The Dictionary Reader is the interface that is used to write out code. The Dictionary Reader has the following properties, which are set on the Dictionary Reader before a command to write the file is called.

  • The Server
  • The Database name
  • The Arguments

Readers are declared in the bdf as follows: -

[#]reader.[#]<index>=<fully qualified class name>

The # comment at the beginning of a line can be used to stop executing the readers at that point in the index. The # comment before the index stops just those readers being executed.

For example: -

reader.#0=com.javelin.generator.jdbc.JdbcReader
reader.1=com.javelin.generator.properties.PropertiesReader

One or more arguments can be passed to a Dictionary Reader, as space separated Strings. For example: -

reader.0=com.javelin.generator.beans.BeanInterfaceWriter Arg1 Arg2 arg3

If the fully qualified class is not a Dictionary Reader JGenerator tries to find a main method to call, and pass the arguments to it, before calling the read method.

Abstract Reader (com.javelin.generator.AbstractReader)

The Abstract Reader is a helper class that readers can extend to provide some basic functionality.

Aggregate Reader (com.javelin.generator.AggregateReader)

The Aggregate Reader is used to group readers together. (see. Aggregate Writer)

Jdbc Reader (com.javelin.generator.jdbc.JdbcReader)

The Jdbc Reader can be used to read in properties from a database and populate the Dictionary. Once the Dictionary is populated supplementary properties can be read in using the Properties Reader.

The JdbcReader uses JPool to read in the database metadata. This requires the database to be specified in a jdbc.properties file. The database meta data is read in using JPool.

Properties Reader (com.javelin.generator.properties.PropertiesReader)

The Properties Reader can be used to read in properties from a property file to populate the Dictionaries supplementary properties. Some of those properties can be used to populate the dictionary. The properties and their formats are covered throughout this tutorial.

 

DTD Reader (com.javelin.generator.dtd.DTDReader)

The DTD Reader can be used to read in properties from one or more DTD files to populate the Dictionaries supplementary properties.

The DTD Reader must be subclassed so that types can be read in - other wise everying is interpreted as a String(50)

Where multiple DTDs are read in the elements from each file can be mapped to a different package/database, using the indexed properties. By default the current database is used as the package/database

dtd.entitypackage.<N>=<relative fileName>=<package>

For example:

dtd.entitypackage.0=dtds/ABC.dtd=abc
dtd.entitypackage.1=dtds/DEF.dtd=def