org.inria.ns.reflex.processor.asl
Class TextCandidate

java.lang.Object
  extended by org.inria.ns.reflex.processor.asl.CandidateNode
      extended by org.inria.ns.reflex.processor.asl.TextCandidate
All Implemented Interfaces:
Node
Direct Known Subclasses:
TextCandidate.Attr, TextCandidate.Text

public abstract class TextCandidate
extends CandidateNode
implements Node

Support for candidate texts used for testing a type.

As a type can be applied indifferently for text contents and attributes, this class is derived in 2 flavors.

When successive matchers are testing a text candidate, a next candidate is set to the remainder of the previous text matched and so on. If the full matching sequence fails, this candidate may be reset to the previous full text value to try another matching sequence. The errors raised will be ignored.

Author:
Philippe Poulard

Nested Class Summary
static class TextCandidate.Attr
          A candidate text for an attribute value.
static class TextCandidate.Text
          A candidate text for which comments and processing instructions have been ignored and adjacent text nodes merged.
 
Field Summary
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
TextCandidate()
           
 
Method Summary
 Node appendChild(Node node)
           
 Node cloneNode(boolean param)
           
 NamedNodeMap getAttributes()
           
 NodeList getChildNodes()
           
 Node getFirstChild()
           
 Node getLastChild()
           
 Node getNextSibling()
           
 String getNodeValue()
           
 Document getOwnerDocument()
           
 Node getParentNode()
           
 Node getPreviousSibling()
           
 boolean hasAttributes()
           
 boolean hasChildNodes()
           
 Node insertBefore(Node node, Node node1)
           
 boolean isSupported(String str, String str1)
           
 boolean isWhitespace()
           
static TextCandidate newTextCandidate(Attr attr)
          Create a new text candidate based on an attribute.
static TextCandidate newTextCandidate(Node node)
          Create a candidate text node from a given node.
static TextCandidate newTextCandidate(Object o)
          Create a candidate text node from an object.
static TextCandidate newTextCandidate(String remainder, Node candidate)
          Create a new text candidate based on the previous candidate.
static TextCandidate newTextCandidate(Text textNode, Node parent, Node next, Node previous)
          Create a new text candidate based on a tex node.
 void normalize()
           
 Node removeChild(Node node)
           
 Node replaceChild(Node node, Node node1)
           
 void setNodeValue(String str)
           
 void setPrefix(String str)
           
 String toString()
          Return the string value.
 
Methods inherited from class org.inria.ns.reflex.processor.asl.CandidateNode
compareDocumentPosition, getBaseURI, getFeature, getTextContent, getUserData, isDefaultNamespace, isEqualNode, isSameNode, lookupNamespaceURI, lookupPrefix, setTextContent, setUserData
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
compareDocumentPosition, getBaseURI, getFeature, getLocalName, getNamespaceURI, getNodeName, getNodeType, getPrefix, getTextContent, getUserData, isDefaultNamespace, isEqualNode, isSameNode, lookupNamespaceURI, lookupPrefix, setTextContent, setUserData
 

Constructor Detail

TextCandidate

public TextCandidate()
Method Detail

isWhitespace

public boolean isWhitespace()

appendChild

public Node appendChild(Node node)
                 throws DOMException
Specified by:
appendChild in interface Node
Throws:
DOMException

cloneNode

public Node cloneNode(boolean param)
Specified by:
cloneNode in interface Node

getAttributes

public NamedNodeMap getAttributes()
Specified by:
getAttributes in interface Node

getChildNodes

public NodeList getChildNodes()
Specified by:
getChildNodes in interface Node

getFirstChild

public Node getFirstChild()
Specified by:
getFirstChild in interface Node

getLastChild

public Node getLastChild()
Specified by:
getLastChild in interface Node

getNextSibling

public Node getNextSibling()
Specified by:
getNextSibling in interface Node

getNodeValue

public String getNodeValue()
                    throws DOMException
Specified by:
getNodeValue in interface Node
Throws:
DOMException

getOwnerDocument

public Document getOwnerDocument()
Specified by:
getOwnerDocument in interface Node

getParentNode

public Node getParentNode()
Specified by:
getParentNode in interface Node

getPreviousSibling

public Node getPreviousSibling()
Specified by:
getPreviousSibling in interface Node

hasAttributes

public boolean hasAttributes()
Specified by:
hasAttributes in interface Node

hasChildNodes

public boolean hasChildNodes()
Specified by:
hasChildNodes in interface Node

insertBefore

public Node insertBefore(Node node,
                         Node node1)
                  throws DOMException
Specified by:
insertBefore in interface Node
Throws:
DOMException

isSupported

public boolean isSupported(String str,
                           String str1)
Specified by:
isSupported in interface Node

normalize

public void normalize()
Specified by:
normalize in interface Node

removeChild

public Node removeChild(Node node)
                 throws DOMException
Specified by:
removeChild in interface Node
Throws:
DOMException

replaceChild

public Node replaceChild(Node node,
                         Node node1)
                  throws DOMException
Specified by:
replaceChild in interface Node
Throws:
DOMException

setNodeValue

public void setNodeValue(String str)
                  throws DOMException
Specified by:
setNodeValue in interface Node
Throws:
DOMException

setPrefix

public void setPrefix(String str)
               throws DOMException
Specified by:
setPrefix in interface Node
Throws:
DOMException

newTextCandidate

public static TextCandidate newTextCandidate(String remainder,
                                             Node candidate)
Create a new text candidate based on the previous candidate.

Parameters:
remainder - The part of the text that is candidate.
candidate - The previous candidate.
Returns:
A new text candidate, that has the same parent node, previous and following siblings.

newTextCandidate

public static TextCandidate newTextCandidate(Text textNode,
                                             Node parent,
                                             Node next,
                                             Node previous)
Create a new text candidate based on a tex node.

Parameters:
textNode - The text node that has all its value as a candidate.
parent - The parent, may differ from the real parent.
next - The next node.
previous - The previous node.
Returns:
A new text candidate.

newTextCandidate

public static TextCandidate newTextCandidate(Attr attr)
Create a new text candidate based on an attribute.

Parameters:
attr - The attribute that has all its value as a candidate.
Returns:
A new text candidate.

newTextCandidate

public static TextCandidate newTextCandidate(Node node)
Create a candidate text node from a given node.

Parameters:
node - The node.
Returns:
A new text candidate that has the same parent and siblings that the given one.

newTextCandidate

public static TextCandidate newTextCandidate(Object o)
Create a candidate text node from an object.

Parameters:
o - The object, from which the text value is computed.
Returns:
A new text candidate without any parent neither siblings.

toString

public String toString()
Return the string value.

Overrides:
toString in class Object
Returns:
The whole text of this node.
See Also:
Object.toString()