Package org.jibx.binding.model
Class ClassHierarchyContext
java.lang.Object
org.jibx.binding.model.ClassHierarchyContext
Context for components using a hierarchy of definitions based on class type.
This is used to track conversion definitions in the form of format and
template elements. The access methods take the different levels of
nesting into account, automatically delegating to the containing context (if
defined) when a lookup fails.
- Author:
- Dennis M. Sosnoski
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate HashSetSet of compatible type names.private HashMapMap from format names toStringconversions (lazy create).private final ClassHierarchyContextLink to containing context.private HashMapMap from type name to binding component. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaccumulateInterfaces(IClass clas, Set intfset) Accumulate all the interfaces implemented (both directly and indirectly) by a class.voidaddNamedComponent(String label, ElementBase comp, ValidationContext vctx) Add named component to set defined at this level.voidaddTypedComponent(IClass clas, ElementBase comp, ValidationContext vctx) Add typed component to set defined at this level.Get containing context.Get best binding component for class.getNamedComponent(String name) Get named binding component definition.getSpecificComponent(String name) Get specific binding component for type.booleanisCompatibleType(IClass clas) Checks if a class is compatible with one or more components.
-
Field Details
-
m_outerContext
Link to containing context. -
m_typeToComponentMap
Map from type name to binding component. -
m_compatibleTypeSet
Set of compatible type names. -
m_nameToComponentMap
Map from format names toStringconversions (lazy create).
-
-
Constructor Details
-
ClassHierarchyContext
Constructor.- Parameters:
outer- containing context (nullif at root of tree)
-
-
Method Details
-
getContaining
Get containing context.- Returns:
- containing context information (
nullif at root of tree)
-
accumulateInterfaces
Accumulate all the interfaces implemented (both directly and indirectly) by a class.- Parameters:
clas-intfset- set of interfaces
-
addTypedComponent
Add typed component to set defined at this level. This associates the component with the type for class hierarchy-based lookups.- Parameters:
clas- class information to be associated with componentcomp- definition component to be addedvctx- validation context in use
-
addNamedComponent
Add named component to set defined at this level. TODO: Make this use qname instead of text- Parameters:
label- name to be associated with componentcomp- definition component to be addedvctx- validation context in use
-
getSpecificComponent
Get specific binding component for type. Looks for an exact match on the type name, checking the containing definitions if a matching component is not found at this level.- Parameters:
name- fully qualified class name to be converted- Returns:
- binding component for class, or
nullif not found
-
getNamedComponent
Get named binding component definition. Finds the component with the supplied name, checking the containing definitions if the component is not found at this level.- Parameters:
name- component name to be found- Returns:
- binding component with name, or
nullif not found
-
getMostSpecificComponent
Get best binding component for class. Finds the component based on a fully qualified class name. If a specific component for the actual class is not found (either in this or a containing level) this returns the most specific superclass component.- Parameters:
clas- information for target class- Returns:
- binding component definition for class, or
nullif none found
-
isCompatibleType
Checks if a class is compatible with one or more components. If a specific component for the actual class is not found (either in this or a containing level) this checks for components that handle subclasses or implementations of the class.- Parameters:
clas- information for target class- Returns:
trueif compatible type,falseif not
-