Class Item

  • Direct Known Subclasses:
    AnyItem, GroupItem, ReferenceItem, ValueItem

    public abstract class Item
    extends java.lang.Object
    Base class for code generation items. Each instance corresponds to a particular schema component, and this base class tracks that schema component (by way of the extension information), along with related details and linkage information. The linkage uses embedded list links, which allows replacing one instance with another with minimal overhead.
    Author:
    Dennis M. Sosnoski
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean m_collection
      Flag for a collection item.
      private ComponentExtension m_componentExtension
      Corresponding schema component extension.
      private boolean m_implicit
      Item is handled by subclassing flag.
      protected Item m_last
      Preceding item in list (null if none).
      private java.lang.String m_name
      Actual name to be used for item (null if to be inherited).
      protected Item m_next
      Next item in list (null if none).
      private boolean m_nillable
      Flag for a nillable item.
      private boolean m_optional
      Flag for an optional item.
      private GroupItem m_parent
      Containing group item.
      private boolean m_topmost
      Flag for topmost item associated with a particular schema component.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void classifyContent()
      Classify the content of this item as attribute, element, and/or character data content, and as requiring content of some form if appropriate.
      protected abstract Item copy​(Item ref, GroupItem parent)
      Copy the item under a different parent.
      protected abstract java.lang.String describe​(int depth, boolean classified)
      Generate a description of the item.
      protected GroupItem findDisjointParent()
      Find the nearest ancestor group which relates to a different schema component.
      ComponentExtension getComponentExtension()
      Get schema component annotation corresponding to this item.
      java.lang.String getEffectiveName()
      Get effective item name, applying inheritance if necessary.
      java.lang.String getName()
      Get name set directly for this item.
      Item getNext()
      Get next item in list.
      GroupItem getParent()
      Get containing group item.
      AnnotatedBase getSchemaComponent()
      Get schema component corresponding to this item.
      Item getTopmost()
      Get the topmost item associated with the same schema component as this item.
      boolean isCollection()
      Check if a collection item.
      boolean isFixedName()
      Check if the name is fixed by configuration.
      boolean isIgnored()
      Check if item is ignored.
      boolean isImplicit()
      Check if the item is represented implicitly by subclassing.
      boolean isOptional()
      Check if item is optional.
      boolean isTopmost()
      Check if topmost item for a particular schema component.
      protected java.lang.String leadString​(int depth)
      Generate the standard leading text for description of the item.
      protected void reparent​(GroupItem parent)
      Replace the parent for this item.
      void setImplicit​(boolean implicit)
      Set item represented implicitly by subclassing flag.
      void setName​(java.lang.String name)
      Set name directly for this item.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • m_componentExtension

        private final ComponentExtension m_componentExtension
        Corresponding schema component extension.
      • m_topmost

        private final boolean m_topmost
        Flag for topmost item associated with a particular schema component.
      • m_optional

        private final boolean m_optional
        Flag for an optional item. In cases where multiple items are associated with the same schema component, this is only meaningful for the topmost item.
      • m_collection

        private final boolean m_collection
        Flag for a collection item. In cases where multiple items are associated with the same schema component, this is only meaningful for the topmost item.
      • m_nillable

        private final boolean m_nillable
        Flag for a nillable item. In cases where multiple items are associated with the same schema component, this is only meaningful for the topmost item.
      • m_implicit

        private boolean m_implicit
        Item is handled by subclassing flag.
      • m_parent

        private GroupItem m_parent
        Containing group item.
      • m_next

        protected Item m_next
        Next item in list (null if none).
      • m_last

        protected Item m_last
        Preceding item in list (null if none).
      • m_name

        private java.lang.String m_name
        Actual name to be used for item (null if to be inherited).
    • Constructor Detail

      • Item

        protected Item​(AnnotatedBase comp,
                       GroupItem parent)
        Basic constructor. This uses the schema component to determine all information other than the parent item group, including the optional/nillable/collection flags. As a special case, if the parent group is associated with the same component this sets all three of these flags false to avoid redundant handling.
        Parameters:
        comp - schema component
        parent - containing group (null if a top-level group)
      • Item

        protected Item​(Item original,
                       Item ref,
                       ComponentExtension ext,
                       GroupItem parent)
        Copy constructor. This creates a copy with a new parent.
        Parameters:
        original -
        ref - reference (for name override; null if none)
        ext - component extension to be linked with copy
        parent - (non-null)
    • Method Detail

      • reparent

        protected void reparent​(GroupItem parent)
        Replace the parent for this item.
        Parameters:
        parent -
      • getSchemaComponent

        public AnnotatedBase getSchemaComponent()
        Get schema component corresponding to this item.
        Returns:
        schema component
      • getComponentExtension

        public ComponentExtension getComponentExtension()
        Get schema component annotation corresponding to this item.
        Returns:
        schema component
      • getParent

        public GroupItem getParent()
        Get containing group item.
        Returns:
        group (null if a top-level group)
      • isFixedName

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

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

        public java.lang.String getName()
        Get name set directly for this item.
        Returns:
        name (null if to be inherited)
      • setName

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

        public Item getNext()
        Get next item in list.
        Returns:
        next
      • isOptional

        public boolean isOptional()
        Check if item is optional. This method is only meaningful for the topmost item associated with a particular schema component (those for which isTopmost() returns true).
        Returns:
        optional
      • isIgnored

        public boolean isIgnored()
        Check if item is ignored. This method is only meaningful for the topmost item associated with a particular schema component (those for which isTopmost() returns true).
        Returns:
        optional
      • isCollection

        public boolean isCollection()
        Check if a collection item. This method is only meaningful for the topmost item associated with a particular schema component (those for which isTopmost() returns true).
        Returns:
        true if collection
      • isImplicit

        public boolean isImplicit()
        Check if the item is represented implicitly by subclassing.
        Returns:
        implicit
      • setImplicit

        public void setImplicit​(boolean implicit)
        Set item represented implicitly by subclassing flag.
        Parameters:
        implicit -
      • copy

        protected abstract Item copy​(Item ref,
                                     GroupItem parent)
        Copy the item under a different parent. This is intended for replacing a reference with a copy, and allows the reference to override settings from the original.
        Parameters:
        ref - reference (for overrides to copy; null if none)
        parent -
        Returns:
        copy
      • findDisjointParent

        protected GroupItem findDisjointParent()
        Find the nearest ancestor group which relates to a different schema component.
        Returns:
        ancestor with different schema component, or null if none
      • classifyContent

        protected void classifyContent()
        Classify the content of this item as attribute, element, and/or character data content, and as requiring content of some form if appropriate. This needs to be done as a separate step after construction in order to handle references, which must assume the content of the definition, and also to work after inlining. This base class implementation does the classification based solely on the schema component type. Any subclasses which override this method should generally call the base class implementation before doing their own classification handling, unless they use a substitute component.
      • describe

        protected abstract java.lang.String describe​(int depth,
                                                     boolean classified)
        Generate a description of the item. For items with nested items this will show the complete structure.
        Parameters:
        depth - current nesting depth
        classified - include classification details flag
        Returns:
        description
      • leadString

        protected java.lang.String leadString​(int depth)
        Generate the standard leading text for description of the item.
        Parameters:
        depth - current nesting depth
        Returns:
        leading text for description