Package org.jibx.schema
Class NameRegister
- java.lang.Object
-
- org.jibx.schema.NameRegister
-
public class NameRegister extends java.lang.ObjectHolder 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.HashMapm_globalAttributeGroupMapDirect attribute group definitions.private java.util.HashMapm_globalAttributeMapDirect attribute definitions.private java.util.HashMapm_globalElementMapDirect element definitions.private java.util.HashMapm_globalGroupMapDirect group definitions.private java.util.HashMapm_globalTypeMapDirect type definitions.private java.util.HashMapm_importedAttributeGroupMapExternal attribute group definitions (lazy create,nullif unused).private java.util.HashMapm_importedAttributeMapExternal attribute definitions (lazy create,nullif unused).private java.util.HashMapm_importedElementMapExternal element definitions (lazy create,nullif unused).private java.util.HashMapm_importedGroupMapExternal group definitions (lazy create,nullif unused).private java.util.HashMapm_importedTypeMapExternal type definitions (lazy create,nullif unused).
-
Constructor Summary
Constructors Constructor Description NameRegister()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AttributeElementfindAttribute(QName qname)Find global attribute by name.AttributeGroupElementfindAttributeGroup(QName qname)Find attribute group by name.ElementElementfindElement(QName qname)Find global element by name.GroupElementfindGroup(QName qname)Find group by name.private java.lang.ObjectfindInMaps(java.lang.Object key, java.util.HashMap map1, java.util.HashMap map2)Find value in main or backup map.CommonTypeDefinitionfindType(QName qname)Find global type by name.voidmergeDefinitions(NameRegister mrg)Merge definitions directly into this register.voidmergeDefinitionsNamespaced(java.lang.String uri, NameRegister mrg)Merge external definitions into this register.voidmergeImportedDefinitions(NameRegister mrg)Merge external definitions into this register.private java.util.HashMapmergeLazyMap(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 voidmergeMapNamespaced(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.AttributeElementregisterAttribute(QName qname, AttributeElement def)Register global attribute in the current schema definition.AttributeGroupElementregisterAttributeGroup(QName qname, AttributeGroupElement def)Register global attribute group in the current schema definition.ElementElementregisterElement(QName qname, ElementElement def)Register global element in the current schema definition.GroupElementregisterGroup(QName qname, GroupElement def)Register global group in the current schema definition.CommonTypeDefinitionregisterType(QName qname, CommonTypeDefinition def)Register global type in the current schema definition.voidreset()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,nullif 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,nullif 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,nullif 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,nullif 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,nullif 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 (
nullif 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 (
nullif 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 (
nullif 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 (
nullif 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 (
nullif 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-nullit is checked.- Parameters:
key-map1- main mapmap2- backup map (nullif none)- Returns:
- value (
nullif value for key not in either map)
-
findAttribute
public AttributeElement findAttribute(QName qname)
Find global attribute by name.- Parameters:
qname- name- Returns:
- definition, or
nullif not registered
-
findAttributeGroup
public AttributeGroupElement findAttributeGroup(QName qname)
Find attribute group by name.- Parameters:
qname- name- Returns:
- definition, or
nullif not registered
-
findElement
public ElementElement findElement(QName qname)
Find global element by name.- Parameters:
qname- name- Returns:
- definition, or
nullif not registered
-
findGroup
public GroupElement findGroup(QName qname)
Find group by name.- Parameters:
qname- name- Returns:
- definition, or
nullif not registered
-
findType
public CommonTypeDefinition findType(QName qname)
Find global type by name.- Parameters:
qname- name- Returns:
- definition, or
nullif 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- (nullif 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
-
-