org.inria.ns.reflex.xml.operator
Class ItemOperator

java.lang.Object
  extended by org.inria.ns.reflex.xml.operator.AbstractXOperator
      extended by org.inria.ns.reflex.xml.operator.ItemOperator
All Implemented Interfaces:
XOperator

public class ItemOperator
extends AbstractXOperator
implements XOperator

XML operations on an item (a name with a value).

Only the static methods of this class are usable directly. To use the methods of the singleton, use the master operator that ensure the type of the arguments.

Author:
Philippe Poulard
See Also:
Map.Entry, XMaster

Method Summary
 void append(Object referent, Object operand)
          Throws an exception if not overriden.
 boolean booleanValueOf(Object referent)
          This implementation returns the boolean value of the referent based on its string value.
 Map getAttributes(Object referent)
          Returns the attributes of the given referent object.
 List getChildren(Object referent)
          Returns the children of the given referent object.
 int getFamilyIndex(Object referent)
          Return the intrinsic position of this item amongs items of the same family, that is to say 0.
 int getFamilySize(Object referent)
          Return the intrinsic size of this item amongs items of the same family, that is to say 0.
 int getIndex(Object referent)
          Return the intrinsic position of an object, that is to say 0.
 int getNameIndex(Object referent)
          Return the intrinsic position of this item amongs items of the same name, that is to say 0.
 int getNameSize(Object referent)
          Return the intrinsic position of this item amongs items of the same name, that is to say 0.
 short getNodeType(Object referent)
          Return either the "attribute type", or the "namespace type", or the "element type" of the referent.
 Object getParent(Object referent)
          Return the parent of the referent object.
 QName getQName(Object referent)
          Return the qualified name of the referent object if any, or null.
 int getSize(Object referent)
          Return the intrinsic size of an object, that is to say 0.
 int getTypeIndex(Object referent)
          Return the intrinsic position of this item amongs items of the same type, that is to say 0.
 QName getTypeName(Object referent)
          Return the type name of the value of the referent.
 int getTypeSize(Object referent)
          Return the intrinsic size of this item amongs items of the same type, that is to say 0.
 boolean isParentNode(Object referent)
          Indicate if the referent is a parent node, that is to say if it can have children.
 Number numberValueOf(Object referent)
          This implementation returns the number value of the referent based on its string value.
static void register(XMaster xmaster)
          Registers this operator to the master operator.
 String stringValueOf(Object referent)
          This implementation returns the string value of the referent.
 Object valueOf(Object referent)
          Return the value of the item.
 
Methods inherited from class org.inria.ns.reflex.xml.operator.AbstractXOperator
append, clear, clear, clearAll, clearAll, clone, clone, getAttributeValue, getCommentAt, getElementAt, getElementById, getElementsByName, getNamedElementAt, getNamedProcessingInstructionAt, getNamespaces, getNext, getNodeAt, getNodeKind, getPrevious, getProcessingInstructionAt, getRoot, getStringAttributeValue, getStringName, getTextAt, getType, getValue, getXFactory, getXMLType, getXOperator, insertAfter, insertAfter, insertBefore, insertBefore, isAttribute, isComment, isDocument, isElement, isProcessingInstruction, isText, remove, remove, removeAttribute, rename, rename, replace, replace, setAttribute, update, update
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.inria.ns.reflex.xml.operator.XOperator
append, clear, clear, clearAll, clearAll, clone, clone, getAttributeValue, getCommentAt, getElementAt, getElementById, getElementsByName, getNamedElementAt, getNamedProcessingInstructionAt, getNamespaces, getNext, getNodeAt, getNodeKind, getPrevious, getProcessingInstructionAt, getRoot, getStringAttributeValue, getStringName, getTextAt, getType, getValue, getXFactory, getXMLType, insertAfter, insertAfter, insertBefore, insertBefore, isAttribute, isComment, isDocument, isElement, isProcessingInstruction, isText, remove, remove, removeAttribute, rename, rename, replace, replace, setAttribute, update, update
 

Method Detail

register

public static void register(XMaster xmaster)
Registers this operator to the master operator.

Parameters:
xmaster - The master operator.

getChildren

public List getChildren(Object referent)
Description copied from interface: XOperator
Returns the children of the given referent object.

Specified by:
getChildren in interface XOperator
Parameters:
referent - The referent object.
Returns:
The childs of the referent object.

isParentNode

public boolean isParentNode(Object referent)
Description copied from class: AbstractXOperator
Indicate if the referent is a parent node, that is to say if it can have children.

Specified by:
isParentNode in interface XOperator
Overrides:
isParentNode in class AbstractXOperator
Parameters:
referent - The referent.
Returns:
This implementation returns true if it is an element or a document, false otherwise.
See Also:
XOperator.isElement(Object), XOperator.isDocument(Object)

getParent

public Object getParent(Object referent)
Description copied from class: AbstractXOperator
Return the parent of the referent object. This default implementation returns null.

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.

Specified by:
getParent in interface XOperator
Overrides:
getParent in class AbstractXOperator
Parameters:
referent - The referent object.
Returns:
The parent of the referent object.

getQName

public QName getQName(Object referent)
Description copied from class: AbstractXOperator
Return the qualified name of the referent object if any, or null. This default implementation returns null.

Specified by:
getQName in interface XOperator
Overrides:
getQName in class AbstractXOperator
Parameters:
referent - The referent object.
Returns:
The qualified name of the referent object.

getAttributes

