org.jibx.binding.model
Class ClassHierarchyContext

java.lang.Object
  extended by org.jibx.binding.model.ClassHierarchyContext

public class ClassHierarchyContext
extends Object

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

Constructor Summary
protected ClassHierarchyContext(ClassHierarchyContext outer)
          Constructor.
 
Method Summary
 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.
 ClassHierarchyContext getContaining()
          Get containing context.
 ElementBase getMostSpecificComponent(IClass clas)
          Get best binding component for class.
 ElementBase getNamedComponent(String name)
          Get named binding component definition.
 ElementBase getSpecificComponent(String name)
          Get specific binding component for type.
 boolean isCompatibleType(IClass clas)
          Checks if a class is compatible with one or more components.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassHierarchyContext

protected ClassHierarchyContext(ClassHierarchyContext outer)
Constructor.

Parameters:
outer - containing context (null if at root of tree)
Method Detail

getContaining

public ClassHierarchyContext getContaining()
Get containing context.

Returns:
containing context information (null if at root of tree)

addTypedComponent

public void addTypedComponent(IClass clas,
                              ElementBase comp,
                              ValidationContext vctx)
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 component
comp - definition component to be added
vctx - validation context in use

addNamedComponent

public void addNamedComponent(String label,
                              ElementBase comp,
                              ValidationContext vctx)
Add named component to set defined at this level. TODO: Make this use qname instead of text

Parameters:
label - name to be associated with component
comp - definition component to be added
vctx - validation context in use

getSpecificComponent

public ElementBase getSpecificComponent(String name)
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

public ElementBase getNamedComponent(String name)
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

public ElementBase getMostSpecificComponent(IClass clas)
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

public boolean isCompatibleType(IClass clas)
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


Copyright © 2005-2011 jibx.org. All Rights Reserved.