Class 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 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).
    • Constructor Detail

      • NameRegister

        public NameRegister()
        Constructor.
    • 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 - name
        def - 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 - name
        def - 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 - name
        def - 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 - name
        def - 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 - name
        def - 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 map
        map2 - 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 map
        source -
        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 definitions
        mrg - 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 be null. If the source map is nonempty but the target is null, 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