Class GroupItem

  • Direct Known Subclasses:
    DefinitionItem

    public class GroupItem
    extends Item
    Information for a grouping of components (attributes, elements, compositors, and/or wildcards). This is used for both local groupings and global definitions.
    Author:
    Dennis M. Sosnoski
    • Field Detail

      • s_logger

        private static final Logger s_logger
        Logger for class.
      • m_enumeration

        private boolean m_enumeration
        Flag for enumeration value.
      • m_inline

        private boolean m_inline
        Inline references to this structure.
      • m_className

        private java.lang.String m_className
        Name to be used for generated class (null if inherited).
      • m_size

        private int m_size
        Number of child items in group.
      • m_head

        private Item m_head
        First child (null if none).
      • m_tail

        private Item m_tail
        Last child (null if none).
      • m_generateClass

        private TypeData m_generateClass
        Generated class information (null if inlined).
      • m_allOptional

        private boolean m_allOptional
        Flag for all child nodes are optional. In cases where multiple items are associated with the same schema component, this is only meaningful for the topmost item.
      • m_attributePresent

        private boolean m_attributePresent
        Attribute data present flag.
      • m_elementPresent

        private boolean m_elementPresent
        Element data present flag.
      • m_contentPresent

        private boolean m_contentPresent
        Character data content data present flag.
    • Constructor Detail

      • GroupItem

        protected GroupItem​(AnnotatedBase comp,
                            GroupItem parent)
        Internal constructor. This is used both for creating a new child group directly, and by the DefinitionItem subclass.
        Parameters:
        comp - schema component (should be the simpleType component in the case of an enumeration)
        parent - (null if none)
      • GroupItem

        GroupItem​(GroupItem original,
                  Item ref,
                  GroupItem parent)
        Copy constructor. This creates a deep copy with a new parent.
        Parameters:
        original -
        ref - reference (for overrides to copy; null if none)
        parent - (non-null)
      • GroupItem

        GroupItem​(ReferenceItem reference,
                  ComponentExtension ext)
        Constructor from a reference. This is only used for inlining a referenced definition. It merges usage information from the reference with a deep copy of the item structure of the definition.
        Parameters:
        reference -
        ext - component extension to be linked with inlined definition
    • Method Detail

      • isEnumeration

        public boolean isEnumeration()
        Check if this value represents an enumeration.
        Returns:
        enumeration
      • setEnumeration

        public void setEnumeration​(boolean enumeration)
        Set value represents an enumeration flag.
        Parameters:
        enumeration -
      • appendChild

        private void appendChild​(Item item)
        Append an item to the list of children.
        Parameters:
        item -
      • addGroup

        public GroupItem addGroup​(AnnotatedBase comp)
        Add a child grouping structure.
        Parameters:
        comp - schema component
        Returns:
        structure
      • addReference

        public ReferenceItem addReference​(AnnotatedBase comp,
                                          DefinitionItem ref)
        Add a child reference structure.
        Parameters:
        comp - schema component
        ref - referenced definition item
        Returns:
        reference
      • addValue

        public ValueItem addValue​(AnnotatedBase comp,
                                  QName type,
                                  JavaType ref)
        Add a child value.
        Parameters:
        comp - schema component extension
        type - schema type name
        ref - schema type equivalent (null if not appropriate)
        Returns:
        value
      • addAny

        public AnyItem addAny​(AnnotatedBase comp)
        Add a child any.
        Parameters:
        comp - schema component
        Returns:
        value
      • replaceChild

        void replaceChild​(Item current,
                          Item replace)
        Replace an item in this group with another item.
        Parameters:
        current -
        replace -
      • adoptChildren

        void adoptChildren​(GroupItem group)
        Adopt the child items from another group as the child items of this group.
        Parameters:
        group -
      • isInline

        public boolean isInline()
        Check if structure to be inlined.
        Returns:
        inline
      • setInline

        public void setInline​(boolean inline)
        Set structure to be inlined flag.
        Parameters:
        inline -
      • getEffectiveClassName

        public java.lang.String getEffectiveClassName()
        Get effective item name, applying inheritance if necessary.
        Returns:
        name
      • getClassName

        public java.lang.String getClassName()
        Get class name set directly for this group.
        Returns:
        name (null if to be inherited)
      • isFixedClassName

        public boolean isFixedClassName()
        Check if the class name is fixed by configuration.
        Returns:
        true if fixed, false if not
      • setClassName

        public void setClassName​(java.lang.String name)
        Set class name directly for this group. It is an error to call this method if the class name is fixed.
        Parameters:
        name - (null if to be inherited)
      • getChildCount

        public int getChildCount()
        Get the number of items present in the group.
        Returns:
        count
      • getFirstChild

        public Item getFirstChild()
        Get head item in list grouped by this structure.
        Returns:
        item (null if none)
      • getGenerateClass

        public TypeData getGenerateClass()
        Get information for class to be generated.
        Returns:
        class
      • setGenerateClass

        public void setGenerateClass​(TypeData clas)
        Set information for class to be generated. If this group is a complexType extension and the base type is not being inlined, this sets the generated class to extend the base type class.
        Parameters:
        clas -
      • isExtensionReference

        public boolean isExtensionReference()
        Check if this group represents an extension reference.
        Returns:
        true if extension reference, false if not
      • convertTypeReference

        public void convertTypeReference()
        Handle groups which consist of a single type reference, or of an extension type reference, by subclassing the class generated for the reference. TODO: instead use separate extension test, since this won't be called for embedded types
      • copy

        protected Item copy​(Item ref,
                            GroupItem parent)
        Copy the item under a different parent.
        Specified by:
        copy in class Item
        Parameters:
        ref - reference (for overrides to copy; null if none)
        parent -
        Returns:
        copy
      • forceAttributePresent

        protected void forceAttributePresent()
        Set attribute present in group. This cascades the attribute present flag upward through containing groups until one is found which defines an element name.
      • forceElementPresent

        protected void forceElementPresent()
        Set element present in group. This cascades the element present flag upward through containing groups until one is found which defines an element name.
      • forceContentPresent

        protected void forceContentPresent()
        Set character data content present in group. This cascades the content present flag upward through all containing groups until one is found which defines an element name.
      • forceRequiredPresent

        protected void forceRequiredPresent()
        Set required item present in group. This cascades the required item present flag upward through all containing groups until one is found which defines either a wrapping element or a compositor other than a required sequence (because a required item present within a required sequence means that there will always be something present in the document, while any other type of compositor does not have this meaning).
      • classifyContent

        protected void classifyContent()
        Classify the content of this item as attribute, element, and/or character data content. For a group item, this just needs to call the corresponding method for each child item.
        Overrides:
        classifyContent in class Item
      • convertToDefinition

        public DefinitionItem convertToDefinition()
        Convert an embedded group to a freestanding definition. This creates a definition using a cloned copy of the structure of this group, then replaces this group with a reference to the definition. TODO: just adopt the child items, rather than cloning? minor performance gain.
        Returns:
        definition
      • nestedString

        public java.lang.String nestedString​(int depth,
                                             boolean classified)
        Build description of nested items.
        Parameters:
        depth - current nesting depth
        classified - include classification details flag
        Returns:
        description
      • isAllOptional

        public boolean isAllOptional()
        Check if all immediate child nodes are optional. This is needed when handling code generation for a reference to a group or attributeGroup handled as a separate object, since that object only needs to be present if one or more of the values are present. This method is only meaningful for the topmost item associated with a particular schema component (those for which Item.isTopmost() returns true).
        Returns:
        true if all child nodes optional, false if not
      • isAttributePresent

        public boolean isAttributePresent()
        Check if an attribute is part of this item. This is only true for items corresponding to attribute definitions, and groupings including these items which do not define an element name. This method is only meaningful for the topmost item associated with a particular schema component (those for which Item.isTopmost() returns true).
        Returns:
        true if attribute
      • isElementPresent

        public boolean isElementPresent()
        Check if a child elements is part of this item. This is true for all items corresponding to element definitions, and all groupings which include such an item. This method is only meaningful for the topmost item associated with a particular schema component (those for which Item.isTopmost() returns true).
        Returns:
        true if content
      • isContentPresent

        public boolean isContentPresent()
        Check if character data content is part of this item. This is true for all items corresponding to simpleContent definitions, and all groupings which include such an item. This method is only meaningful for the topmost item associated with a particular schema component (those for which Item.isTopmost() returns true).
        Returns:
        true if content
      • describe

        protected java.lang.String describe​(int depth,
                                            boolean classified)
        Generate a description of the item, including all nested items.
        Specified by:
        describe in class Item
        Parameters:
        depth - current nesting depth
        classified - include classification details flag
        Returns:
        description