Package org.jibx.binding.model
Class DefinitionContext
java.lang.Object
org.jibx.binding.model.DefinitionContext
Definition context information. This is used to track definitions of items
that can be referenced by other items. The contexts are nested, so that names
not found in a context may be defined by a containing context. The access
methods take this into account, automatically delegating to the containing
context (if defined) when a lookup fails.
- Author:
- Dennis M. Sosnoski
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate NamespaceElement
Namespace used by default at this level for attributes.private NamespaceElement
Namespace used by default at this level for elements.private ClassHierarchyContext
Class hierarchy context for format definitions (lazy create).private HashMap
Map from element names to mappings defined at level (lazy create).private HashMap
Named binding components (lazy create).private ArrayList
Namespaces defined at level (lazy create).private final DefinitionContext
Link to containing definition context.private HashMap
Mapping from prefix to namespace definition (lazy create).private ClassHierarchyContext
Class hierarchy context for template definitions (lazy create).private HashMap
Mapping from URI to namespace definition (lazy create). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFormat
(FormatElement def, ValidationContext vctx) Add format to set defined at this level.addImpliedNamespace
(NamespaceElement def, ElementBase ref) Add namespace declaration to set defined at this level.void
addMappedName
(NameAttributes name, MappingElementBase def, ValidationContext vctx) Add mapped name to set defined at this level.Add named structure to set defined in this context.Add namespace to set defined at this level.void
addTemplate
(MappingElementBase def, ValidationContext vctx) Add template or mapping to set defined at this level.private NamespaceElement
Check for namespace using the same prefix.Get namespace definition for attribute name.getBestFormat
(IClass clas) Get best format definition for class.Get containing context.private ClassHierarchyContext
Get containing format context.private ClassHierarchyContext
Get containing template context.Get the default namespace applied to element definitions.getElementNamespace
(NameAttributes name, ValidationContext vctx) Get namespace definition for element name.private ClassHierarchyContext
Get current format context.(package private) DefinitionContext
Copy a context for use by an included binding.getNamedFormat
(String name) Get named format definition.getNamedStructure
(String label) Get labeled structure definition within this context.getNamedTemplate
(String name) Get named template definition.getNamespaceForPrefix
(String prefix) Get namespace for prefix.Get the namespaces defined in this contextgetSpecificFormat
(String type) Get specific format definition for type.getSpecificTemplate
(String type) Get specific template definition for type.private ClassHierarchyContext
Get current template context.(package private) void
Inject namespaces from this context into another context.private ValidationProblem
internalAddNamespace
(NamespaceElement def, boolean report) Add namespace to internal tables.boolean
Checks if a class is compatible with one or more templates.
-
Field Details
-
m_outerContext
Link to containing definition context. -
m_attributeDefault
Namespace used by default at this level for attributes. -
m_elementDefault
Namespace used by default at this level for elements. -
m_namespaces
Namespaces defined at level (lazy create). -
m_prefixMap
Mapping from prefix to namespace definition (lazy create). -
m_uriMap
Mapping from URI to namespace definition (lazy create). -
m_mappingMap
Map from element names to mappings defined at level (lazy create). -
m_formatContext
Class hierarchy context for format definitions (lazy create). -
m_templateContext
Class hierarchy context for template definitions (lazy create). -
m_namedStructureMap
Named binding components (lazy create).
-
-
Constructor Details
-
DefinitionContext
Constructor.- Parameters:
outer
- containing definition context (null
if at root of tree)
-
-
Method Details
-
getIncludeCopy
DefinitionContext getIncludeCopy()Copy a context for use by an included binding. The duplicated context has the same containing context as the original, and shared reference structures for formats and templates, but only a static copy of the namespace definitions.- Returns:
- context copy for included binding
-
injectNamespaces
Inject namespaces from this context into another context. This is intended for includes, where the included binding inherits the namespace declarations of the containing binding.- Parameters:
to
-
-
getContaining
Get containing context.- Returns:
- containing context information (
null
if at root of tree)
-
getContainingFormatContext
Get containing format context.- Returns:
- innermost containing context for format definitions
(
null
none defined)
-
getFormatContext
Get current format context.- Returns:
- innermost context for format definitions (
null
none defined)
-
getContainingTemplateContext
Get containing template context.- Returns:
- innermost containing context for template definitions
(
null
none defined)
-
getTemplateContext
Get current template context.- Returns:
- innermost context for template definitions (
null
none defined)
-
getElementDefaultNamespace
Get the default namespace applied to element definitions. If there's no default namespace at this level of definitions this moves up the nested definitions contexts until one is found.- Returns:
- default namespace (
null
if none)
-
getNamespaceForPrefix
Get namespace for prefix.- Parameters:
prefix
-- Returns:
- namespace definition in this context,
null
if none
-
checkDuplicatePrefix
Check for namespace using the same prefix. This also intializes the namespace structures for this context the first time the method is called.- Parameters:
def
-- Returns:
- namespace definition using same prefix,
null
if none
-
internalAddNamespace
Add namespace to internal tables.- Parameters:
def
-report
- report default conflicts as error flag- Returns:
- problem information, or
null
if no problem
-
addNamespace
Add namespace to set defined at this level.- Parameters:
def
- namespace definition element to be added (duplicates ignored)- Returns:
- problem information, or
null
if no problem
-
addImpliedNamespace
Add namespace declaration to set defined at this level.- Parameters:
def
- namespace definition to be added (duplicates ignored)ref
- binding element referencing the namespace- Returns:
- problem information, or
null
if no problem
-
getElementNamespace
Get namespace definition for element name. TODO: handle multiple prefixes for namespace, proper screening- Parameters:
name
- attribute group defining namevctx
- validation context in use- Returns:
- namespace definition, or
null
if none that matches
-
getAttributeNamespace
Get namespace definition for attribute name. TODO: handle multiple prefixes for namespace, proper screening- Parameters:
name
- attribute group defining name- Returns:
- namespace definition, or
null
if none that matches
-
addFormat
Add format to set defined at this level.- Parameters:
def
- format definition element to be addedvctx
- validation context in use
-
getSpecificFormat
Get specific format definition for type. Finds with an exact match on the class name, checking the containing definitions if a format is not found at this level.- Parameters:
type
- fully qualified class name to be converted- Returns:
- conversion definition for class, or
null
if not found
-
getNamedFormat
Get named format definition. Finds the format with the supplied name, checking the containing definitions if the format is not found at this level.- Parameters:
name
- conversion name to be found- Returns:
- conversion definition with specified name, or
null
if no conversion with that name
-
getBestFormat
Get best format definition for class. Finds the format based on the inheritance hierarchy for the supplied class. If a specific format for the actual class is not found (either in this or a containing level) this returns the most specific superclass format.- Parameters:
clas
- information for target conversion class- Returns:
- conversion definition for class, or
null
if no compatible conversion defined
-
addMappedName
Add mapped name to set defined at this level.- Parameters:
name
- mapped namedef
- mapping definitionvctx
- validation context
-
addTemplate
Add template or mapping to set defined at this level.- Parameters:
def
- template definition element to be addedvctx
- validation context in use
-
getSpecificTemplate
Get specific template definition for type. Finds with an exact match on the class name, checking the containing definitions if a template is not found at this level.- Parameters:
type
- fully qualified class name to be converted- Returns:
- template definition for type, or
null
if not found
-
getNamedTemplate
Get named template definition. Finds the template with the supplied name, checking the containing definitions if the template is not found at this level. TODO: Make this specific to TemplateElement in 2.0- Parameters:
name
- conversion name to be found- Returns:
- template definition for class, or
null
if no template with that name
-
isCompatibleTemplateType
Checks if a class is compatible with one or more templates. This checks based on the inheritance hierarchy for the supplied class, looks for the class or interface itself as well as any subclasses or implementations.- Parameters:
clas
- information for target class- Returns:
true
if compatible type,false
if not
-
addNamedStructure
Add named structure to set defined in this context. For named structures only the definition context associated with the binding element should be used. This is a kludge, but will go away in 2.0.- Parameters:
def
- structure definition- Returns:
- problem information, or
null
if no problem
-
getNamedStructure
Get labeled structure definition within this context. For named structures only the definition context associated with the binding element should be used. This is a kludge, but will go away in 2.0.- Parameters:
label
- structure definition label- Returns:
- structure definition with specified label, or
null
if not defined
-
getNamespaces
Get the namespaces defined in this context- Returns:
- namespace definitions (may be
null
if none)
-