public class SourceGenerator extends BuilderConfiguration
BuilderConfiguration.Property
Modifier and Type | Field and Description |
---|---|
protected SGStateInfo |
_sInfo |
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
void |
generateSource(InputSource source,
String packageName)
Creates Java Source code (Object model) for the given XML Schema.
|
void |
generateSource(Reader reader,
String packageName)
Creates Java Source code (Object model) for the given XML Schema.
|
void |
generateSource(Schema schema,
String packageName)
Creates Java Source code (Object model) for the given XML Schema.
|
void |
generateSource(String filename,
String packageName)
Creates Java Source code (Object model) for the given XML Schema.
|
boolean |
getGenerateImportedSchemas()
Indicates whether classes should be created for imported XML schemas as well.
|
JClassPrinterFactoryRegistry |
getJClassPrinterFactoryRegistry()
Returns the registry for
JClassPrinterFactory instances. |
static String |
getVersion()
Returns the version number of this SourceGenerator.
|
JClassRegistry |
getXMLInfoRegistry()
Returns the
JClassRegistry instance associated with this source generator. |
static void |
main(String[] args)
Deprecated.
Please use
SourceGeneratorMain.main(String[]) |
boolean |
mappingSchemaElement2Java()
Tests the org.exolab.castor.builder.javaclassmapping property for the
'element' value.
|
boolean |
mappingSchemaType2Java()
Tests the org.exolab.castor.builder.javaclassmapping property for the
'type' value.
|
void |
setBinding(ExtendedBinding binding)
Sets the binding to use with this instance of the SourceGenerator.
|
void |
setBinding(InputSource source)
Sets the binding to use given an InputSource identifying
a Castor Binding File.
|
void |
setBinding(String fileName)
Sets the binding to use given the path name of a Castor Binding File.
|
void |
setCaseInsensitive(boolean caseInsensitive)
Set to true if enumerated type lookups should be performed in a case
insensitive manner.
|
void |
setClassNameConflictResolver(String resolverName)
Sets the ClassNameConflictResolver instance to be used for automatic class name
conflict resolution.
|
void |
setCreateMarshalMethods(boolean createMarshalMethods)
Sets whether or not to create the XML marshaling framework specific
methods (marshal, unmarshal, validate) in the generated classes.
|
void |
setDescriptorCreation(boolean createDescriptors)
Sets whether or not to create ClassDescriptors for the generated classes.
|
void |
setDestDir(String destDir)
Sets the destination directory.
|
void |
setFailOnFirstError(boolean failOnFirstError)
If true, the source generator will fail on the first error encountered.
|
void |
setGenerateImportedSchemas(boolean generate)
Sets whether or not to generate Java sources for imported XML Schema.
|
void |
setGenerateMappingFile(boolean generateMapping)
Sets whether or not a mapping file should be generated, this is false by
default.
|
void |
setJClassPrinterType(String jClassPrinterType)
Sets the jclassPrinter type.
|
void |
setJdoDescriptorCreation(boolean createJdoDescriptors)
Sets whether or not to create JDO-specific class descriptors for the
generated classes.
|
void |
setLineSeparator(String lineSeparator)
Sets the line separator to use when printing the source code.
|
void |
setMappingFilename(String filename)
Sets the filename of the mapping file.
|
void |
setNameConflictStrategy(String nameConflictStrategy)
Sets the strategy for handling name conflicts.
|
void |
setResourceDestination(String destination)
Sets the destination directory for resources, e.g.
|
void |
setSAX1(boolean sax1)
Set to true if SAX1 should be used in the marshal method.
|
void |
setSuppressNonFatalWarnings(boolean suppress)
Sets whether or not to suppress non-fatal warnings encountered during
source generation.
|
void |
setTestable(boolean testable)
Sets whether or not to implement CastorTestable.
|
void |
setVerbose(boolean verbose)
Sets whether or not the source code generator prints additional messages
during generating source code.
|
static String |
toURIRepresentation(String path)
Returns a string which is the URI of a file.
|
addAnnotationBuilder, boundPropertiesEnabled, classDescFieldNames, equalsMethod, forceUseJava50, generateExtraCollectionMethods, generateExtraDocumentationMethods, getAnnotationBuilders, getAutomaticConflictResolutionTypeSuffix, getDefault, getJavaNaming, getJClassPrinterFactories, getMaximumNumberOfConstants, getProperty, isAutomaticConflictResolution, load, loadProperties, lookupPackageByLocation, lookupPackageByNamespace, processNamespacePackageMappings, setClassDescFieldNames, setDefaultProperties, setEqualsMethod, setJavaNaming, setLocationPackageMapping, setNamespacePackageMapping, setPrimitiveWrapper, setUseEnumeratedTypeInterface, useCycleBreaker, useEnumeratedTypeInterface, useJava50, useJava5Enums, useOldFieldNaming, usePrimitiveWrapper
protected SGStateInfo _sInfo
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.public final void setMappingFilename(String filename)
filename
- filename of the mapping filepublic final void setNameConflictStrategy(String nameConflictStrategy)
nameConflictStrategy
- the name of the stretegy to use for handling
name conflicts.public static String getVersion()
public final void setSAX1(boolean sax1)
sax1
- true if SAX1 should be used in the marshal methodpublic final void setCaseInsensitive(boolean caseInsensitive)
caseInsensitive
- when true, enumerated type lookups will be
performed in a case insensitive manner.public final void setFailOnFirstError(boolean failOnFirstError)
failOnFirstError
- if true, the source generator will fail on the
first error encountered.public final void setSuppressNonFatalWarnings(boolean suppress)
suppress
- true if non-fatal warnings should be suppressed.public void setVerbose(boolean verbose)
verbose
- a boolean, when true indicates to print additional
messagespublic void setClassNameConflictResolver(String resolverName)
resolverName
- The name of the resolver to be used for automatic class name
conflict resolutionpublic final void setDescriptorCreation(boolean createDescriptors)
createDescriptors
- a boolean, when true indicates to generated
ClassDescriptorspublic final void setJdoDescriptorCreation(boolean createJdoDescriptors)
createJdoDescriptors
- a boolean, when true indicates to generated
JDO-specific class descriptorspublic final void setDestDir(String destDir)
destDir
- the destination directory.public final void setResourceDestination(String destination)
destDir
- the destination directory for resources.public final void setCreateMarshalMethods(boolean createMarshalMethods)
createMarshalMethods
- a boolean, when true indicates to generated
the marshaling framework methodspublic final void setGenerateImportedSchemas(boolean generate)
generate
- true to generate the java classes for the imported XML Schemapublic final void setGenerateMappingFile(boolean generateMapping)
generateMapping
- a flag that indicates whether or not a mapping
file should be generated.public final void setTestable(boolean testable)
testable
- a boolean, when true indicates to implement CastorTestablepublic final void setBinding(ExtendedBinding binding)
binding
- the binding to use, null indicates that the default binding
will be used.public final void setBinding(String fileName)
fileName
- the file that represents a Bindingpublic final void setBinding(InputSource source)
source
- an InputSource identifying a Castor Binding File.public final void setLineSeparator(String lineSeparator)
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.public final boolean mappingSchemaElement2Java()
mappingSchemaElement2Java
in class BuilderConfiguration
public final boolean mappingSchemaType2Java()
mappingSchemaType2Java
in class BuilderConfiguration
public final void generateSource(String filename, String packageName) throws IOException
generateSource(InputSource, String)
.filename
- the full path to the XML Schema definitionpackageName
- the package for the generated source filesIOException
- if an IOException occurs writing the new source filespublic final void generateSource(Reader reader, String packageName) throws IOException
generateSource(InputSource, String)
.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 filesIOException
- if an IOException occurs writing the new source filespublic void generateSource(InputSource source, String packageName) throws IOException
generateSource(Schema, String)
to actually generate the source.source
- - the InputSource representing the XML schema.packageName
- the package for the generated source filesIOException
- if an IOException occurs writing the new source filespublic final void generateSource(Schema schema, String packageName) throws IOException
Schema
already parsed.schema
- the XML schema to generate the Java sources for.packageName
- the package for the generated source files.IOException
- if this Exception occurs while generating sourceto provide the schema filename
,
to provide a Reader for the schema
,
to provide an InputSource for
the schema
public static String toURIRepresentation(String path)
path
- The absolute path of the file.public static void main(String[] args)
SourceGeneratorMain.main(String[])
args
- our command line arguments.public JClassRegistry getXMLInfoRegistry()
JClassRegistry
instance associated with this source generator.JClassRegistry
instance currently in use.public final void setJClassPrinterType(String jClassPrinterType)
jClassPrinterType
- The string identifier of the printer to use.public boolean getGenerateImportedSchemas()
public JClassPrinterFactoryRegistry getJClassPrinterFactoryRegistry()
JClassPrinterFactory
instances.JClassPrinterFactory
instances.Copyright © 2019. All rights reserved.