org.inria.ns.reflex.xml.operator
Interface XOperator

All Known Implementing Classes:
AbstractXOperator, ArrayOperator, BooleanOperator, DefaultXOperator, DOMListOperator, DOMMapOperator, DOMOperator, ItemOperator, ListOperator, MapOperator, NullOperator, NumberOperator, StringOperator

public interface XOperator

The X-operator of an X-operable object allows to perform XML updates operations and XPath navigation on this object. An X-operable object is free to support all or only a few of this XML features. An X-operable object must not be invoked directly by its X-operator, but by using the MasterXOperator responsible of X-operators invokation.

There is a single instance for each type which is X-operable.

Author:
Philippe Poulard
See Also:
XOperable, AbstractXOperator, XMaster

Method Summary
 void append(int referent, Object parent, Object operand)
          Appends an object to the end of the child list of a referent object.
 void append(Object referent, Object operand)
          Appends an object to the end of the child list of a referent object.
 boolean booleanValueOf(Object referent)
          Return the boolean evaluation of a value, given by the XPath boolean() function.
 void clear(int referent, Object parent)
          Clear the content of a referent object.
 void clear(Object referent)
          Clear the content of a referent object.
 void clearAll(int referent, Object parent)
          Removes all the childs of a referent object.
 void clearAll(Object referent)
          Removes all the childs of a referent object.
 Object clone(int referent, Object parent)
          Clones a referent object to a new one that is a field to field copy of the referent object.
 Object clone(Object referent)
          Clones a referent object to a new one that is a field to field copy of the referent object.
 Map getAttributes(Object referent)
          Returns the attributes of the given referent object.
 Object getAttributeValue(Object referent, QName attribute)
          Returns the attribute value hosted by the given referent object.
 List getChildren(Object referent)
          Returns the children of the given referent object.
 Object getCommentAt(Object referent, int index)
          Return the child comment at the position specified.
 Object getElementAt(Object referent, int index)
          Return the child element at the position specified.
 Object getElementById(QName id, Object referent)
          Return an object by its ID.
 Iterator getElementsByName(Object referent, QName name)
          Return the children elements that have the given name.
 int getFamilyIndex(Object referent)
          Return the intrinsic position of the referent amongs items of the same family ; for an element <f:foo>, the XPath pattern f:*[n] would use this method in order to test its position.
 int getFamilySize(Object referent)
          Return the intrinsic size of the referent's collection of items of the same family ; for an element <f:foo>, the XPath pattern f:*[last()] would use this method in order to test its position.
 int getIndex(Object referent)
          Return the intrinsic position of the referent ; for an element <foo>, the XPath pattern node()[n] would use this method in order to test its position.
 Object getNamedElementAt(Object referent, int index, QName qname)
          Return the child element at the position specified with a specific name.
 Object getNamedProcessingInstructionAt(Object referent, int index, QName target)
          Return the child processing instruction at the position specified with a specific target.
 int getNameIndex(Object referent)
          Return the intrinsic position of the referent amongs items of the same name ; for an element <foo>, the XPath pattern foo[n] would use this method in order to test its position.
 int getNameSize(Object referent)
          Return the intrinsic size of the referent's collection of items of the same name ; for an element <foo>, the XPath pattern foo[last()] would use this method in order to test its position.
 Map getNamespaces(Object referent)
          Returns the namespaces of the given referent object.
 Object getNext(Object referent)
          Returns the next object.
 Object getNodeAt(Object referent, int index)
          Return the child item at the position specified.
 String getNodeKind(Object referent)
           
 short getNodeType(Object referent)
          Returns the type of node that the given referent object represents.
 Object getParent(Object referent)
          Returns the parent of the given referent object.
 Object getPrevious(Object referent)
          Returns the previous object.
 Object getProcessingInstructionAt(Object referent, int index)
          Return the child processing instruction at the position specified.
 QName getQName(Object referent)
          Retrieve the qualified name of the referent object if any, or null.
 Object getRoot(Object referent)
          Return the root in the hierarchy.
 int getSize(Object referent)
          Return the intrinsic size of the collection to which belongs the referent ; for an element <foo>, the XPath pattern node()[last()] would use this method in order to test its size.
 String getStringAttributeValue(Object referent, QName attribute)
          Returns the string attribute value hosted by the given referent object.
 String getStringName(Object referent)
          Retrieve the string name of the referent object if any, or null.
 Object getTextAt(Object referent, int index)
          Return the child text at the position specified.
 Type getType(Object referent)
          Returns the type of the given referent object.
 int getTypeIndex(Object referent)
          Return the intrinsic position of the referent amongs items of the same type ; for an element <foo>, the XPath pattern *[n] would use this method in order to test its position.
 QName getTypeName(Object referent)
          Return the type name of the referent.
 int getTypeSize(Object referent)
          Return the intrinsic size of the referent's collection of items of the same type ; for an element <foo>, the XPath pattern *[last()] would use this method in order to test its position.
 Object getValue(Object referent)
          Retrieve the value of the referent object, or null.
 XFactory getXFactory()
          Return the factory that built this X-operator.
 short getXMLType(Object referent)
           
 void insertAfter(int referent, Object parent, Object operand)
          Inserts an object after the referent object given.
 void insertAfter(Object referent, Object parent, Object operand)
          Inserts an object after the referent object given.
 void insertBefore(int referent, Object parent, Object operand)
          Inserts an object before the referent object given.
 void insertBefore(Object referent, Object parent, Object operand)
          Inserts an object before the referent object given.
 boolean isAttribute(Object referent)
           
 boolean isComment(Object referent)
           
 boolean isDocument(Object referent)
           
 boolean isElement(Object referent)
           
 boolean isParentNode(Object referent)
          Indicate if the referent is a parent node, that is to say if it can have children.
 boolean isProcessingInstruction(Object referent)
           
 boolean isText(Object referent)
           
 Number numberValueOf(Object referent)
          Return the number evaluation of a value, given by the XPath number() function.
 void remove(int referent, Object parent)
          Removes a referent object from its parent.
 void remove(Object referent, Object parent)
          Removes a referent object from its parent.
 boolean removeAttribute(Object referent, QName attribute)
          Removes an attribute hosted by the given referent object.
 void rename(int referent, Object parent, QName newName)
          Renames a referent object.
 void rename(Object referent, Object parent, QName newName)
          Renames a referent object.
 void replace(int referent, Object parent, Object operand)
          Replaces a referent object by another object from its parent.
 void replace(Object referent, Object parent, Object operand)
          Replaces a referent object by another object from its parent.
 void setAttribute(Object referent, QName attribute, Object value)
          Sets the attribute value hosted by the given referent object.
 String stringValueOf(Object referent)
          Return the string evaluation of a value, given by the XPath string() function.
 void update(int referent, Object parent, Object value)
          Updates a referent object with a value.
 void update(Object referent, Object value)
          Updates a referent object with a value.
 Object valueOf(Object referent)
           
 

