org.jibx.custom.classes
Class GlobalCustom

java.lang.Object
  extended by org.jibx.custom.classes.CustomBase
      extended by org.jibx.custom.classes.SharedNestingBase
          extended by org.jibx.custom.classes.NestingBase
              extended by org.jibx.custom.classes.GlobalCustom

public class GlobalCustom
extends NestingBase

Global customization information. This includes some options specific to the <binding> element of the definition, as well as controls for structuring of the generated binding(s). It handles the binding customization child elements directly, by invoking the abstract unmarshallers for the child elements to process the content. It also allows for extension elements which are not part of the binding customization structure, as long as the binding in use defines the unmarshalling for these elements.

Author:
Dennis M. Sosnoski

Nested Class Summary
static class GlobalCustom.Mapper
          Unmarshaller implementation for class.
 
Field Summary
static int BOTH_BINDING
           
static java.lang.String ELEMENT_NAME
          Element name in XML customization file.
static int IN_BINDING
           
private  boolean m_addConstructors
           
private  IClassLocator m_classLocator
           
private  java.util.List m_extensionChildren
           
private  boolean m_forceClasses
           
private  boolean m_isInput
           
private  boolean m_isOutput
           
private  boolean m_namespaceModular
           
private  java.util.Map m_packageMap
           
private  boolean m_trackSource
           
private  java.util.ArrayList m_unmarshalledClasses
           
static int OUT_BINDING
           
static StringArray s_allowedAttributes
          Enumeration of allowed attribute names
(package private) static EnumSet s_directionEnum
           
 
Fields inherited from class org.jibx.custom.classes.NestingBase
ATTRIBUTE_STYLE_INTEGER, ATTRIBUTE_VALUE_STYLE, ELEMENT_STYLE_INTEGER, ELEMENT_VALUE_STYLE, s_valueStyleEnum
 
Fields inherited from class org.jibx.custom.classes.CustomBase
CAMEL_CASE_NAMES, DERIVE_BY_PACKAGE, DERIVE_FIXED, DERIVE_NONE, DOTTED_NAMES, HYPHENATED_NAMES, REQUIRE_ALL, REQUIRE_NONE, REQUIRE_OBJECTS, REQUIRE_PRIMITIVES, s_namespaceStyleEnum, s_nameStyleEnum, s_requireEnum, UNDERSCORED_NAMES, UPPER_CAMEL_CASE_NAMES
 
Constructor Summary
GlobalCustom()
          Constructor.
GlobalCustom(IClassLocator loc)
          Constructor with class locator supplied.
 
Method Summary
 ClassCustom addClassCustomization(java.lang.String type)
          Get initialized class customization information, creating it if it doesn't already exist.
 void addExtensionChild(java.lang.Object child)
          Add a child extension element.
private  ClassCustom buildClassCustomization(java.lang.String type)
          Build new class customization information.
 void fillClasses()
          Fills in class information based on inspection of the actual class data.
private  ClassCustom forceClassCustomization(java.lang.String type)
          Get class customization information, creating it if it doesn't already exist.
 ClassCustom getClassCustomization(java.lang.String type)
          Get class customization information.
 IClass getClassInfo(java.lang.String type)
          Get class information.
protected  IClassLocator getClassLocator()
          Get class locator.
private  java.lang.String getDirectionText()
          Direction get text method.
 java.util.List getExtensionChildren()
          Get the extension elements used in this customization.
 GlobalCustom getGlobal()
          Get global customizations root.
 PackageCustom getPackage(java.lang.String name)
          Get package customizations.
 java.util.ArrayList getUnmarshalledClasses()
          Get list of unmarshalled classes.
 void initClasses()
          Initialize the global default namespace, along with special classes with built-in defaults.
