Package org.jibx.schema.generator
Class DetailDirectory
- java.lang.Object
-
- org.jibx.schema.generator.DetailDirectory
-
public class DetailDirectory extends java.lang.Object
Directory for components included in schema generation. This includes both <mapping> elements of the bindings and special formats, with the latter currently limited to enumeration types. The building code works from a supplied list of bindings, walking the tree structure of the bindings to find all mappings and processing each mapping directly using the lists of child components. It creates mapping details and sets flags for the types of access to each mapping, as well as creating enumeration details and counting usage to select globals.- Author:
- Dennis M. Sosnoski
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
DetailDirectory.AnalysisVisitor
Model visitor for analyzing the structure of bindings and determining the appropriate schema components.
-
Field Summary
Fields Modifier and Type Field Description private ValidationContext
m_context
Validation context for bindings.private GlobalCustom
m_custom
Binding customization information.private java.util.Map
m_enumMap
Map from class name to enumeration detail.private java.util.Set
m_forceTypeMappings
Set of <mapping> definitions used as base types.private java.util.Map
m_mappingMap
Map from <mapping> definition to mapping detail.
-
Constructor Summary
Constructors Constructor Description DetailDirectory(GlobalCustom custom, ValidationContext vctx)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private MappingDetail
addDetail(MappingElement map)
Create the detail information for a <mapping>.private void
checkReferences(ContainerElementBase cont, ContainerElementBase base)
Check references to mappings or enumeration types from component children of binding container element.private void
countEnumUsage(java.lang.String type)
Count the usage of an enumeration type.protected MappingDetail
forceMappingDetail(MappingElement map)
Find detail information for a <mapping>.java.util.Collection
getComplexDetails()
Get all complex type details.MappingDetail
getMappingDetail(MappingElementBase map)
Get detail information for a <mapping>.EnumDetail
getSimpleDetail(java.lang.String type)
Get detail information for a simple type.java.util.Collection
getSimpleDetails()
Get all simple type details.private boolean
isEnumeration(IClass clas)
Check if class is an enumeration type.private boolean
isSimpleValue(IClass clas)
Check if class is a simple value type.private static boolean
isTypeDerivation(StructureElement struct)
Check if a <structure> element represents a type derivation.void
populate(java.util.List bindings)
Populate the mapping directory from a supplied list of root bindings.
-
-
-
Field Detail
-
m_custom
private final GlobalCustom m_custom
Binding customization information.
-
m_context
private final ValidationContext m_context
Validation context for bindings.
-
m_mappingMap
private final java.util.Map m_mappingMap
Map from <mapping> definition to mapping detail.
-
m_enumMap
private final java.util.Map m_enumMap
Map from class name to enumeration detail.
-
m_forceTypeMappings
private final java.util.Set m_forceTypeMappings
Set of <mapping> definitions used as base types.
-
-
Constructor Detail
-
DetailDirectory
public DetailDirectory(GlobalCustom custom, ValidationContext vctx)
Constructor.- Parameters:
custom
- binding customization information (used for creating names as needed)vctx
- binding validation context
-
-
Method Detail
-
populate
public void populate(java.util.List bindings)
Populate the mapping directory from a supplied list of root bindings. This uses a visitor to analyze the bindings, building the detail information to be used during the actual generation process.- Parameters:
bindings
-
-
isTypeDerivation
private static boolean isTypeDerivation(StructureElement struct)
Check if a <structure> element represents a type derivation. If the element is empty, has no name or property, is required, and is a mapping reference, then it can be handled as a type derivation.- Parameters:
struct
-- Returns:
true
if a type derivation,false
if not
-
isEnumeration
private boolean isEnumeration(IClass clas)
Check if class is an enumeration type.- Parameters:
clas
-- Returns:
- enumeration type flag
-
isSimpleValue
private boolean isSimpleValue(IClass clas)
Check if class is a simple value type.- Parameters:
clas
-- Returns:
- simple value type flag
-
countEnumUsage
private void countEnumUsage(java.lang.String type)
Count the usage of an enumeration type. The first time this is called for a type it just creates the enumeration detail, then if called again for the same type it flags it as a global.- Parameters:
type
-
-
checkReferences
private void checkReferences(ContainerElementBase cont, ContainerElementBase base)
Check references to mappings or enumeration types from component children of binding container element. This allows for skipping a base mapping reference, so that mappings with type extension components can be handled (with the extension component processed separately, since it's a special case).- Parameters:
cont
- container elementbase
- child element representing base mapping reference (null
if none)
-
addDetail
private MappingDetail addDetail(MappingElement map)
Create the detail information for a <mapping>. This creates the detail information and adds it to the map, then analyzes the structure of the mapping to find references to other mappings and to enumeration types.- Parameters:
map
-- Returns:
- detail
-
forceMappingDetail
protected MappingDetail forceMappingDetail(MappingElement map)
Find detail information for a <mapping>. If this is the first time a particular mapping was requested, a new detail information will be created for that mapping and returned.- Parameters:
map
-- Returns:
- detail
-
getMappingDetail
public MappingDetail getMappingDetail(MappingElementBase map)
Get detail information for a <mapping>. If the detail information does not exist, this throws an exception.- Parameters:
map
-- Returns:
- detail
-
getSimpleDetail
public EnumDetail getSimpleDetail(java.lang.String type)
Get detail information for a simple type. If the detail information does not exist, this throws an exception.- Parameters:
type
-- Returns:
- detail
-
getComplexDetails
public java.util.Collection getComplexDetails()
Get all complex type details.- Returns:
- collection of
MappingDetail
-
getSimpleDetails
public java.util.Collection getSimpleDetails()
Get all simple type details.- Returns:
- collection of
EnumDetail
-
-