Method Detail

getXFactory

XFactory getXFactory()
Return the factory that built this X-operator.

Returns:
The factory that built this X-operator.

append

void append(Object referent,
            Object operand)
            throws UnsupportedOperationException
Appends an object to the end of the child list of a referent object. An implementation that deals with the append operation must append the operand object. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The referent object to append to.
operand - The object to append.
Throws:
UnsupportedOperationException - When the operation is not supported.

append

void append(int referent,
            Object parent,
            Object operand)
            throws UnsupportedOperationException
Appends an object to the end of the child list of a referent object. An implementation that deals with the append operation must append the operand object. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The position of the referent object to append to.
parent - The non null parent object of the referent.
operand - The object to append.
Throws:
UnsupportedOperationException - When the operation is not supported.

clear

void clear(Object referent)
           throws UnsupportedOperationException
Clear the content of a referent object. An implementation that deals with the clear operation must define what is part of the content of the referent object, and clear it. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The referent object to clear.
Throws:
UnsupportedOperationException - When the operation is not supported.

clear

void clear(int referent,
           Object parent)
           throws UnsupportedOperationException
Clear the content of a referent object. An implementation that deals with the clear operation must define what is part of the content of the referent object, and clear it. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The position of the referent object to clear.
parent - The non null parent object of the referent.
Throws:
UnsupportedOperationException - When the operation is not supported.

