org.inria.ns.reflex.xml.dom
Class DOMOperator

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

public class DOMOperator
extends AbstractXOperator
implements XOperator

DOM-related operations.

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:
Node, org.inria.ns.reflex.xml.operate.XMaster

Method Summary
 void append(Object referent, Object operand)
          Throws an exception if not overriden.
 Map getAttributes(Object referent)
          Return a map of attributes.
 List getChildren(Object referent)
          Return the list of children of a node as specified in XPath : container structures are flattenned, and adjacent text nodes are returned as a single node (in fact, the first text node of the sequence).
 Object getElementById(QName id, Object referent)
          Get the element with the ID given.
 short getNodeType(Object referent)
          Return the type of the referent.
 Object getParent(Object child)
          Return the parent node : the parent node of an attribute is its owner element ; entity references are traversed.
 QName getQName(Object referent)
          Return the DOM name of the node.
 Object getRoot(Object referent)
          Return the root node.
 QName getTypeName(Object referent)
          Return the type name of a node.
 boolean isParentNode(Object referent)
          Indicates whether the referent is a parent node or not.
 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.
 void remove(Object referent, Object parent)
          Removes a referent node from its parent.
 String stringValueOf(Object referent)
          Return the string value of a node as specified in XPath : container structures are flattenned, and adjacent text nodes are returned as a single string.
 Object valueOf(Object referent)
          Return the node value.
 
Methods inherited from class org.inria.ns.reflex.xml.operator.AbstractXOperator
append, booleanValueOf, clear, clear, clearAll, clearAll, clone, clone, getAttributeValue, getCommentAt, getElementAt, getElementsByName, getFamilyIndex, getFamilySize, getIndex, getNamedElementAt, getNamedProcessingInstructionAt, getNameIndex, getNameSize, getNamespaces, getNext, getNodeAt, getNodeKind, getPrevious, getProcessingInstructionAt, getSize, getStringAttributeValue, getStringName, getTextAt, getType, getTypeIndex, getTypeSize, getValue, getXFactory, getXMLType, getXOperator, insertAfter, insertAfter, insertBefore, insertBefore, isAttribute, isComment, isDocument, isElement, isProcessingInstruction, isText, 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, booleanValueOf, clear, clear, clearAll, clearAll, clone, clone, getAttributeValue, getCommentAt, getElementAt, getElementsByName, getFamilyIndex, getFamilySize, getIndex, getNamedElementAt, getNamedProcessingInstructionAt, getNameIndex, getNameSize, getNamespaces, getNext, getNodeAt, getNodeKind, getPrevious, getProcessingInstructionAt, getSize, getStringAttributeValue, getStringName, getTextAt, getType, getTypeIndex, getTypeSize, getValue, getXFactory, getXMLType, insertAfter, insertAfter, insertBefore, insertBefore, isAttribute, isComment, isDocument, isElement, isProcessingInstruction, isText, 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)
Return the list of children of a node as specified in XPath : container structures are flattenned, and adjacent text nodes are returned as a single node (in fact, the first text node of the sequence).

Specified by:
getChildren in interface XOperator
Parameters:
referent - The node.
The - list of chidren of the referent if it is a parent node, or an empty list.
Returns:
The childs of the referent object.
See Also:
isParentNode(Object), XOperator.getChildren(java.lang.Object)

getParent

public Object getParent(Object child)
Return the parent node : the parent node of an attribute is its owner element ; entity references are traversed.

Specified by:
getParent in interface XOperator
Overrides:
getParent in class AbstractXOperator
Parameters:
child - The child.
Returns:
The parent node, or the owner element.
See Also:
XOperator.getParent(java.lang.Object)

getAttributes

public Map getAttributes(Object referent)
Return a map of attributes.

Specified by:
getAttributes in interface XOperator
Parameters:
referent - The node.
Returns:
The attributes of the referent if it is an element, or an empty map.
See Also:
XOperator.getAttributes(java.lang.Object)

isParentNode

public boolean isParentNode(Object referent)
Indicates whether the referent is a parent node or not.

Specified by:
isParentNode in interface XOperator
Overrides:
isParentNode in class AbstractXOperator
Parameters:
referent - The node.
Returns:
true if the node is a document, an element, a fragment, an entity, or an entity reference, false otherwise.
See Also:
XOperator.isParentNode(java.lang.Object)

getQName

public QName getQName(Object referent)
Return the DOM name of the node.

Non-qualified names are wrapped in a QName that has just a local-name.

CData sections are returned as text.

Document fragments are returned as Document.

The QName of namespace declarations is built with the prefix (that might be "").

Specified by:
getQName in interface XOperator
Overrides:
getQName in class AbstractXOperator
Parameters:
The - referent node.
Returns:
The qualified name of the node.
See Also:
XMLNames.TEXT_DOM_NAME, XMLNames.COMMENT_DOM_NAME, XMLNames.DOCUMENT_DOM_NAME, Node

stringValueOf

public String stringValueOf(Object referent)
Return the string value of a node as specified in XPath : container structures are flattenned, and adjacent text nodes are returned as a single string. In fact, for a text node, only the following text nodes will be concatenated, not the previous ones ; to browse the children of a node in this sense, use #getNextXPathNode(Node) or getChildren(Object).

Specified by:
stringValueOf in interface XOperator
Overrides:
stringValueOf in class AbstractXOperator
Parameters:
referent - The node.
Returns:
The string value of the node.
See Also:
XOperator.stringValueOf(java.lang.Object)

numberValueOf

public Number numberValueOf(Object referent)
This implementation returns the number value of the referent based on its string value.

*** This implementation is slightly different from its parent class : it is conform to what is expected by the XPath specification ***

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

valueOf

public Object valueOf(Object referent)
Return the node value.

Specified by:
valueOf in interface XOperator
Overrides:
valueOf in class AbstractXOperator
Parameters:
referent - The referent.
Returns:
The node value.
See Also:
Node.getNodeValue()

getRoot

public Object getRoot(Object referent)
Return the root node.

Specified by:
getRoot in interface XOperator
Overrides:
getRoot in class AbstractXOperator
Parameters:
referent - The referent.
Returns:
The ancestor-or-self node that has no parent.
See Also:
Document, DocumentFragment

getNodeType

public short getNodeType(Object referent)
Return the type of the referent.

Specified by:
getNodeType in interface XOperator
Overrides:
getNodeType in class AbstractXOperator
Parameters:
referent - The referent.
Returns:
The node type.
See Also:
Node.getNodeType()

getElementById

public Object getElementById(QName id,
                             Object referent)
Get the element with the IDflerODE>
ParDE>, Object getElementById( getElementById( getEleme>(XOperator
Overrides:
getParent ect)">getNodeType istotlook org.inn class XOperator
The node type.
See Also:
- The referent.
Returns:rg/inrime, java.lang.Object)">setAttribute DocumentFragment
DocumentFragment
rnd)com/j2se/1.4.thurn /w3c/dom/DocumentFragment.html?is-external=true" title="clasUnsupp2seed>referionExceprionnterface in org.w3c.dom">DocumentFragment Unsupp2seed>referionExceprionCODE> l/QName.html" R BDescriprion copi> :or.html" title="interface in org.inria.ns.reflex.xml.operator">XOperator
setAttribute