Package org.exolab.castor.builder
Class BuilderConfiguration
- java.lang.Object
-
- org.exolab.castor.builder.BuilderConfiguration
-
- Direct Known Subclasses:
SourceGenerator
public class BuilderConfiguration extends java.lang.ObjectThe configuration for the SourceGenerator. HACK this class is a configuration but does not base on Castor Configuration! Raised CASTOR-2195 to solve this issue.- Version:
- $Revision: 8600 $ $Date: 2006-04-25 15:08:23 -0600 (Tue, 25 Apr 2006) $
- Author:
- Keith Visco, Arnaud Blandin
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBuilderConfiguration.PropertyNames of properties used in the configuration file.
-
Constructor Summary
Constructors Constructor Description BuilderConfiguration()Creates a default BuilderConfiguration.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAnnotationBuilder(AnnotationBuilder annotationBuilder)adds a custom annotation builder.booleanboundPropertiesEnabled()Returns true if bound properties are enabled.booleanclassDescFieldNames()Returns true if we generate a 'public static final String' for the name of each attribute and element described by the class descriptorbooleanequalsMethod()Returns true if we generate an 'equals' method for each generated class.voidforceUseJava50()Add support to set java version programmatically.booleangenerateExtraCollectionMethods()Returns true if extra methods for collection fields should be generated.booleangenerateExtraDocumentationMethods()Returns true if extra methods for accessing XML schema documentation should be generated; default to 'false'.AnnotationBuilder[]getAnnotationBuilders()returns all applied annotation builders.java.lang.StringgetAutomaticConflictResolutionTypeSuffix()Returns the type 'suffix' used for the type strategy during automatic class name conflict resolution during XML code generation; default to "" unless a value is specified.java.util.PropertiesgetDefault()Returns the default configuration file.JavaNaminggetJavaNaming()To get theJavaNamingimplementation to be used.java.lang.StringgetJClassPrinterFactories()Returns a String representing the list ofJClassPrinterFactoryinstances configured in the Castor XML code generator property file.intgetMaximumNumberOfConstants()Returns the maximum number of static constant definitions that are acceptable within one class file; default is 1000.java.lang.StringgetProperty(java.lang.String name, java.lang.String defValue)Returns a property from the default configuration file.booleanisAutomaticConflictResolution()indicates whether automatic class name conflict resolution during XML code generation should take place or not.protected voidload()Called bygetDefault()to load the configuration the first time.static java.util.PropertiesloadProperties(java.lang.String resourceName, java.lang.String fileName)Load the configuration 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.java.lang.StringlookupPackageByLocation(java.lang.String schemaLocation)Converts a schema location into a Java package.java.lang.StringlookupPackageByNamespace(java.lang.String nsURL)Gets a Java package to an XML namespace URL.booleanmappingSchemaElement2Java()Tests the org.exolab.castor.builder.javaclassmapping property for the 'element' value.booleanmappingSchemaType2Java()Tests the org.exolab.castor.builder.javaclassmapping property for the 'type' value.protected voidprocessNamespacePackageMappings(java.lang.String mappings)processes the given String which contains namespace-to-package mappings.voidsetClassDescFieldNames(boolean classDescFieldNames)Sets the 'classDescFieldNames' property.voidsetDefaultProperties(java.util.Properties properties)Overrides the current set of properties with the given properties.voidsetEqualsMethod(boolean equals)Sets the 'equalsmethod' property.voidsetJavaNaming(JavaNaming javaNaming)To set theJavaNamingimplementation to be used.voidsetLocationPackageMapping(java.lang.String schemaLocation, java.lang.String packageName)Sets the schemaLocation to package mapping.voidsetNamespacePackageMapping(java.lang.String ns, java.lang.String packageName)Sets the namespace to package mapping.voidsetPrimitiveWrapper(boolean wrapper)Sets the 'primitivetowrapper' property.voidsetUseEnumeratedTypeInterface(boolean flag)Sets the 'enumTypeAccessInterface' property.booleanuseCycleBreaker()Returns true if the classCycleBreakershould be used during code generation; defaults to 'true'.booleanuseEnumeratedTypeInterface()Returns true if we generate the implements EnumeratedTypeAccess interface for enumerated type classes.booleanuseJava50()Returns true if we generate the implements EnumeratedTypeAccess interface for enumerated type classes.booleanuseJava5Enums()Indicates what kind of enumeration should be created for <xs:simpleType> enumerations.booleanusePrimitiveWrapper()Returns true if primitive types have to be used as Objects (eg.
-
-
-
Method Detail
-
getDefault
public final java.util.Properties getDefault()
Returns the default configuration file. Changes to the returned properties set will affect all Castor functions relying on the default configuration.- Returns:
- The default configuration
-
getProperty
public final java.lang.String getProperty(java.lang.String name, java.lang.String defValue)Returns a property from the default configuration file. Equivalent to calling getProperty on the result ofgetDefault().- Parameters:
name- The property namedefValue- The property's default value- Returns:
- The property's value
-
boundPropertiesEnabled
public final boolean boundPropertiesEnabled()
Returns true if bound properties are enabled.Enabling bound properties is controlled via the org.exolab.castor.builder.boundproperties item in the castorbuilder.properties file. The value is either 'true' or 'false'.
- Returns:
- true if bound properties are enabled.
-
equalsMethod
public final boolean equalsMethod()
Returns true if we generate an 'equals' method for each generated class.Enabling this property is controlled via the org.exolab.castor.builder.equalsmethod item in the castorbuilder.properties file. The value is either 'true' or 'false'.
- Returns:
- true if bound properties are enabled.
-
setEqualsMethod
public final void setEqualsMethod(boolean equals)
Sets the 'equalsmethod' property.- Parameters:
equals- The value we want to use.
-
classDescFieldNames
public final boolean classDescFieldNames()
Returns true if we generate a 'public static final String' for the name of each attribute and element described by the class descriptorEnabling this property is controlled via the org.exolab.castor.builder.classdescfieldnames item in the castorbuilder.properties file. The value is either 'true' or 'false'.
- Returns:
- true if bound properties are enabled.
-
generateExtraCollectionMethods
public final boolean generateExtraCollectionMethods()
Returns true if extra methods for collection fields should be generated. Such methods include set/get methods for the actual collection in addition to the array methods.Enabling extra collection methods is controlled via the org.exolab.castor.builder.extraCollectionMethods property in the castorbuilder.properties file. The value is either 'true' or 'false'.
- Returns:
- true if extra collection methods are enabled.
-
setClassDescFieldNames
public final void setClassDescFieldNames(boolean classDescFieldNames)
Sets the 'classDescFieldNames' property.- Parameters:
classDescFieldNames- the value we want to ues
-
usePrimitiveWrapper
public final boolean usePrimitiveWrapper()
Returns true if primitive types have to be used as Objects (eg. replacingfloatbyjava.lang.Float).- Returns:
- true if primitive types have to be used as Objects.
-
setPrimitiveWrapper
public final void setPrimitiveWrapper(boolean wrapper)
Sets the 'primitivetowrapper' property.- Parameters:
wrapper- the value we want to use.
-
useEnumeratedTypeInterface
public final boolean useEnumeratedTypeInterface()
Returns true if we generate the implements EnumeratedTypeAccess interface for enumerated type classes. The value is either 'true' or 'false'- Returns:
- true if use enumerated type interface is enabled
-
useJava50
public final boolean useJava50()
Returns true if we generate the implements EnumeratedTypeAccess interface for enumerated type classes. The value is either 'true' or 'false'- Returns:
- true if use enumerated type interface is enabled
-
useJava5Enums
public final boolean useJava5Enums()
Indicates what kind of enumeration should be created for <xs:simpleType> enumerations.- Returns:
- true if Java 5 source code should be generated.
-
forceUseJava50
public final void forceUseJava50()
Add support to set java version programmatically.
-
generateExtraDocumentationMethods
public final boolean generateExtraDocumentationMethods()
Returns true if extra methods for accessing XML schema documentation should be generated; default to 'false'.- Returns:
- true if if extra methods for accessing XML schema documentation should be generated
-
useCycleBreaker
public final boolean useCycleBreaker()
Returns true if the classCycleBreakershould be used during code generation; defaults to 'true'.- Returns:
- true if the class
CycleBreakershould be used during code generation
-
getMaximumNumberOfConstants
public final int getMaximumNumberOfConstants()
Returns the maximum number of static constant definitions that are acceptable within one class file; default is 1000.- Returns:
- the maximum number of static constant definitions acceptable within one class file
-
setUseEnumeratedTypeInterface
public final void setUseEnumeratedTypeInterface(boolean flag)
Sets the 'enumTypeAccessInterface' property.- Parameters:
flag- the value we want to use
-
mappingSchemaElement2Java
public boolean mappingSchemaElement2Java()
Tests the org.exolab.castor.builder.javaclassmapping property for the 'element' value.- Returns:
- True if the Source Generator is mapping schema elements to Java classes.
-
mappingSchemaType2Java
public boolean mappingSchemaType2Java()
Tests the org.exolab.castor.builder.javaclassmapping property for the 'type' value.- Returns:
- True if the Source Generator is mapping schema types to Java classes.
-
setDefaultProperties
public final void setDefaultProperties(java.util.Properties properties)
Overrides the current set of properties with the given properties. Once the properties are set, only a copy will be uses, so any changes to the given properties file after the fact will go unnoticed.- Parameters:
properties- the Properties file
-
setNamespacePackageMapping
public final void setNamespacePackageMapping(java.lang.String ns, java.lang.String packageName)Sets the namespace to package mapping.- Parameters:
ns- the namespace URI to mappackageName- the package name
-
setLocationPackageMapping
public final void setLocationPackageMapping(java.lang.String schemaLocation, java.lang.String packageName)Sets the schemaLocation to package mapping.- Parameters:
schemaLocation- the schemaLocation to mappackageName- the package name to map to
-
getJClassPrinterFactories
public final java.lang.String getJClassPrinterFactories()
Returns a String representing the list ofJClassPrinterFactoryinstances configured in the Castor XML code generator property file.- Returns:
- the list of
JClassPrinterFactoryinstances as configured, as string.
-
load
protected final void load()
Called bygetDefault()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.
-
lookupPackageByNamespace
public final java.lang.String lookupPackageByNamespace(java.lang.String nsURL)
Gets a Java package to an XML namespace URL.- Parameters:
nsURL- the XML namespace URL to convert into a Java package name- Returns:
- a Java package name
-
lookupPackageByLocation
public final java.lang.String lookupPackageByLocation(java.lang.String schemaLocation)
Converts a schema location into a Java package.- Parameters:
schemaLocation- the Schema location to use to look up the Java package- Returns:
- a Java package name
-
processNamespacePackageMappings
protected final void processNamespacePackageMappings(java.lang.String mappings)
processes the given String which contains namespace-to-package mappings.- Parameters:
mappings- the namespace-to-package mappings
-
isAutomaticConflictResolution
public boolean isAutomaticConflictResolution()
indicates whether automatic class name conflict resolution during XML code generation should take place or not.- Returns:
- True if automatic mode should be used.
-
getAutomaticConflictResolutionTypeSuffix
public java.lang.String getAutomaticConflictResolutionTypeSuffix()
Returns the type 'suffix' used for the type strategy during automatic class name conflict resolution during XML code generation; default to "" unless a value is specified.- Returns:
- The type suffix to be inserted between element name and type name
-
setJavaNaming
public void setJavaNaming(JavaNaming javaNaming)
To set theJavaNamingimplementation to be used.- Parameters:
javaNaming- JavaNaming implementation to be used- Since:
- 1.1.3
-
getJavaNaming
public JavaNaming getJavaNaming()
To get theJavaNamingimplementation to be used.- Returns:
- JavaNaming implementation to be used
- Since:
- 1.1.3
-
addAnnotationBuilder
public void addAnnotationBuilder(AnnotationBuilder annotationBuilder)
adds a custom annotation builder.- Parameters:
annotationBuilder- the builder
-
getAnnotationBuilders
public AnnotationBuilder[] getAnnotationBuilders()
returns all applied annotation builders.- Returns:
- a array of builders for type convenience
-
loadProperties
public static java.util.Properties loadProperties(java.lang.String resourceName, java.lang.String fileName)Load the configuration 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.- Parameters:
resourceName- Name of the source.fileName- Name of the configuration file.- Returns:
- A
Propertiesinstance holding the actual XML code generator configuration.
-
-