clearAll

void clearAll(Object referent)
              throws UnsupportedOperationException
Removes all the childs of a referent object. An implementation that deals with the clear all operation must clear all the childs of the referent object. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The referent object to clear all.
Throws:
UnsupportedOperationException - When the operation is not supported.

clearAll

void clearAll(int referent,
              Object parent)
              throws UnsupportedOperationException
Removes all the childs of a referent object. An implementation that deals with the clear all operation must clear all the childs of the referent object. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The position of the referent object to clear all.
parent - The non null parent object of the referent.
Throws:
UnsupportedOperationException - When the operation is not supported.

clone

Object clone(Object referent)
             throws UnsupportedOperationException
Clones a referent object to a new one that is a field to field copy of the referent object. An implementation that deals with the clone operation must clone the referent object. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The referent object to clone.
Throws:
UnsupportedOperationException - When the operation is not supported.

clone

Object clone(int referent,
             Object parent)
             throws UnsupportedOperationException
Clones a referent object to a new one that is a field to field copy of the referent object. An implementation that deals with the clone operation must clone the referent object. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The position of the referent object to clone.
parent - The non null parent object of the referent.
Throws:
UnsupportedOperationException - When the operation is not supported.

insertAfter

void insertAfter(Object referent,
                 Object parent,
                 Object operand)
                 throws UnsupportedOperationException
Inserts an object after the referent object given. An implementation that deals with the insert after operation must insert the operand object. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The referent object where to insert after.
parent - The parent object of the referent, or null if the referent is able to retrieve it by itself.
operand - The object to insert.
Throws:
UnsupportedOperationException - When the operation is not supported.

insertAfter

void insertAfter(int referent,
                 Object parent,
                 Object operand)
                 throws UnsupportedOperationException
Inserts an object after the referent object given. An implementation that deals with the insert after operation must insert the operand object. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The position of the referent object where to insert after.
parent - The non null parent object of the referent.
operand - The object to insert.
Throws:
UnsupportedOperationException - When the operation is not supported.

insertBefore

void insertBefore(Object referent,
                  Object parent,
                  Object operand)
                  throws UnsupportedOperationException
Inserts an object before the referent object given. An implementation that deals with the insert before operation must insert the operand object. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The referent object where to insert before.
parent - The parent object of the referent, or null if the referent is able to retrieve it by itself.
operand - The object to insert.
Throws:
UnsupportedOperationException - When the operation is not supported.

insertBefore

void insertBefore(int referent,
                  Object parent,
                  Object operand)
                  throws UnsupportedOperationException
Inserts an object before the referent object given. An implementation that deals with the insert before operation must insert the operand object. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The position of the referent object where to insert before.
parent - The non null parent object of the referent.
operand - The object to insert.
Throws:
UnsupportedOperationException - When the operation is not supported.

remove

void remove(Object referent,
            Object parent)
            throws UnsupportedOperationException
Removes a referent object from its parent. An implementation that deals with the remove operation must remove the referent object from its parent. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The referent object to remove.
parent - The parent object of the referent, or null if the referent is able to retrieve it by itself.
Throws:
UnsupportedOperationException - When the operation is not supported.

remove

void remove(int referent,
            Object parent)
            throws UnsupportedOperationException
Removes a referent object from its parent. An implementation that deals with the remove operation must remove the referent object from its parent. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The position of the referent object to remove.
parent - The non null parent object of the referent.
Throws:
UnsupportedOperationException - When the operation is not supported.

rename

