Class ContainerElementBase

  • Direct Known Subclasses:
    StructureElementBase, TemplateElementBase

    public abstract class ContainerElementBase
    extends NestingElementBase
    Model component for elements that can contain detailed binding information in the form of nested child components. Elements of this type include mapping, template, structure, and collection elements.
    Author:
    Dennis M. Sosnoski
    • Field Detail

      • s_allowedAttributes

        public static final StringArray s_allowedAttributes
        Enumeration of allowed attribute names
    • Constructor Detail

      • ContainerElementBase

        protected ContainerElementBase​(int type)
        Constructor.
        Parameters:
        type - element type code
    • Method Detail

      • getLabel

        public String getLabel()
        Get label for this definition.
        Returns:
        label for this definition
      • setLabel

        public void setLabel​(String label)
        Set label for this definition.
        Parameters:
        label - label for this definition
      • getUsing

        public String getUsing()
        Get label for definition to be used.
        Returns:
        label for definition to be used
      • setUsing

        public void setUsing​(String label)
        Set label for definition to be used.
        Parameters:
        label - label for definition to be used
      • getContentComponents

        public ArrayList getContentComponents()
        Get list of child components contributing content items to this container element. This call is only meaningful after validation.
        Returns:
        list of child binding components defining content items
      • getAttributeComponents

        public ArrayList getAttributeComponents()
        Get list of child components contributing attribute items to this container element. This call is only meaningful after validation.
        Returns:
        list of child binding components defining attribute items
      • hasObject

        public abstract boolean hasObject()
        Check if this container defines a context object.
        Returns:
        true if defines context object, false if not
      • getObjectType

        public abstract IClass getObjectType()
        Get class linked to binding element. This call is only meaningful after validation.
        Returns:
        information for class linked by binding
      • getChildObjectType

        public IClass getChildObjectType()
        Get class passed to child components. This call is only meaningful after validation.
        Returns:
        information for class linked by binding
      • setIdChild

        public final void setIdChild​(IComponent child,
                                     ValidationContext vctx)
        Set ID property child. Used to set the ID property associated with a particular class instance. There can only be at most one child ID property for each actual object instance.
        Parameters:
        child - child defining the ID property
        vctx - validation context
      • getId

        public IComponent getId()
        Get ID property child.
        Returns:
        ID child
      • getFactoryName

        public String getFactoryName()
        Get factory method name.
        Returns:
        fully-qualified factory class and method name (or null if none)
      • getFactory

        public IClassItem getFactory()
        Get factory method information. This call is only meaningful after a call to prevalidate(ValidationContext).
        Returns:
        factory method information (or null if none)
      • setFactoryName

        public void setFactoryName​(String name)
        Set factory method name.
        Parameters:
        name - fully qualified class and method name for object factory
      • getPresetName

        public String getPresetName()
        Get pre-set method name.
        Returns:
        pre-set method name (or null if none)
      • getPreset

        public IClassItem getPreset()
        Get pre-set method information. This call is only meaningful after a call to prevalidate(ValidationContext).
        Returns:
        pre-set method information (or null if none)
      • setPresetName

        public void setPresetName​(String name)
        Set pre-set method name.
        Parameters:
        name - member method name to be called before unmarshalling
      • getPostsetName

        public String getPostsetName()
        Get post-set method name.
        Returns:
        post-set method name (or null if none)
      • getPostset

        public IClassItem getPostset()
        Get post-set method information. This call is only meaningful after a call to prevalidate(ValidationContext).
        Returns:
        post-set method information (or null if none)
      • setPostsetName

        public void setPostsetName​(String name)
        Set post-set method name.
        Parameters:
        name - member method name to be called after unmarshalling
      • getPregetName

        public String getPregetName()
        Get pre-get method name.
        Returns:
        pre-get method name (or null if none)
      • getPreget

        public IClassItem getPreget()
        Get pre-get method information. This call is only meaningful after a call to prevalidate(ValidationContext).
        Returns:
        pre-get method information (or null if none)
      • setPregetName

        public void setPregetName​(String name)
        Set pre-get method name.
        Parameters:
        name - member method name to be called before marshalling
      • getMarshallerName

        public String getMarshallerName()
        Get marshaller class name.
        Returns:
        marshaller class name (or null if none)
      • getMarshaller

        public IClass getMarshaller()
        Get marshaller class information. This call is only meaningful after a call to prevalidate(ValidationContext).
        Returns:
        class information for marshaller (or null if none)
      • setMarshallerName

        public void setMarshallerName​(String name)
        Set marshaller class name.
        Parameters:
        name - class name to be used for marshalling
      • getUnmarshallerName

        public String getUnmarshallerName()
        Get unmarshaller class name.
        Returns:
        unmarshaller class name (or null if none)
      • getUnmarshaller

        public IClass getUnmarshaller()
        Get unmarshaller class information. This call is only meaningful after a call to prevalidate(ValidationContext).
        Returns:
        class information for unmarshaller (or null if none)
      • setUnmarshallerName

        public void setUnmarshallerName​(String name)
        Set unmarshaller class name.
        Parameters:
        name - class name to be used for unmarshalling
      • isNillable

        public boolean isNillable()
        Check if nillable object.
        Returns:
        nillable flag
      • setNillable

        public void setNillable​(boolean nillable)
        Set nillable flag.
        Parameters:
        nillable - flag
      • getCreateType

        public String getCreateType()
        Get type to be used for creating new instance.
        Returns:
        class name for type to be created (or null if none)
      • getCreateClass

        public IClass getCreateClass()
        Get new instance creation class information. This method is only usable a call to prevalidate(ValidationContext).
        Returns:
        class information for type to be created (or null if none)
      • setCreateType

        public void setCreateType​(String name)
        Set new instance type class name.
        Parameters:
        name - class name to be used for creating new instance
      • isFlexible

        public boolean isFlexible()
        Get flexible flag.
        Returns:
        flexible flag
      • setFlexible

        public void setFlexible​(boolean flexible)
        Set flexible flag.
        Parameters:
        flexible - Flexible
      • isOrdered

        public boolean isOrdered()
        Check if child components are ordered.
        Returns:
        true if ordered, false if not
      • setOrdered

        public void setOrdered​(boolean ordered)
        Set child components ordered flag.
        Parameters:
        ordered - true if ordered, false if not
      • isChoice

        public boolean isChoice()
        Check if child components are a choice.
        Returns:
        true if choice, false if not
      • setChoice

        public void setChoice​(boolean choice)
        Set child components choice flag.
        Parameters:
        choice - true if choice, false if not
      • isAllowRepeats

        public boolean isAllowRepeats()
        Check if repeated child elements are allowed.
        Returns:
        true if repeats allowed, false if not
      • setAllowRepeats

        public void setAllowRepeats​(boolean ignore)
        Set repeated child elements allowed flag.
        Parameters:
        ignore - true if repeated child elements to be allowed, false if not
      • verifyConstruction

        protected void verifyConstruction​(ValidationContext vctx,
                                          IClass type)
        Check that there's a way to construct an instance of an object class for input bindings. This can be a factory method, an unmarshaller, a no-argument constructor already defined in the class, or a modifiable class with constructor generation enabled. If a create-type is specified, this is used in place of the declared type. The call always succeeds if the binding is output-only. Note that this method should not be changed to pass the "this" object when reporting errors, because it may be called indirectly during the validation of other elements. Because of this, it needs to only use values defined after prevalidate(ValidationContext).
        Parameters:
        vctx - validation context
        type - constructed object type
      • checkCompatibleChildren

        protected void checkCompatibleChildren​(ValidationContext vctx,
                                               IClass type,
                                               ArrayList children)
        Check that child components are of types compatible with the container object type. This method may call itself recursively to process the children of child components which do not themselves set a type. It's not used directly, but is here for use by subclasses.
        Parameters:
        vctx - validation context
        type - structure object type
        children - list of child components to be checked
      • isClassified

        protected boolean isClassified()
        Check for child components classified. This is a convenience method for subclasses to check if classification has already been done.
        Returns:
        true if classified, false if not
      • classifyComponents

        protected void classifyComponents​(ValidationContext vctx)
        Classify child components as contributing attributes, content, or both. This method is needed to handle on-demand classification during validation. When a child component is another instance of this class, the method calls itself on the child component prior to checking the child component's contribution.
        Parameters:
        vctx - Validatation context
      • setComponents

        protected void setComponents​(ArrayList attribs,
                                     ArrayList contents)
        Set child attribute and content components directly. This is provided for use by subclasses requiring special handling, in particular the <structure> element used as a mapping reference.
        Parameters:
        attribs - Array of attributes
        contents - Array of Contents
      • prevalidate

        public void prevalidate​(ValidationContext vctx)
        Description copied from class: ElementBase
        Prevalidate element information. The prevalidation step is used to check isolated aspects of an element, such as the settings for enumerated values on the element and attributes. This empty base class implementation should be overridden by each subclass that requires prevalidation handling.
        Overrides:
        prevalidate in class NestingElementBase
        Parameters:
        vctx - validation context
      • validate

        public void validate​(ValidationContext vctx)
        Description copied from class: ElementBase
        Validate element information. The validation step is used for checking the interactions between elements, such as name references to other elements. The ElementBase.prevalidate(org.jibx.binding.model.ValidationContext) method will always be called for every element in the binding definition before this method is called for any element. This empty base class implementation should be overridden by each subclass that requires validation handling.
        Overrides:
        validate in class NestingElementBase
        Parameters:
        vctx - validation context