org.exolab.castor.builder

Class BuilderConfiguration

Known Direct Subclasses:
SourceGenerator

public class BuilderConfiguration
extends java.lang.Object

The configuration for the SourceGenerator
Version:
$Revision: 6302 $ $Date: 2006-04-25 15:08:23 -0600 (Tue, 25 Apr 2006) $
Authors:
Keith Visco
Arnaud Blandin

Nested Class Summary

static class
BuilderConfiguration.Property
Names of properties used in the configuration file.

Constructor Summary

BuilderConfiguration()
Creates a default BuilderConfiguration.

Method Summary

boolean
boundPropertiesEnabled()
Returns true if bound properties are enabled.
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.

boolean
equalsMethod()
Returns true if we generate an 'equals' method for each generated class.
boolean
generateExtraCollectionMethods()
Returns true if extra methods for collection fields should be generated.
Properties
getDefault()
Returns the default configuration file.
String
getProperty(String name, String defValue)
Returns a property from the default configuration file.
protected void
load()
Called by getDefault() to load the configuration the first time.
String
lookupPackageByLocation(String schemaLocation)
Converts a schema location into a Java package.
String
lookupPackageByNamespace(String nsURL)
Gets a Java package to an XML namespace URL
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.
protected void
processNamespacePackageMappings(String mappings)
processes the given String which contains namespace-to-package mappings
void
setClassDescFieldNames(boolean classDescFieldNames)
Sets the 'classDescFieldNames' property
void
setDefaultProperties(Properties properties)
Overrides the current set of properties with the given properties.
void
setEqualsMethod(boolean equals)
Sets the 'equalsmethod' property.
void
setLocationPackageMapping(String schemaLocation, String packageName)
Sets the schemaLocation to package mapping.
void
setNamespacePackageMapping(String ns, String packageName)
Sets the namespace to package mapping.
void
setPrimitiveWrapper(boolean wrapper)
Sets the 'primitivetowrapper' property
void
setUseEnumeratedTypeInterface(boolean flag)
Sets the 'enumTypeAccessInterface' property
boolean
useEnumeratedTypeInterface()
Returns true if we generate the implements EnumeratedTypeAccess interface for enumerated type classes.
boolean
useJava50()
Returns true if we generate the implements EnumeratedTypeAccess interface for enumerated type classes.
boolean
usePrimitiveWrapper()
Returns true if primitive types have to be used as Objects (eg.

Constructor Details

BuilderConfiguration

public BuilderConfiguration()
Creates a default BuilderConfiguration.

Method Details

boundPropertiesEnabled

public 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.

classDescFieldNames

public 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. The value is either 'true' or 'false'.

Returns:
true if bound properties are enabled.

equalsMethod

public 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.

generateExtraCollectionMethods

public 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.

getDefault

public 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 String getProperty(String name,
                          String defValue)
Parameters:
name - The property name
defValue - The property's default value
Returns:
The property's value

load

protected void load()
Called by 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.

lookupPackageByLocation

public String lookupPackageByLocation(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

lookupPackageByNamespace

public String lookupPackageByNamespace(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

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.

processNamespacePackageMappings

protected void processNamespacePackageMappings(String mappings)
processes the given String which contains namespace-to-package mappings
Parameters:
mappings - the namespace-to-package mappings

setClassDescFieldNames

public void setClassDescFieldNames(boolean classDescFieldNames)
Sets the 'classDescFieldNames' property
Parameters:
classDescFieldNames - the value we want to ues

setDefaultProperties

public void setDefaultProperties(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

setEqualsMethod

public void setEqualsMethod(boolean equals)
Sets the 'equalsmethod' property.
Parameters:
equals - The value we want to use.

setLocationPackageMapping

public void setLocationPackageMapping(String schemaLocation,
                                      String packageName)
Sets the schemaLocation to package mapping.
Parameters:
schemaLocation - the schemaLocation to map
packageName - the package name to map to

setNamespacePackageMapping

public void setNamespacePackageMapping(String ns,
                                       String packageName)
Sets the namespace to package mapping.
Parameters:
ns - the namespace URI to map
packageName - the package name

setPrimitiveWrapper

public void setPrimitiveWrapper(boolean wrapper)
Sets the 'primitivetowrapper' property
Parameters:
wrapper - the value we want to use.

setUseEnumeratedTypeInterface

public void setUseEnumeratedTypeInterface(boolean flag)
Sets the 'enumTypeAccessInterface' property
Parameters:
flag - the value we want to use

useEnumeratedTypeInterface

public 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 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

usePrimitiveWrapper

public boolean usePrimitiveWrapper()
Returns true if primitive types have to be used as Objects (eg. replacing float by java.lang.Float).
Returns:
true if primitive types have to be used as Objects.

Intalio Inc. (C) 1999-2006. All rights reserved http://www.intalio.com