void rename(Object referent,
            Object parent,
            QName newName)
            throws UnsupportedOperationException
Renames a referent object. An implementation that deals with the rename operation must rename the referent object. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The referent object to rename.
parent - The parent object of the referent, or null if the referent is able to retrieve it by itself or may be renamed without involving its parent.
newName - The new name of the referent object. If the referent object only support String, the QName should be built with an NCName.
Throws:
UnsupportedOperationException - When the operation is not supported.

rename

void rename(int referent,
            Object parent,
            QName newName)
            throws UnsupportedOperationException
Renames a referent object. An implementation that deals with the rename operation must rename the referent object. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The position of the referent object to rename.
parent - The non null parent object of the referent.
newName - The new name of the referent object. If the referent object only support String, the QName should be built with an NCName.
Throws:
UnsupportedOperationException - When the operation is not supported.

replace

void replace(Object referent,
             Object parent,
             Object operand)
             throws UnsupportedOperationException
Replaces a referent object by another object from its parent. An implementation that deals with the replace operation must replace the referent object by the operand. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The referent object to replace.
parent - The parent object of the referent, or null if the referent is able to retrieve it by itself.
operand - The object that will replace the referent object.
Throws:
UnsupportedOperationException - When the operation is not supported.

replace

void replace(int referent,
             Object parent,
             Object operand)
             throws UnsupportedOperationException
Replaces a referent object by another object from its parent. An implementation that deals with the replace operation must replace the referent object by the operand. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The position of the referent object to replace.
parent - The non null parent object of the referent.
operand - The object that will replace the referent object.
Throws:
UnsupportedOperationException - When the operation is not supported.

update

void update(Object referent,
            Object value)
            throws UnsupportedOperationException
Updates a referent object with a value. An implementation that deals with the update operation must update the referent object. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The referent object to update.
value - The new value of the referent.
Throws:
UnsupportedOperationException - When the operation is not supported.

update

void update(int referent,
            Object parent,
            Object value)
            throws UnsupportedOperationException
Updates a referent object with a value. An implementation that deals with the update operation must update the referent object. Other implementation MUST throw UnsupportedOperationException.

Parameters:
referent - The position of the referent object to update.
parent - The non null parent object of the referent.
value - The new value of the referent.
Throws:
UnsupportedOperationException - When the operation is not supported.

getChildren

List getChildren(Object referent)
Returns the children of the given referent object.

Parameters:
referent - The referent object.
Returns:
The childs of the referent object.

getParent

Object getParent(Object referent)
Returns the parent of the given referent object.

The parent returned is not the structural parent of the object, but the functional parent ; for example, if a component stores its attributes in a Map, the parent of an attribute of the component is not the Map that hold the attributes but the component itself.

Parameters:
referent - The referent object.
Returns:
The parent of the referent object.

getNext

Object getNext(Object referent)
Returns the next object.

Parameters:
referent - The referent object.
Returns:
The object after the referent object.

getPrevious

Object getPrevious(Object referent)
Returns the previous object.

Parameters:
referent - The referent object.
Returns:
The object before the referent object.

getAttributes

Map getAttributes(Object referent)
Returns the attributes of the given referent object.

Parameters:
referent - The referent object.
Returns:
The attributes of the referent object.

getNamespaces

Map getNamespaces(Object referent)
Returns the namespaces of the given referent object.

Parameters:
referent - The referent object.
Returns:
The namespaces of the referent object.

getType

Type getType(Object referent)
Returns the type of the given referent object.

Parameters:
referent - The referent object.
Returns:
The type of the referent object.

getTypeName

QName getTypeName(Object referent)
Return the type name of the referent.

Parameters:
referent - The referent object.
Returns:
The name of the type of the referent.

getQName

QName getQName(Object referent)
Retrieve the qualified name of the referent object if any, or null.

Parameters:
referent - The referent object.
Returns:
The qualified name of the referent object.

getStringName

String getStringName(Object referent)
Retrieve the string name of the referent object if any, or null.

