A Java Source generation tool which uses XML Schema definitions
to create an Object model.
generateSource
public void generateSource(InputSource source,
String packageName)
throws IOException
Creates Java Source code (Object model) for the given XML Schema. Parses
the schema provided by the InputSource and then calls
generateSource(Schema,String)
to actually generate the source.
source
- - the InputSource representing the XML schema.packageName
- the package for the generated source files
generateSource
public final void generateSource(Reader reader,
String packageName)
throws IOException
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 files
generateSource
public final void generateSource(String filename,
String packageName)
throws IOException
filename
- the full path to the XML Schema definitionpackageName
- the package for the generated source files
generateSource
public final void generateSource(Schema schema,
String packageName)
throws IOException
Creates Java Source code (Object model) for the given XML Schema.
Convenience methods exist if you don't have a
Schema
already parsed.
schema
- the XML schema to generate the Java sources for.packageName
- the package for the generated source files.
getGenerateImportedSchemas
public boolean getGenerateImportedSchemas()
Indicates whether classes should be created for imported XML schemas as well.
- true if classes should be created for imported schemas.
getVersion
public static String getVersion()
Returns the version number of this SourceGenerator.
- the version number of this SourceGenerator
main
public static void main(String[] args)
Please use SourceGeneratorMain.main(String[])
For backwards compability, when we are called as the main() routine,
delegate the command-line usage to the proper class.
args
- our command line arguments.
mappingSchemaElement2Java
public final boolean mappingSchemaElement2Java()
Tests the org.exolab.castor.builder.javaclassmapping property for the
'element' value.
- mappingSchemaElement2Java in interface BuilderConfiguration
- True if the Source Generator is mapping schema elements to Java
classes.
mappingSchemaType2Java
public final boolean mappingSchemaType2Java()
Tests the org.exolab.castor.builder.javaclassmapping property for the
'type' value.
- mappingSchemaType2Java in interface BuilderConfiguration
- True if the Source Generator is mapping schema types to Java
classes.
setBinding
public final void setBinding(InputSource source)
Sets the binding to use given an InputSource identifying
a Castor Binding File.
source
- an InputSource identifying a Castor Binding File.
setBinding
public final void setBinding(String fileName)
Sets the binding to use given the path name of a Castor Binding File.
fileName
- the file that represents a Binding
setBinding
public final void setBinding(ExtendedBinding binding)
Sets the binding to use with this instance of the SourceGenerator.
binding
- the binding to use, null indicates that the default binding
will be used.
setCaseInsensitive
public final void setCaseInsensitive(boolean caseInsensitive)
Set to true if enumerated type lookups should be performed in a case
insensitive manner.
caseInsensitive
- when true, enumerated type lookups will be
performed in a case insensitive manner.
setClassNameConflictResolver
public void setClassNameConflictResolver(String resolverName)
Sets the ClassNameConflictResolver instance to be used for automatic class name
conflict resolution.
resolverName
- The name of the resolver to be used for automatic class name
conflict resolution
setCreateMarshalMethods
public final void setCreateMarshalMethods(boolean createMarshalMethods)
Sets whether or not to create the XML marshaling framework specific
methods (marshal, unmarshal, validate) in the generated classes. By
default, these methods are generated.
createMarshalMethods
- a boolean, when true indicates to generated
the marshaling framework methods
setDescriptorCreation
public final void setDescriptorCreation(boolean createDescriptors)
Sets whether or not to create ClassDescriptors for the generated classes.
By default, descriptors are generated.
createDescriptors
- a boolean, when true indicates to generated
ClassDescriptors
setDestDir
public final void setDestDir(String destDir)
Sets the destination directory.
destDir
- the destination directory.
setFailOnFirstError
public final void setFailOnFirstError(boolean failOnFirstError)
If true, the source generator will fail on the first error encountered.
Otherwise, the source generator will continue on certain errors.
failOnFirstError
- if true, the source generator will fail on the
first error encountered.
setGenerateImportedSchemas
public final void setGenerateImportedSchemas(boolean generate)
Sets whether or not to generate Java sources for imported XML Schema.
By default Java sources for imported XML schemas are not generated.
generate
- true to generate the java classes for the imported XML Schema
setGenerateMappingFile
public final void setGenerateMappingFile(boolean generateMapping)
Sets whether or not a mapping file should be generated, this is false by
default. Note that this will only be used when generation of descriptors
has been disabled.
generateMapping
- a flag that indicates whether or not a mapping
file should be generated.
setJClassPrinter
public final void setJClassPrinter(String jClassPrinterType)
Sets the jclassPrinter type.
jClassPrinterType
- The string identifier of the printer to use.
setLineSeparator
public final void setLineSeparator(String lineSeparator)
Sets the line separator to use when printing the source code.
Note:This can be any string, so be careful. I recommend either
using the default or using one of the following:
windows systems use: "\r\n"
unix systems use: "\n"
mac systems use: "\r"
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.
setMappingFilename
public final void setMappingFilename(String filename)
Sets the filename of the mapping file.
filename
- filename of the mapping file
setNameConflictStrategy
public final void setNameConflictStrategy(String nameConflictStrategy)
Sets the strategy for handling name conflicts.
nameConflictStrategy
- the name of the stretegy to use for handling
name conflicts.
setSAX1
public final void setSAX1(boolean sax1)
Set to true if SAX1 should be used in the marshal method.
sax1
- true if SAX1 should be used in the marshal method
setSuppressNonFatalWarnings
public final void setSuppressNonFatalWarnings(boolean suppress)
Sets whether or not to suppress non-fatal warnings encountered during
source generation.
suppress
- true if non-fatal warnings should be suppressed.
setTestable
public final void setTestable(boolean testable)
Sets whether or not to implement CastorTestable.
testable
- a boolean, when true indicates to implement CastorTestable
setVerbose
public void setVerbose(boolean verbose)
Sets whether or not the source code generator prints additional messages
during generating source code.
verbose
- a boolean, when true indicates to print additional
messages
toURIRepresentation
public static String toURIRepresentation(String path)
Returns a string which is the URI of a file.
- file:///DOSpath
- file://UnixPath
No validation is done to check whether the file exists or not. This
method will be no longer used when the JDK URL.toString() is fixed.
path
- The absolute path of the file.
- A string representing the URI of the file.