com.virtualweaver.xotics.datamodel
Interface XoContainer

All Superinterfaces:
java.lang.Cloneable, XoNode, XoObject
All Known Subinterfaces:
XoRoot
All Known Implementing Classes:
XoContainerSupport

public interface XoContainer
extends XoObject

This interface must be implemented for every Xotics Object representing an XML element which can have children elements.

Version:
4.1

Method Summary
 int addXoChild(XoObject child, int index)
          Adds an XO Object as child, at index specified by index param.
 void addXoContainerListener(XoContainerListener l)
          Adds a listener of XoContainerEvent.
 XoObject[] getXoChildren()
          Returns the XO children objects as an XoObject array.
 XoObject getXoChildren(int index)
          Returns the XO child object standing at index position.
 int getXoChildrenCount()
          Returns the number of children of this XO Container.
 XoContainerListener[] getXoContainerListeners()
          Returns the registered listeners of XoContainerEvent fired for this container.
 XoContentModel getXoContentModel()
          Returns this children Content Model.
 boolean isXoObjectWelcome(XoObject maybeChild, int index)
          This method can be called before adding an XO object to know if it can be added at the specified index.
 XoObject removeXoChild(int index)
          Removes the child at the index position from the list of children.
 void removeXoContainerListener(XoContainerListener l)
          Removes a listener of XoContainerEvent previously added by corresponding add method.
 
Methods inherited from interface com.virtualweaver.xotics.datamodel.XoObject
addPropertyChangeListener, addVetoableChangeListener, checkXoValidity, clone, equalsXoObject, getLocale, getXmlLocalName, getXmlNameSpace, getXmlWhiteSpace, getXoDMInstance, getXoParent, isXoPropertyToWrite, removePropertyChangeListener, removeVetoableChangeListener, setIntegrated, setLocale, setXmlLocalName, setXmlNameSpace, setXmlWhiteSpace, setXoDMInstance, setXoParent
 

Method Detail

addXoChild

public int addXoChild(XoObject child,
                      int index)
               throws XoException
Adds an XO Object as child, at index specified by index param. It is allowed for index to be equal to -1 or getXoChildrenCount() : these both values indicate to append child at the end of current children list.

Parameters:
child - the XO object to add as new child
index - position in children list where to add child : -1 and getXoChildrenCount() are valid indexes.
Returns:
effective add index
Throws:
XoException - when :
  • child param is null, or represents an invalid XO object (for example when it is not allowed to add such kind of object),
  • when index is out of bounds, or when child can not be inserted at this index,
  • or for any other reason depending on specific implementations

removeXoChild

public XoObject removeXoChild(int index)
                       throws java.lang.ArrayIndexOutOfBoundsException
Removes the child at the index position from the list of children.

Parameters:
index - position where the child to remove resides
Returns:
the child removed
Throws:
java.lang.ArrayIndexOutOfBoundsException - if there is no child at the specified index

getXoChildrenCount

public int getXoChildrenCount()
Returns the number of children of this XO Container.

Returns:
the number of children of this container

getXoChildren

public XoObject[] getXoChildren()
Returns the XO children objects as an XoObject array.

Returns:
the children array

getXoChildren

public XoObject getXoChildren(int index)
                       throws java.lang.ArrayIndexOutOfBoundsException
Returns the XO child object standing at index position.

Parameters:
index - the position where resides the object to get
Returns:
the object wanted
Throws:
java.lang.ArrayIndexOutOfBoundsException - when the index param is invalid

getXoContentModel

public XoContentModel getXoContentModel()
Returns this children Content Model. This optional method can be used to override static content-model specified in Data-Model definition (DMDL document). By default, this method returns null, which means to get static content-model.

Returns:
an XoContentModel root or null if content model must be got from Data-Model definition
See Also:
XoContentModel

isXoObjectWelcome

public boolean isXoObjectWelcome(XoObject maybeChild,
                                 int index)
This method can be called before adding an XO object to know if it can be added at the specified index. It avoids to get a potentially XoException when directly adding an XO object. This method must not be confused with XoObject.checkXoValidity() ; isXoObjectWelcome() should only perform a few checks about validity of index and XO object params from implementation point of view : for example, if the child to add is of a particular Java class, or if the index has a valid value.

Parameters:
maybeChild - the object to check whether it can be added
index - the index where willing to add maybeChild
Returns:
true if this object is acceptable, false otherwise

addXoContainerListener

public void addXoContainerListener(XoContainerListener l)
Adds a listener of XoContainerEvent. Such event is fired by an XoDMInstance after a complete add/remove child process.

Parameters:
l - a listener of type XoContainerListener to add
See Also:
XoContainerListener

removeXoContainerListener

public void removeXoContainerListener(XoContainerListener l)
Removes a listener of XoContainerEvent previously added by corresponding add method.

Parameters:
l - a listener of type XoContainerListener to remove
See Also:
XoContainerListener

getXoContainerListeners

public XoContainerListener[] getXoContainerListeners()
Returns the registered listeners of XoContainerEvent fired for this container. The event fire process is managed by XoDMInstance owner of this container. So, it needs to get the list of listeners on this container object.

Returns:
the listeners of type XoContainerEvent registered for this container
See Also:
XoContainerListener