Parameters:
referent - The referent object.
Returns:
The string name of the referent object.

getValue

Object getValue(Object referent)
Retrieve the value of the referent object, or null.

Parameters:
referent - The referent object.
Returns:
The value of the referent object.

getNodeType

short getNodeType(Object referent)
Returns the type of node that the given referent object represents.

Parameters:
referent - The referent object.
See Also:
XType

getAttributeValue

Object getAttributeValue(Object referent,
                         QName attribute)
Returns the attribute value hosted by the given referent object.

Parameters:
referent - The referent object.
attribute - The name of the attribute.
Returns:
The value of the attribute, or null if it does not exists.

getStringAttributeValue

String getStringAttributeValue(Object referent,
                               QName attribute)
Returns the string attribute value hosted by the given referent object.

Parameters:
referent - The referent object.
attribute - The name of the attribute.
Returns:
The value of the attribute converted to a string, or null if it does not exists.

setAttribute

void setAttribute(Object referent,
                  QName attribute,
                  Object value)
                  throws UnsupportedOperationException
Sets the attribute value hosted by the given referent object.

Parameters:
referent - The referent object.
attribute - The name of the attribute.
value - The value of the attribute.
Throws:
UnsupportedOperationException - When the operation is not supported.

removeAttribute

boolean removeAttribute(Object referent,
                        QName attribute)
Removes an attribute hosted by the given referent object.

Parameters:
referent - The referent object.
attribute - The name of the attribute to remove.
Returns:
true if the attribute was really removed, false if it wasn't existed before.

getIndex

int getIndex(Object referent)
Return the intrinsic position of the referent ; for an element <foo>, the XPath pattern node()[n] would use this method in order to test its position.

Parameters:
referent - The referent object.
Returns:
The intrinsic position of this item.

getTypeIndex

int getTypeIndex(Object referent)
Return the intrinsic position of the referent amongs items of the same type ; for an element <foo>, the XPath pattern *[n] would use this method in order to test its position.

Parameters:
referent - The referent object.
Returns:
The intrinsic position of this item.

getFamilyIndex

int getFamilyIndex(Object referent)
Return the intrinsic position of the referent amongs items of the same family ; for an element <f:foo>, the XPath pattern f:*[n] would use this method in order to test its position.

Parameters:
referent - The referent object.
Returns:
The intrinsic position of this item.

getNameIndex

int getNameIndex(Object referent)
Return the intrinsic position of the referent amongs items of the same name ; for an element <foo>, the XPath pattern foo[n] would use this method in order to test its position.

Parameters:
referent - The referent object.
Returns:
The intrinsic position of this item.

getSize

int getSize(Object referent)
Return the intrinsic size of the collection to which belongs the referent ; for an element <foo>, the XPath pattern node()[last()] would use this method in order to test its size.

Parameters:
referent - The referent object.
Returns:
The intrinsic size of the collection.

getTypeSize

int getTypeSize(Object referent)
Return the intrinsic size of the referent's collection of items of the same type ; for an element <foo>, the XPath pattern *[last()] would use this method in order to test its position.

Parameters:
referent - The referent object.
Returns:
The intrinsic size of the collection of this item.

getFamilySize

int getFamilySize(Object referent)
Return the intrinsic size of the referent's collection of items of the same family ; for an element <f:foo>, the XPath pattern f:*[last()] would use this method in order to test its position.

Parameters:
referent - The referent object.
Returns:
The intrinsic size of the collection of this item.

getNameSize

int getNameSize(Object referent)
Return the intrinsic size of the referent's collection of items of the same name ; for an element <foo>, the XPath pattern foo[last()] would use this method in order to test its position.

Parameters:
referent - The referent object.
Returns:
The intrinsic size of the collection of this item.

getElementById

Object getElementById(QName id,
                      Object referent)
Return an object by its ID.

Parameters:
id - The ID.
referent - The referent.
Returns:
The object that has the ID given, or null.

getElementsByName

Iterator getElementsByName(Object referent,
                           QName name)
Return the children elements that have the given name.

Parameters:
referent - The referent.
name - The name.
Returns:
A non-null iterator on the elements that has the name given.

getElementAt

Object getElementAt(Object referent,
                    int index)
Return the child element at the position specified.

Parameters:
referent - The parent node.
index - The index.
Returns:
The element, or null.

getNodeAt

Object getNodeAt(Object referent,
                 int index)
Return the child item at the position specified.

Parameters:
referent - The parent node.
index - The index.
Returns:
The item, or null.

getTextAt

Object getTextAt(Object referent,
                 int index)
Return the child text at the position specified.

Parameters:
referent - The parent node.
index - The index.
Returns:
The text, or null.

getCommentAt

Object getCommentAt(Object referent,
                    int index)
Return the child comment at the position specified.

Parameters:
referent - The parent node.
index - The index.
Returns:
The comment, or null.

getProcessingInstructionAt

Object getProcessingInstructionAt(Object referent,
                                  int index)
Return the child processing instruction at the position specified.

Parameters:
referent - The parent node.
index - The index.
Returns:
The processing instruction, or null.

getNamedElementAt

Object getNamedElementAt(Object referent,
                         int index,
                         QName qname)
Return the child element at the position specified with a specific name. The previous index-1 element with the name given are skipped.

Parameters:
referent - The parent node.
index - The index.
qname - The name of the element to count.
Returns:
The element with the same name, or null.

getNamedProcessingInstructionAt

Object getNamedProcessingInstructionAt(Object referent,
                                       int index,
                                       QName target)
Return the child processing instruction at the position specified with a specific target. The previous index-1 PI with the target given are skipped.

Parameters:
referent - The parent node.
index - The index.
target - The target of the PI to count, as an NCName.
Returns:
The PI with the same target, or null.

isDocument

boolean isDocument(Object referent)
Parameters:
referent -
Returns:

isElement

boolean isElement(Object referent)
Parameters:
referent -
Returns:

isAttribute

boolean isAttribute(Object referent)
Parameters:
referent -
Returns:

isText

boolean isText(Object referent)
Parameters:
referent -
Returns:

isComment

boolean isComment(Object referent)
Parameters:
referent -
Returns:

isProcessingInstruction

boolean isProcessingInstruction(Object referent)
Parameters:
referent -
Returns:

getXMLType

short getXMLType(Object referent)

getNodeKind

String getNodeKind(Object referent)
Returns:
"attribute", "comment", "document", "element", "namespace", "processing-instruction", "text" or ""

isParentNode

boolean isParentNode(Object referent)
Indicate if the referent is a parent node, that is to say if it can have children.

Parameters:
referent - The referent.
Returns:
true if it is a parent node, false otherwise.

stringValueOf

String stringValueOf(Object referent)
Return the string evaluation of a value, given by the XPath string() function. Objects other than those usually processed by the XPath string() function are converted with their own toString() method.

Parameters:
referent - The object to convert to string.
Returns:
The non-null string value of the object.

numberValueOf

Number numberValueOf(Object referent)
Return the number evaluation of a value, given by the XPath number() function. Objects other than those usually processed by the XPath number() function are converted with their own toString() method then with the number() function to the result string.

Parameters:
referent - The object to convert to number.
Returns:
The non-null number value of the object, can be NaN.

booleanValueOf

boolean booleanValueOf(Object referent)
Return the boolean evaluation of a value, given by the XPath boolean() function. Objects other than those usually processed by the XPath boolean() function are converted with their own toString() method then with the boolean() function to the result string.

Parameters:
referent - The object to convert to boolean.
Returns:
The boolean value of the object.

getRoot

Object getRoot(Object referent)
Return the root in the hierarchy.

Parameters:
referent - An item in the hierarchy.
Returns:
The root, or the referent itself if it is not in a hierarchy or is unreachable. If the referent is null, null is returned.

valueOf

Object valueOf(Object referent)