Package org.jibx.schema.codegen
Class StructureClassHolder
java.lang.Object
org.jibx.schema.codegen.TypeData
org.jibx.schema.codegen.ClassHolder
org.jibx.schema.codegen.StructureClassHolder
- All Implemented Interfaces:
IClassHolder
Information for a data class to be included in code generated from schema.
- Author:
- Dennis M. Sosnoski
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jibx.schema.codegen.ClassHolder
ClassHolder.DataNode, ClassHolder.LeafNode, ClassHolder.ParentNode -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Stringprivate ContainerElementBaseBinding definition element for this class.private booleanFlag for collection present in class.private ClassHolder.ParentNodeRoot node for data structure of class.protected UniqueNameSetSelection property names used in class (lazy create,nullif none).private static final MapDefault format definitions map.private static final LoggerLogger for class.Fields inherited from class org.jibx.schema.codegen.ClassHolder
COLLECTION_VARIABLE_NAME, COLLECTION_VARIABLE_TYPE, m_baseName, m_decorators, m_holder, m_importsTracker, m_inners, m_listImplClass, m_nameConverter, m_nameSet, m_outerClass, m_package, m_useInnerClasses -
Constructor Summary
ConstructorsModifierConstructorDescriptionStructureClassHolder(String name, String base, PackageHolder pack, BindingHolder holder, NameConverter nconv, ClassDecorator[] decorators, boolean inner) Constructor.privateStructureClassHolder(String name, StructureClassHolder context) Constructor for creating a child inner class definition. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddFixedNames(ClassHolder.ParentNode wrapper) Add all fixed names in a group to the set of names defined for this class.private voidaddFlagProperty(String basename, ClassHolder.DataNode node, ClassBuilder builder) Add a flag property to the class.private voidaddInnerFormats(MappingElementBase mapping) Recursively add all inner enumeration classes as formats to a <mapping> definition.private StructureElementaddReferenceStructure(ClassHolder.LeafNode leaf, DefinitionItem def, boolean single, BindingHolder holder, ContainerElementBase bindcomp) Build the binding structure element for a reference to a class.private voidaddRepeatedProperty(String basename, ClassHolder.DataNode node, ClassBuilder builder) Add a multiple-valued property to the class.private voidaddSimpleProperty(String basename, ClassHolder.DataNode node, ClassBuilder builder) Add a simple property to the class.private voidaddToBinding(ClassHolder.ParentNode parent, QName wrapname, boolean wrapopt, boolean single, ContainerElementBase bindcomp, BindingHolder holder) Generate the binding for a parent node of the data structure tree.private voidaddToClass(ClassHolder.ParentNode parent) Generate the fields and methods for a wrapper around one or more properties.private voidaddToTree(GroupItem struct, String supertext, ClassHolder.ParentNode parent, BindingHolder bindhold) Populate a class data representation tree based on a supplied item tree.voidbuildDataStructure(GroupItem group, BindingHolder bindhold) Convert an item structure to a class representation.private ValueElementbuildValueBinding(ClassHolder.DataNode node, QName wrapname, String gname, String sname, BindingHolder holder) Build a <value> binding component for a field.private voidcheckIfMethod(ClassHolder.DataNode node, String seldesc, String valdesc, ClassBuilder builder) Generate a test method for a value, if it's part of a group with a selector.private StringfindDocumentation(boolean top, ClassHolder.DataNode node) Find the schema documentation associated with a data node.private voidfixFlexibleNames(ClassHolder.ParentNode parent, boolean innamed) Handle value name assignments for a group within this class.voidgenerate(boolean verbose, SourceBuilder builder) Generate this class.private voidgenerateSelectorCheck(ClassHolder.DataNode value, BlockBuilder block, ClassBuilder builder) Generate the code to check the selection on any containing selector group.private voidgenerateSelectorSet(ClassHolder.DataNode value, BlockBuilder block, ClassBuilder builder) Generate the code to check and set the selection on any containing selector group.private CollectionElementnewCollection(QName wrapname, boolean wrapopt, BindingHolder holder, ClassHolder.DataNode node) Create a new collection element for the binding.voidsetBinding(ContainerElementBase container) Set the binding component linked to this class.private voidsetCollectionName(String base, Item item) Convert base name to collection name.private voidsetMemberNames(String basename, ClassHolder.DataNode node) Set the field and get/set access method names for a property.private static voidsetName(QName qname, BindingHolder holder, StructureElementBase struct) Set the name and namespace URI for a <structure> or <collection> binding component.private static voidsetName(QName qname, BindingHolder holder, ValueElement value) Set the name and namespace URI for a <value> binding component.private voidsetStructureOptional(ClassHolder.DataNode value, boolean force, StructureElementBase struct) Set the optional state of a structure or collection element in the binding.private voidsetValueHandlingOptions(Item item, ValueElement value, BindingHolder holder) Set serializer/deserializer options for a <value> component of the binding.Methods inherited from class org.jibx.schema.codegen.ClassHolder
addField, addImport, addInterface, addMethod, addType, describe, extractDocumentation, finishClass, generateInner, getBuilder, getFields, getImports, getInterfaces, getMethods, getName, getOuterClass, getPackage, getSchemaCustom, getSortedFields, getSuperClass, getSuperClassName, getTypeName, importValueType, initClass, isGenerated, isSuperClassForced, setListImplementation, setSuperClass, setSuperClassNameMethods inherited from class org.jibx.schema.codegen.TypeData
getBindingName, getFullName, isPregenerated, isSimpleValueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jibx.schema.codegen.IClassHolder
getFullName
-
Field Details
-
LIST_DESERIALIZE_PREFIX
- See Also:
-
LIST_SERIALIZE_PREFIX
- See Also:
-
s_logger
private static final Logger s_loggerLogger for class. -
s_formatMap
Default format definitions map. -
m_collectionPresent
private boolean m_collectionPresentFlag for collection present in class. -
m_dataRoot
Root node for data structure of class. -
m_bindingElement
Binding definition element for this class. -
m_selectSet
Selection property names used in class (lazy create,nullif none).
-
-
Constructor Details
-
StructureClassHolder
public StructureClassHolder(String name, String base, PackageHolder pack, BindingHolder holder, NameConverter nconv, ClassDecorator[] decorators, boolean inner) Constructor.- Parameters:
name- class namebase- base class namepack- package informationholder- binding holdernconv- name converterdecorators- class decoratorsinner- use inner classes for substructures
-
StructureClassHolder
Constructor for creating a child inner class definition.- Parameters:
name- class namecontext- parent class
-
-
Method Details
-
addToTree
private void addToTree(GroupItem struct, String supertext, ClassHolder.ParentNode parent, BindingHolder bindhold) Populate a class data representation tree based on a supplied item tree. The mapping between the two trees is not one-to-one since item groupings may be ignored where irrelevant.- Parameters:
struct- root item in treesupertext- schema documentation passed in for item treeparent- containing data nodebindhold- associated binding definition holder
-
buildDataStructure
Convert an item structure to a class representation. This may include creating subsidiary classes (either as inner classes, or as separate standalone classes), where necessary.- Overrides:
buildDataStructurein classClassHolder- Parameters:
group- item groupbindhold- associated binding definition holder
-
setBinding
Set the binding component linked to this class.- Parameters:
container- binding definition element (<mapping> or <structure>)
-
addInnerFormats
Recursively add all inner enumeration classes as formats to a <mapping> definition. This is used to create the <format> elements for all nested enumerations, which need to be direct children of the <mapping> element for the top-level class.- Parameters:
mapping-
-
addFixedNames
Add all fixed names in a group to the set of names defined for this class. This calls itself recursively to handle nested groups.- Parameters:
wrapper-
-
setCollectionName
Convert base name to collection name. If using ajava.util.Listrepresentation the name is converted to singular form and "List" is appended; if using an array representation the name is converted to plural form.- Parameters:
base-item-
-
fixFlexibleNames
Handle value name assignments for a group within this class. This calls itself recursively to handle nested groups.- Parameters:
parent-innamed- flag for parent group name already fixed
-
generateSelectorSet
private void generateSelectorSet(ClassHolder.DataNode value, BlockBuilder block, ClassBuilder builder) Generate the code to check and set the selection on any containing selector group. This should be used when setting any value, including inside selector methods (if used), since selector groups may be nested.- Parameters:
value-block-builder-
-
generateSelectorCheck
private void generateSelectorCheck(ClassHolder.DataNode value, BlockBuilder block, ClassBuilder builder) Generate the code to check the selection on any containing selector group. This should be used when getting any value, including inside selector methods (if used), since selector groups may be nested.- Parameters:
value-block-builder-
-
checkIfMethod
private void checkIfMethod(ClassHolder.DataNode node, String seldesc, String valdesc, ClassBuilder builder) Generate a test method for a value, if it's part of a group with a selector.- Parameters:
node-seldesc- containing group descriptionvaldesc- description of this value within groupbuilder-
-
setStructureOptional
private void setStructureOptional(ClassHolder.DataNode value, boolean force, StructureElementBase struct) Set the optional state of a structure or collection element in the binding. The name for the structure or collection must be set before calling this method, since the presence or absence of a name determines whether optional status is passed down from a parent.- Parameters:
value- nodeforce- optional state forced flagstruct- binding structure
-
setName
Set the name and namespace URI for a <value> binding component. The value style must be set before making this call, since element and attribute elements are handled differently.- Parameters:
qname- qualified name to be set (nullif none)holder- binding containing the value definitionvalue- binding component
-
setName
Set the name and namespace URI for a <structure> or <collection> binding component.- Parameters:
qname- qualified name to be set (nullif none)holder- binding containing the structure or collection definitionstruct- binding component
-
buildValueBinding
private ValueElement buildValueBinding(ClassHolder.DataNode node, QName wrapname, String gname, String sname, BindingHolder holder) Build a <value> binding component for a field.- Parameters:
node-wrapname-gname-sname-holder-- Returns:
- constructed binding component
-
setMemberNames
Set the field and get/set access method names for a property.- Parameters:
basename-node-
-
addSimpleProperty
Add a simple property to the class. This adds the actual field definition, along with the appropriate access methods.- Parameters:
basename-node-builder-
-
addRepeatedProperty
Add a multiple-valued property to the class. This adds the actual field definition, along with the appropriate access methods.- Parameters:
basename-node-builder-
-
addFlagProperty
Add a flag property to the class. This adds the actual field definition, along with the appropriate access methods.- Parameters:
basename-node-builder-
-
findDocumentation
Find the schema documentation associated with a data node. If the node has documentation set and does not have a separate class, this just returns the documentation from that node. Otherwise, it moves up the node tree until it finds a documented node, terminating if any parent has more than one child or when it reaches the node matching the root of the class data structure.- Parameters:
top- use topmost documentation found flagnode- starting node- Returns:
- documentation
-
addToClass
Generate the fields and methods for a wrapper around one or more properties. This calls itself recursively to handle nested wrappers.- Parameters:
parent-
-
addReferenceStructure
private StructureElement addReferenceStructure(ClassHolder.LeafNode leaf, DefinitionItem def, boolean single, BindingHolder holder, ContainerElementBase bindcomp) Build the binding structure element for a reference to a class.- Parameters:
leaf- reference nodedef- target definitionsingle- flag for single childholder- holder for binding definitionbindcomp- containing binding element- Returns:
- binding structure
-
newCollection
private CollectionElement newCollection(QName wrapname, boolean wrapopt, BindingHolder holder, ClassHolder.DataNode node) Create a new collection element for the binding. This initializes the create and declared types of the collection as appropriate, along with the wrapper name and optional status.- Parameters:
wrapname- name to be used for wrapper collection or structure,nullif nonewrapopt- wrapper element optional flag (should befalseif wrapname isnull)holder- binding definition tracking informationnode- data node associated with collection- Returns:
- collection element
-
setValueHandlingOptions
Set serializer/deserializer options for a <value> component of the binding. If the item defining the item is a reference, this uses the definition type name as the format and makes sure the definition namespace is defined within the binding being generated. If the item defining the item is a builtin type, this sets the format and/or serializer/deserializer methods based on the type definition.- Parameters:
item-value-holder-
-
addToBinding
private void addToBinding(ClassHolder.ParentNode parent, QName wrapname, boolean wrapopt, boolean single, ContainerElementBase bindcomp, BindingHolder holder) Generate the binding for a parent node of the data structure tree. This calls itself recursively to handle nested subtrees. TODO: This needs a more structured approach to creating the binding, which probably involves trying to merge the binding components down a particular branch of the tree as long as there's only one child (creating new structures as needed when the child has a name and there's already a name, or the child has a property and there's already a property, etc.)- Parameters:
parent- node to be added to bindingwrapname- name to be used for wrapper collection or structure,nullif nonewrapopt- wrapper element optional flag (should befalseif wrapname isnull)single- parent node binding component can be modified by child flag (single path from parent)bindcomp- binding definition component corresponding to the parent nodeholder- binding definition tracking information
-
generate
Generate this class.- Specified by:
generatein classClassHolder- Parameters:
verbose-builder- class source file builder
-