protected  void internalAddExtensionChild(java.lang.Object child)
          Internal method used during unmarshalling to add a child extension element.
 boolean isAddConstructors()
          Get 'add-constructors' setting.
 boolean isClassUsed(java.lang.String type)
          Check if a class is included in the customization information.
 boolean isForceClasses()
          Get 'force-classes' setting.
 boolean isInput()
          Check for an input binding.
 boolean isKnownMapping(java.lang.String type)
          Check if type represents a known mapping.
 boolean isOutput()
          Check for an output binding.
 boolean isTrackSource()
          Get 'track-source' attribute value.
private  void preSet(IUnmarshallingContext uctx)
          Make sure all attributes are defined.
 void setAddConstructors(boolean add)
          Set 'add-constructors' value.
private  void setDirectionText(java.lang.String text, IUnmarshallingContext ictx)
          Direction set text method.
 void setForceClasses(boolean force)
          Set 'force-classes' value.
 void setInput(boolean input)
          Set input binding flag.
 void setOutput(boolean output)
          Set output binding falg.
 void setTrackSource(boolean track)
          Set 'track-source' value.
 
Methods inherited from class org.jibx.custom.classes.NestingBase
getStripPrefixes, getStripSuffixes, getValueStyle, isForceMapping, isForceStructureNames, isMapAbstract, isPropertyAccess, isWrapCollections, setMapAbstract, setValueStyle
 
Methods inherited from class org.jibx.custom.classes.SharedNestingBase
convertName, getFormatterClass, getNamespace, getNamespaceStyle, getNameStyle, getSpecifiedNamespace, isObjectRequired, isPrimitiveRequired, isUseJavaDocs, setNamespace, setNamespaceStyle, setNameStyle
 
Methods inherited from class org.jibx.custom.classes.CustomBase
convertName, deriveItemName, deriveNamespace, getContainingObject, getParent, packageOfType, packageToNamespace, validateAttributes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s_allowedAttributes

public static final StringArray s_allowedAttributes
Enumeration of allowed attribute names


ELEMENT_NAME

public static final java.lang.String ELEMENT_NAME
Element name in XML customization file.

See Also:
Constant Field Values

IN_BINDING

public static final int IN_BINDING
See Also:
Constant Field Values

OUT_BINDING

public static final int OUT_BINDING
See Also:
Constant Field Values

BOTH_BINDING

public static final int BOTH_BINDING
See Also:
Constant Field Values

s_directionEnum

static final EnumSet s_directionEnum

m_packageMap

private java.util.Map m_packageMap

m_classLocator

private final IClassLocator m_classLocator

m_extensionChildren

private java.util.List m_extensionChildren

m_addConstructors

private boolean m_addConstructors

m_forceClasses

private boolean m_forceClasses

m_trackSource

private boolean m_trackSource

m_namespaceModular

private boolean m_namespaceModular

m_isInput

private boolean m_isInput

m_isOutput

private boolean m_isOutput

m_unmarshalledClasses

private java.util.ArrayList m_unmarshalledClasses
Constructor Detail

GlobalCustom

public GlobalCustom(IClassLocator loc)
Constructor with class locator supplied.

Parameters:
loc -

GlobalCustom

public GlobalCustom()
Constructor. This always creates the default package as the only direct child, since other packages will be treated as children of the default package.

Method Detail

preSet

private void preSet(IUnmarshallingContext uctx)
Make sure all attributes are defined.

Parameters:
uctx - unmarshalling context

getGlobal

public GlobalCustom getGlobal()
Get global customizations root.

Overrides:
getGlobal in class CustomBase
Returns:
global customization

getUnmarshalledClasses

public java.util.ArrayList getUnmarshalledClasses()
Get list of unmarshalled classes. This list is populated by the custom unmarshalling code as the customizations document is unmarshalled.

Returns:
list

isAddConstructors

public boolean isAddConstructors()
Get 'add-constructors' setting.

Returns:
'add-constructors' value

setAddConstructors

public void setAddConstructors(boolean add)
Set 'add-constructors' value.

Parameters:
add - 'add-constructors' value

isForceClasses

public boolean isForceClasses()
Get 'force-classes' setting.

Returns:
'force-classes' value