public Map getAttributes(Object referent)
Description copied from interface: XOperator
Returns the attributes of the given referent object.

Specified by:
getAttributes in interface XOperator
Parameters:
referent - The referent object.
Returns:
The attributes of the referent object.

stringValueOf

public String stringValueOf(Object referent)
Description copied from class: AbstractXOperator
This implementation returns the string value of the referent.

Specified by:
stringValueOf in interface XOperator
Overrides:
stringValueOf in class AbstractXOperator
Parameters:
referent - The referent.
Returns:
Its string value.
See Also:
Object.toString()

numberValueOf

public Number numberValueOf(Object referent)
Description copied from class: AbstractXOperator
This implementation returns the number value of the referent based on its string value. May return an arbitrary-precision signed decimal number.

Specified by:
numberValueOf in interface XOperator
Overrides:
numberValueOf in class AbstractXOperator
Parameters:
referent - The referent.
Returns:
Its number value.
See Also:
AbstractXOperator.stringValueOf(Object), NumberOperator.parseNumber(String)

booleanValueOf

public boolean booleanValueOf(Object referent)
Description copied from class: AbstractXOperator
This implementation returns the boolean value of the referent based on its string value.

Specified by:
booleanValueOf in interface XOperator
Overrides:
booleanValueOf in class AbstractXOperator
Parameters:
referent - The referent.
Returns:
Its boolean value.
See Also:
AbstractXOperator.stringValueOf(Object)

valueOf

public Object valueOf(Object referent)
Return the value of the item.

Specified by:
valueOf in interface XOperator
Overrides:
valueOf in class AbstractXOperator
Parameters:
referent - The referent.
Returns:
The item value.

append

public void append(Object referent,
                   Object operand)
            throws UnsupportedOperationException
Description copied from class: AbstractXOperator
Throws an exception if not overriden. Otherwise : 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.

Specified by:
append in interface XOperator
Overrides:
append in class AbstractXOperator
Parameters:
referent - The referent object to append to.
operand - The object to append.
Throws:
UnsupportedOperationException - When the operation is not supported.

getNodeType

public short getNodeType(Object referent)
Return either the "attribute type", or the "namespace type", or the "element type" of the referent.

The "element type" is returned if the item is a named item that declares itself as beeing not an attribute.

The "namespace type" is returned if the item is a QName and its namespace URI is bound to the xmlns namespace URI.

Specified by:
getNodeType in interface XOperator
Overrides:
getNodeType in class AbstractXOperator
Parameters:
referent - The referent.
Returns:
The node type.
See Also:
Node.getNodeType(), XType, XMLNames.XMLNS_NAMESPACE_URI, NamedItem.isAttribute()

getTypeName

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

Specified by:
getTypeName in interface XOperator
Parameters:
referent - The referent.
Returns:
The type name of the value of the referent

getIndex

public int getIndex(Object referent)
Return the intrinsic position of an object, that is to say 0.

Specified by:
getIndex in interface XOperator
Overrides:
getIndex in class AbstractXOperator
Parameters:
referent - The referent object.
Returns:
0.
See Also:
#getNaturalSize(Object), AbstractXOperator.getTypeIndex(Object), AbstractXOperator.getFamilyIndex(Object), AbstractXOperator.getNameIndex(Object)

getSize

public int getSize(Object referent)
Return the intrinsic size of an object, that is to say 0.

Specified by:
getSize in interface XOperator
Overrides:
getSize in class AbstractXOperator
Parameters:
referent - The referent object.
Returns:
0.
See Also:
#getNaturalIndex(Object), AbstractXOperator.getTypeSize(Object), AbstractXOperator.getFamilySize(Object), AbstractXOperator.getNameSize(Object)

getTypeIndex

public int getTypeIndex(Object referent)
Return the intrinsic position of this item amongs items of the same type, that is to say 0.

Specified by:
getTypeIndex in interface XOperator
Overrides:
getTypeIndex in class AbstractXOperator
Parameters:
referent - The referent object.
Returns:
0.

getTypeSize

public int getTypeSize(Object referent)
Return the intrinsic size of this item amongs items of the same type, that is to say 0.

Specified by:
getTypeSize in interface XOperator
Overrides:
getTypeSize in class AbstractXOperator
Parameters:
referent - The referent object.
Returns:
0;

getFamilyIndex

public int getFamilyIndex(Object referent)
Return the intrinsic position of this item amongs items of the same family, that is to say 0.

Specified by:
getFamilyIndex in interface XOperator
Overrides:
getFamilyIndex in class AbstractXOperator
Parameters:
referent - The referent object.
Returns:
0;

getFamilySize

public int getFamilySize(Object referent)
Return the intrinsic size of this item amongs items of the same family, that is to say 0.

Specified by:
getFamilySize in interface XOperator
Overrides:
getFamilySize in class AbstractXOperator
Parameters:
referent - The referent object.
Returns:
0;

getNameIndex

public int getNameIndex(Object referent)
Return the intrinsic position of this item amongs items of the same name, that is to say 0.

Specified by:
getNameIndex in interface XOperator
Overrides:
getNameIndex in class AbstractXOperator
Parameters:
referent - The referent object.
Returns:
0;

getNameSize

public int getNameSize(Object referent)
Return the intrinsic position of this item amongs items of the same name, that is to say 0.

Specified by:
getNameSize in interface XOperator
Overrides:
getNameSize in class AbstractXOperator
Parameters:
referent - The referent object.
Returns:
0;