Package org.jibx.schema
Class NameRegister
- java.lang.Object
-
- org.jibx.schema.NameRegister
-
public class NameRegister extends java.lang.Object
Holder for registration of all global components of a schema by name.- Author:
- Dennis M. Sosnoski
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.HashMap
m_globalAttributeGroupMap
Direct attribute group definitions.private java.util.HashMap
m_globalAttributeMap
Direct attribute definitions.private java.util.HashMap
m_globalElementMap
Direct element definitions.private java.util.HashMap
m_globalGroupMap
Direct group definitions.private java.util.HashMap
m_globalTypeMap
Direct type definitions.private java.util.HashMap
m_importedAttributeGroupMap
External attribute group definitions (lazy create,null
if unused).private java.util.HashMap
m_importedAttributeMap
External attribute definitions (lazy create,null
if unused).private java.util.HashMap
m_importedElementMap
External element definitions (lazy create,null
if unused).private java.util.HashMap
m_importedGroupMap
External group definitions (lazy create,null
if unused).private java.util.HashMap
m_importedTypeMap
External type definitions (lazy create,null
if unused).
-
Constructor Summary
Constructors Constructor Description NameRegister()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AttributeElement
findAttribute(QName qname)
Find global attribute by name.AttributeGroupElement
findAttributeGroup(QName qname)
Find attribute group by name.ElementElement
findElement(QName qname)
Find global element by name.GroupElement
findGroup(QName qname)
Find group by name.private java.lang.Object
findInMaps(java.lang.Object key, java.util.HashMap map1, java.util.HashMap map2)
Find value in main or backup map.CommonTypeDefinition
findType(QName qname)
Find global type by name.void
mergeDefinitions(NameRegister mrg)
Merge definitions directly into this register.void
mergeDefinitionsNamespaced(java.lang.String uri, NameRegister mrg)
Merge external definitions into this register.void
mergeImportedDefinitions(NameRegister mrg)
Merge external definitions into this register.private java.util.HashMap
mergeLazyMap(java.util.HashMap source, java.util.HashMap target)
Merge one map into another, where the source map may be empty and the target map may benull
.private void
mergeMapNamespaced(java.lang.String uri, java.util.HashMap source, java.util.HashMap target)
Merge one QName map into another, changing the namespace URI for keys in the source map.AttributeElement
registerAttribute(QName qname, AttributeElement def)
Register global attribute in the current schema definition.AttributeGroupElement
registerAttributeGroup(QName qname, AttributeGroupElement def)
Register global attribute group in the current schema definition.ElementElement
registerElement(QName qname, ElementElement def)
Register global element in the current schema definition.GroupElement
registerGroup(QName qname, GroupElement def)
Register global group in the current schema definition.CommonTypeDefinition
registerType(QName qname, CommonTypeDefinition def)
Register global type in the current schema definition.void
reset()
Reset register for reuse.
-
-
-
Field Detail
-
m_globalAttributeMap
private java.util.HashMap m_globalAttributeMap
Direct attribute definitions.
-
m_importedAttributeMap
private java.util.HashMap m_importedAttributeMap
External attribute definitions (lazy create,null
if unused).
-
m_globalAttributeGroupMap
private java.util.HashMap m_globalAttributeGroupMap
Direct attribute group definitions.
-
m_importedAttributeGroupMap
private java.util.HashMap m_importedAttributeGroupMap
External attribute group definitions (lazy create,null
if unused).
-
m_globalElementMap
private java.util.HashMap m_globalElementMap
Direct element definitions.
-
m_importedElementMap
private java.util.HashMap m_importedElementMap
External element definitions (lazy create,null
if unused).
-
m_globalGroupMap
private java.util.HashMap m_globalGroupMap
Direct group definitions.
-
m_importedGroupMap
private java.util.HashMap m_importedGroupMap
External group definitions (lazy create,null
if unused).
-
m_globalTypeMap
private java.util.HashMap m_globalTypeMap
Direct type definitions.
-
m_importedTypeMap
private java.util.HashMap m_importedTypeMap
External type definitions (lazy create,null
if unused).
-
-
Method Detail
-
reset
public void reset()
Reset register for reuse.
-
registerAttribute
public AttributeElement registerAttribute(QName qname, AttributeElement def)
Register global attribute in the current schema definition.- Parameters:
qname
- namedef
- attribute definition- Returns:
- prior registered definition (
null
if none)
-
registerAttributeGroup
public AttributeGroupElement registerAttributeGroup(QName qname, AttributeGroupElement def)
Register global attribute group in the current schema definition.- Parameters:
qname
- namedef
- attribute definition- Returns:
- prior registered definition (
null
if none)
-
registerElement
public ElementElement registerElement(QName qname, ElementElement def)
Register global element in the current schema definition.- Parameters:
qname
- namedef
- element definition- Returns:
- prior registered definition (
null
if none)
-
registerGroup
public GroupElement registerGroup(QName qname, GroupElement def)
Register global group in the current schema definition.- Parameters:
qname
- namedef
- attribute definition- Returns:
- prior registered definition (
null
if none)
-
registerType
public CommonTypeDefinition registerType(QName qname, CommonTypeDefinition def)
Register global type in the current schema definition.- Parameters:
qname
- namedef
- attribute definition- Returns:
- prior registered definition (
null
if none)
-
findInMaps
private java.lang.Object findInMaps(java.lang.Object key, java.util.HashMap map1, java.util.HashMap map2)
Find value in main or backup map. If the (non-null
) value is present in the main map it is returned directly; otherwise, if the backup map is non-null
it is checked.- Parameters:
key
-map1
- main mapmap2
- backup map (null
if none)- Returns:
- value (
null
if value for key not in either map)
-
findAttribute
public AttributeElement findAttribute(QName qname)
Find global attribute by name.- Parameters:
qname
- name- Returns:
- definition, or
null
if not registered
-
findAttributeGroup
public AttributeGroupElement findAttributeGroup(QName qname)
Find attribute group by name.- Parameters:
qname
- name- Returns:
- definition, or
null
if not registered
-
findElement
public ElementElement findElement(QName qname)
Find global element by name.- Parameters:
qname
- name- Returns:
- definition, or
null
if not registered
-
findGroup
public GroupElement findGroup(QName qname)
Find group by name.- Parameters:
qname
- name- Returns:
- definition, or
null
if not registered
-
findType
public CommonTypeDefinition findType(QName qname)
Find global type by name.- Parameters:
qname
- name- Returns:
- definition, or
null
if not registered
-
mergeDefinitions
public void mergeDefinitions(NameRegister mrg)
Merge definitions directly into this register.- Parameters:
mrg
- register supplying definitions to be merged
-
mergeMapNamespaced
private void mergeMapNamespaced(java.lang.String uri, java.util.HashMap source, java.util.HashMap target)
Merge one QName map into another, changing the namespace URI for keys in the source map.- Parameters:
uri
- namespace URI to be used for keys from source mapsource
-target
-
-
mergeDefinitionsNamespaced
public void mergeDefinitionsNamespaced(java.lang.String uri, NameRegister mrg)
Merge external definitions into this register.- Parameters:
uri
- namespace URI to be used for merged external definitionsmrg
- register supplying external definitions
-
mergeLazyMap
private java.util.HashMap mergeLazyMap(java.util.HashMap source, java.util.HashMap target)
Merge one map into another, where the source map may be empty and the target map may benull
. If the source map is nonempty but the target isnull
, this creates a new map for the target and returns that map; otherwise, the map returned is always the same as the target map passed in.- Parameters:
source
-target
- (null
if none)- Returns:
- target (possibly changed, if the supplied target was
null
)
-
mergeImportedDefinitions
public void mergeImportedDefinitions(NameRegister mrg)
Merge external definitions into this register.- Parameters:
mrg
- register supplying external definitions
-
-