Implementation of NodeList

parisseg

New Member
I implemented \[code\]NodeList\[/code\] like this : \[code\]import java.util.ArrayList;import java.util.Collections;import org.w3c.dom.Node;import org.w3c.dom.NodeList;public class MyNodeList implements NodeList{ //// local member ... ArrayList<Node> arrayNode = new ArrayList<Node>() ; //// @Override public int getLength() { return arrayNode.size() ; } @Override public Node item(int index) { return (arrayNode.get(index)).cloneNode(true); } public void reverse () { Collections.reverse(arrayNode); } public void castNodeToMyNode (NodeList nodeListToCast) { int lenList = nodeListToCast.getLength(); for (int i = 0; i < lenList; i++) { this.arrayNode.add(nodeListToCast.item(i)) ; } } public void appendNodeList (NodeList nodeListToappend) { this.castNodeToMyNode(nodeListToappend) ; }}\[/code\]i have to do this cause i need the method \[code\]reverse\[/code\] - revese the order of the \[code\]NodeList\[/code\] . my question is : when is use \[code\]evaluate\[/code\] function - \[code\]Object result = xpath.evaluate(expression, source, XPathConstants.NODESET);\[/code\]I want to set \[code\]source\[/code\] argument as \[code\]item\[/code\] of the \[code\]MyNodeList\[/code\] implementation. Is it OK to set the \[code\]sourcec\[/code\] as \[code\]myNodeAfterProbExp.item(indexOfNode)\[/code\] when \[code\]myNodeAfterProbExp\[/code\]is an object of \[code\]MyNodeList\[/code\] ?I did something like this but I think it's disruptive for the execution of \[code\]evaluate\[/code\].Thanks in advance.
 
Back
Top