setForceClasses

public void setForceClasses(boolean force)
Set 'force-classes' value.

Parameters:
force - 'force-classes' value

isTrackSource

public boolean isTrackSource()
Get 'track-source' attribute value.

Returns:
'track-source' value

setTrackSource

public void setTrackSource(boolean track)
Set 'track-source' value.

Parameters:
track - 'track-source' value

isInput

public boolean isInput()
Check for an input binding.

Returns:
input flag

setInput

public void setInput(boolean input)
Set input binding flag.

Parameters:
input -

isOutput

public boolean isOutput()
Check for an output binding.

Returns:
output flag

setOutput

public void setOutput(boolean output)
Set output binding falg.

Parameters:
output -

getClassLocator

protected IClassLocator getClassLocator()
Get class locator.

Returns:
locator

getClassInfo

public IClass getClassInfo(java.lang.String type)
Get class information.

Parameters:
type - fully-qualified class name
Returns:
information, or null if unable to load

getExtensionChildren

public java.util.List getExtensionChildren()
Get the extension elements used in this customization. This does not include the <package> or <class> child elements, which are added directly to the customization structures.

Returns:
child list

internalAddExtensionChild

protected void internalAddExtensionChild(java.lang.Object child)
Internal method used during unmarshalling to add a child extension element.

Parameters:
child -

addExtensionChild

public void addExtensionChild(java.lang.Object child)
Add a child extension element. This both adds the child to the list and invokes the extension element's IApply.apply(IClassLocator) method, if present.

Parameters:
child -

isClassUsed

public boolean isClassUsed(java.lang.String type)
Check if a class is included in the customization information. This method does not alter the structures in any way, it only checks if the class customization information is part of the existing structure.

Parameters:
type - fully qualified class name
Returns:
true if class includes, false if not

getClassCustomization

public ClassCustom getClassCustomization(java.lang.String type)
Get class customization information.

Parameters:
type - fully qualified class name
Returns:
class information (null if not defined)

buildClassCustomization

private ClassCustom buildClassCustomization(java.lang.String type)
Build new class customization information. This creates the customization information and adds it to the internal structures, initializing all values based on the settings inherited from <package> and <global> elements of the structure. This method should only be used after first calling getClassCustomization(String) and obtaining a null result.

Parameters:
type - fully qualified class name
Returns:
class information

forceClassCustomization

private ClassCustom forceClassCustomization(java.lang.String type)
Get class customization information, creating it if it doesn't already exist. This internal method supplies the class information in uninitialized form, so that data can be unmarshalled before initialization.

Parameters:
type - fully qualified class name
Returns:
class information

addClassCustomization

public ClassCustom addClassCustomization(java.lang.String type)
Get initialized class customization information, creating it if it doesn't already exist.

Parameters:
type - fully qualified class name
Returns:
class information

isKnownMapping

public boolean isKnownMapping(java.lang.String type)
Check if type represents a known mapping.

Parameters:
type - fully qualified class name
Returns:
known mapping flag

setDirectionText

private void setDirectionText(java.lang.String text,
                              IUnmarshallingContext ictx)
Direction set text method. This is intended for use during unmarshalling. TODO: add validation

Parameters:
text -
ictx -

getDirectionText

private java.lang.String getDirectionText()
Direction get text method. This is intended for use during marshalling.

Returns:
text

initClasses

public void initClasses()
Initialize the global default namespace, along with special classes with built-in defaults. This needs to be done as a separate step before unmarshalling, so that the special classes are available for use.


fillClasses

public void fillClasses()
Fills in class information based on inspection of the actual class data. This needs to be done as a separate step following unmarshalling, so that the full details of the unmarshalled customizations are available.


getPackage

public PackageCustom getPackage(java.lang.String name)
Get package customizations. If the requested package is already defined the existing instance will be returned, otherwise a new instance will be created (along with any ancestor packages) and added to the structure.

Parameters:
name -
Returns:
package


Project Web Site