|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exolab.castor.builder.SourceGenerator
public class SourceGenerator
A Java Source generation tool which uses XML Schema definitions to create an Object model.
Nested Class Summary | |
---|---|
static class |
SourceGenerator.Property
Names of properties used in the configuration file. |
Field Summary | |
---|---|
(package private) static java.lang.String |
APP_DESC
The application description |
(package private) static java.lang.String |
APP_NAME
The application name |
(package private) static java.lang.String |
APP_URI
The application URI |
(package private) static java.lang.String |
VERSION
The application version |
Constructor Summary | |
---|---|
SourceGenerator()
Creates a SourceGenerator using the default FieldInfo factory |
|
SourceGenerator(FieldInfoFactory infoFactory)
Creates a SourceGenerator using the specific field info Factory. |
|
SourceGenerator(FieldInfoFactory infoFactory,
ExtendedBinding binding)
Creates a SourceGenerator using the specific field info Factory and the given Binding element . |
Method Summary | |
---|---|
static boolean |
boundPropertiesEnabled()
Returns true if bound properties are enabled. |
static boolean |
classDescFieldNames()
Returns true if we generate a 'public static final String' for the name of each attribute and element described by the class descriptor Enabling this property is controlled via the org.exolab.castor.builder.classdescfieldnames item in the castorbuilder.properties file. |
static boolean |
equalsMethod()
Returns true if we generate an 'equals' method for each generated class. |
static boolean |
generateExtraCollectionMethods()
Returns true if extra methods for collection fields should be generated. |
void |
generateSource(org.xml.sax.InputSource source,
java.lang.String packageName)
Creates Java Source code (Object model) for the given XML Schema |
void |
generateSource(java.io.Reader reader,
java.lang.String packageName)
Creates Java Source code (Object model) for the given XML Schema. |
void |
generateSource(Schema schema,
java.lang.String packageName)
Creates Java Source code (Object model) for the given XML Schema. |
void |
generateSource(java.lang.String filename,
java.lang.String packageName)
Creates Java Source code (Object model) for the given XML Schema. |
static java.util.Properties |
getDefault()
Returns the default configuration file. |
static java.lang.String |
getProperty(java.lang.String name,
java.lang.String defValue)
Returns a property from the default configuration file. |
static java.lang.String |
getVersion()
Returns the version number of this SourceGenerator |
protected static void |
initBindingType()
Called by #load to initialize the binding type |
protected static void |
load()
Called by getDefault() to load the configuration the
first time. |
static java.lang.String |
lookupPackageLocation(java.lang.String schemaLocation)
Gets a Java package to a schema location. |
static java.lang.String |
lookupPackageNamespace(java.lang.String nsURL)
Gets a Java package to an XML namespace URL |
static void |
main(java.lang.String[] args)
main class used for command line invocation |
static boolean |
mappingSchemaElement2Java()
Tests the org.exolab.castor.builder.javaclassmapping property for the 'element' value. |
static boolean |
mappingSchemaType2Java()
Tests the org.exolab.castor.builder.javaclassmapping property for the 'type' value. |
protected static void |
processNamespacePackageMappings(java.lang.String mappings)
|
void |
setBinding(ExtendedBinding binding)
Sets the binding to use with this instance of the SourceGenerator. |
void |
setBinding(org.xml.sax.InputSource source)
Sets the binding to use given an InputSource identifying a Castor Binding File. |
void |
setBinding(java.lang.String fileName)
Sets the binding to use given the path name of a Castor Binding File. |
static void |
setClassDescFieldNames(boolean classDescFieldNames)
Sets the 'classDescFieldNames' property |
void |
setCreateMarshalMethods(boolean createMarshalMethods)
Sets whether or not to create the XML marshalling framework specific methods (marshall, unmarshall, validate) in the generated classes. |
static void |
setDefaultProperties(java.util.Properties properties)
Override the properties |
void |
setDescriptorCreation(boolean createDescriptors)
Sets whether or not to create ClassDescriptors for the generated classes. |
void |
setDestDir(java.lang.String destDir)
Sets the destination directory. |
static void |
setEqualsMethod(boolean equals)
Sets the 'equalsmethod' property |
void |
setLineSeparator(java.lang.String lineSeparator)
Sets the line separator to use when printing the source code |
static void |
setPrimitiveWrapper(boolean wrapper)
Sets the 'primitivetowrapper' property |
void |
setSAX1(boolean sax1)
Set to true if SAX1 should be used in the marshall method |
void |
setSuppressNonFatalWarnings(boolean suppress)
|
void |
setTestable(boolean testable)
Sets whether or not to create the XML marshalling framework specific methods (marshall, unmarshall, validate) in the generated classes. |
void |
setVerbose(boolean verbose)
Sets whether or not the source code generator prints additional messages during generating source code |
static java.lang.String |
toURIRepresentation(java.lang.String path)
Returns a string which is the URI of a file. |
static boolean |
usePrimitiveWrapper()
Returns true if primitive types have to be used as Objects (eg. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final java.lang.String APP_NAME
static final java.lang.String APP_DESC
static final java.lang.String VERSION
static final java.lang.String APP_URI
Constructor Detail |
---|
public SourceGenerator()
public SourceGenerator(FieldInfoFactory infoFactory)
infoFactory
- the FieldInfoFactory to use.public SourceGenerator(FieldInfoFactory infoFactory, ExtendedBinding binding)
infoFactory
- the FieldInfoFactory to use.binding
- the binding element to use.Method Detail |
---|
public void generateSource(Schema schema, java.lang.String packageName)
schema
- the XML schema to generate the Java sources for.packageName
- the package for the generated source files.public void generateSource(org.xml.sax.InputSource source, java.lang.String packageName)
InputSource
- - the InputSource representing the XML schema.packageName
- the package for the generated source filespublic void generateSource(java.io.Reader reader, java.lang.String packageName)
reader
- the Reader with which to read the XML Schema definition.
The caller should close the reader, since thie method will not do so.packageName
- the package for the generated source filespublic void generateSource(java.lang.String filename, java.lang.String packageName) throws java.io.FileNotFoundException
filename
- the full path to the XML Schema definitionpackageName
- the package for the generated source files
java.io.FileNotFoundException
public static java.util.Properties getDefault()
public static java.lang.String getProperty(java.lang.String name, java.lang.String defValue)
getDefault()
.
name
- The property namedefault
- The property's default value
public static boolean boundPropertiesEnabled()
public static boolean equalsMethod()
public static void setEqualsMethod(boolean equals)
boolean
- the value we want to usepublic static boolean classDescFieldNames()
public static void setClassDescFieldNames(boolean classDescFieldNames)
boolean
- the value we want to uespublic static boolean usePrimitiveWrapper()
public static void setPrimitiveWrapper(boolean wrapper)
boolean
- the value we want to use.public static boolean mappingSchemaElement2Java()
public static boolean mappingSchemaType2Java()
public static java.lang.String lookupPackageNamespace(java.lang.String nsURL)
public static java.lang.String lookupPackageLocation(java.lang.String schemaLocation)
public static java.lang.String getVersion()
public void setSAX1(boolean sax1)
public void setSuppressNonFatalWarnings(boolean suppress)
public void setVerbose(boolean verbose)
verbose
- a boolean, when true indicates to
print additional messagespublic void setDescriptorCreation(boolean createDescriptors)
createDescriptors
- a boolean, when true indicates
to generated ClassDescriptorspublic void setDestDir(java.lang.String destDir)
destDir
- the destination directory.public void setCreateMarshalMethods(boolean createMarshalMethods)
createMarshalMethods
- a boolean, when true indicates
to generated the marshalling framework methodspublic void setTestable(boolean testable)
createMarshall
- a boolean, when true indicates
to generated the marshalling framework methodspublic static void setDefaultProperties(java.util.Properties properties)
public void setBinding(ExtendedBinding binding)
binding
- the binding to use, null indicates that the default
binding will be used.public void setBinding(java.lang.String fileName)
fileName
- the file that represents a Bindingpublic void setBinding(org.xml.sax.InputSource source)
source
- an InputSource identifying a Castor Binding File.public static void main(java.lang.String[] args)
args
- the String[] consisting of the command line argumentspublic void setLineSeparator(java.lang.String lineSeparator)
lineSeparator
- the line separator to use when printing
the source code. This method is useful if you are generating
source on one platform, but will be compiling the source
on a different platform.
windows systems use: "\r\n" unix systems use: "\n" mac systems use: "\r"
public static boolean generateExtraCollectionMethods()
protected static void load()
getDefault()
to load the configuration the
first time. Will not complain about inability to load
configuration file from one of the default directories, but if
it cannot find the JAR's configuration file, will throw a
run time exception.
protected static void processNamespacePackageMappings(java.lang.String mappings)
protected static void initBindingType()
public static java.lang.String toURIRepresentation(java.lang.String path)
Returns a string which is the URI of a file.
path
- the absolute path of the file.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |