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 HashSet
Set of compatible type names.private HashMap
Map from format names toString
conversions (lazy create).private final ClassHierarchyContext
Link to containing context.private HashMap
Map from type name to binding component. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
accumulateInterfaces
(IClass clas, Set intfset) Accumulate all the interfaces implemented (both directly and indirectly) by a class.void
addNamedComponent
(String label, ElementBase comp, ValidationContext vctx) Add named component to set defined at this level.void
addTypedComponent
(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.boolean
isCompatibleType
(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 toString
conversions (lazy create).
-
-
Constructor Details
-
ClassHierarchyContext
Constructor.- Parameters:
outer
- containing context (null
if at root of tree)
-
-
Method Details
-
getContaining
Get containing context.- Returns:
- containing context information (
null
if 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
null
if 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
null
if 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
null
if 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:
true
if compatible type,false
if not
-