xacute.util
Class NodeListDefaultImpl

java.lang.Object
  |
  +--xacute.util.NodeListDefaultImpl
All Implemented Interfaces:
NodeList
Direct Known Subclasses:
NodeListImpl, NodeListImpl

public class NodeListDefaultImpl
extends java.lang.Object
implements NodeList


Field Summary
protected  java.util.AbstractList list
           
 
Constructor Summary
protected NodeListDefaultImpl()
           
 
Method Summary
protected  NodeListDefaultImpl add(Node n)
          add THIS IS THE ONLY METHOD THAT DOES NOT REQUIRE TO GET THE RESULT.
 NodeList AFTER(NodeList nl)
          Both node lists NL1 and NL2 are sorted.
 NodeList APPEND(Node n)
           
 NodeList APPEND(NodeList nl)
           
 NodeList applyPredicate(Predicate p)
          Apply predicates -- one at a time -- on each element of the nodelist.
 NodeList BEFORE(NodeList nl)
          Both node lists NL1 and NL2 are sorted.
 NodeList EXCEPT(NodeList nl)
          Like difference.
 NodeList freeDuplicateValues()
          removes value-based duplicates (stringValue()) THE RESULT IS RETURNED.
 Node get(int k)
           
protected  void init()
          These are the only required subclass-specific methods: the subclass is responsible for allocating the object that will play the role of the abstrat list.
 NodeList INTER(NodeList nl)
          We assume both lists to be sorted.
 boolean isDifferentFrom(NodeList nl)
          Meaning: There exists u1 in L1, there exists u2 in L2 ...
 boolean isEmpty()
           
 boolean isEqualTo(NodeList nl)
          Compare 2 nodelists for equality Meaning: There exists u1 in L1, there exists u2 in L2 ...
protected  NodeListDefaultImpl newInstance()
           
 int size()
           
 java.lang.String stringValue_shallow()
           
 java.lang.String stringValue()
          stringValue of the NodeList (i.e.
 NodeList UNION(NodeList nl)
          Physical duplicates are removed THE RESULT IS RETURNED.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

list

protected java.util.AbstractList list
Constructor Detail

NodeListDefaultImpl

protected NodeListDefaultImpl()
Method Detail

init

protected void init()
These are the only required subclass-specific methods: the subclass is responsible for allocating the object that will play the role of the abstrat list. One can also redefine all the methods below if one thinks they can be implemented in a better, for a given XML back-end.

newInstance

protected NodeListDefaultImpl newInstance()

get

public Node get(int k)
Specified by:
get in interface NodeList

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface NodeList

size

public int size()
Specified by:
size in interface NodeList

stringValue

public java.lang.String stringValue()
stringValue of the NodeList (i.e. concatenation of Node individual string values).
Specified by:
stringValue in interface NodeList

stringValue_shallow

public java.lang.String stringValue_shallow()
Specified by:
stringValue_shallow in interface NodeList

isEqualTo

public boolean isEqualTo(NodeList nl)
Compare 2 nodelists for equality Meaning: There exists u1 in L1, there exists u2 in L2 ... such that u1.stringValue() = u2.stringValue() If one or both of the the lists are empty, then false. Strategy: We build a hash of one list and we iterate through the other one. We stop as soon as we find a match.
Specified by:
isEqualTo in interface NodeList

isDifferentFrom

public boolean isDifferentFrom(NodeList nl)
Meaning: There exists u1 in L1, there exists u2 in L2 ... such that u1.stringValue() != u2.stringValue() Strategy: We build the two lists of string values. We sort them and look for differences
Specified by:
isDifferentFrom in interface NodeList

add

protected NodeListDefaultImpl add(Node n)
add THIS IS THE ONLY METHOD THAT DOES NOT REQUIRE TO GET THE RESULT. CAN BE USED ONLY BY SUBCLASSES THOUGH.

APPEND

public NodeList APPEND(Node n)
Specified by:
APPEND in interface NodeList

APPEND

public NodeList APPEND(NodeList nl)
Specified by:
APPEND in interface NodeList

applyPredicate

public NodeList applyPredicate(Predicate p)
                        throws QuiltException
Apply predicates -- one at a time -- on each element of the nodelist. Returns a new nodelist as a result. THE RESULT IS RETURNED. DO NOT COUNT ON SIDE-EFFECTS.
Specified by:
applyPredicate in interface NodeList

AFTER

public NodeList AFTER(NodeList nl)
               throws QuiltException
Both node lists NL1 and NL2 are sorted. If get(i) in NL1 is in the result, then get(i+1) is also in the result. Once we have found a first match, we know that the remaining items will also be part of the result. An exception is raised when the nodelists cannot be compared (e.g. nodes from different documents). THE RESULT IS RETURNED. DO NOT COUNT ON SIDE-EFFECTS.
Specified by:
AFTER in interface NodeList

BEFORE

public NodeList BEFORE(NodeList nl)
                throws QuiltException
Both node lists NL1 and NL2 are sorted. If get(i) in NL1 is in the result, then get(i-1) is also in the result. Once we have found a first match, we know that the remaining items will also be part of the result (assuming we iterate in reverse order). THE RESULT IS RETURNED. DO NOT COUNT ON SIDE-EFFECTS.
Specified by:
BEFORE in interface NodeList

EXCEPT

public NodeList EXCEPT(NodeList nl)
                throws QuiltException
Like difference. THE RESULT IS RETURNED. DO NOT COUNT ON SIDE-EFFECTS.
Specified by:
EXCEPT in interface NodeList

INTER

public NodeList INTER(NodeList nl)
               throws QuiltException
We assume both lists to be sorted. THE RESULT IS RETURNED. DO NOT COUNT ON SIDE-EFFECTS.
Specified by:
INTER in interface NodeList

UNION

public NodeList UNION(NodeList nl)
Physical duplicates are removed THE RESULT IS RETURNED. DO NOT COUNT ON SIDE-EFFECTS.
Specified by:
UNION in interface NodeList

freeDuplicateValues

public NodeList freeDuplicateValues()
removes value-based duplicates (stringValue()) THE RESULT IS RETURNED. DO NOT COUNT ON SIDE-EFFECTS.
Specified by:
freeDuplicateValues in interface NodeList