NodeArrayComparator implements Comparator<Node[]>, Serializable { public int compare(Node[] n1, Node[] n2) { if(n1==n2){ return 0; } int min = Math.min(Math.min(n1.length, n2.length),_n); for (int i=0; i<min; i++) { if(_order!=null){ if(_order.length==i){ if(_nZero) return NOT_EQUALS_COMP; return 0; } int index = _order[i]; if(index>=n1.length || index>=n2.length){ _log.warning("Cannot compare "+Nodes.toString(n1)+" with "+Nodes.toString(n2)+" for order "+_order); return Integer.MIN_VALUE; }else{ int comp = compare(n1[index], n2[index], _numeric!=null && _numeric.length>index && _numeric[index], _reverse!=null && _reverse.length>index && _reverse[index] ); if (comp != 0) return comp; } }else{ int comp = n1[i].compareTo(n2[i]); if (comp != 0) return comp; } } if(!_variableLength){ int dif = n1.length - n2.length; if(dif!=0){ return dif; } } if(_nZero) return NOT_EQUALS_COMP;; return 0; } NodeArrayComparator(boolean variableLength);  NodeArrayComparator(boolean notZero, boolean notEqual);  NodeArrayComparator(int n);  NodeArrayComparator(int[] order);  NodeArrayComparator();  NodeArrayComparator(NodeArrayComparatorArgs nca); int compare(Node[] n1, Node[] n2); boolean equals(Node[] n1, Node[] n2); static void main(String args[]); static final int NOT_EQUALS_COMP; static final NodeArrayComparator NC_VAR; static final NodeArrayComparator NC; }
@Test public void test() { NodeArrayComparator.NodeArrayComparatorArgs nca = new NodeArrayComparator.NodeArrayComparatorArgs(); nca.setNumeric(new boolean[] { true }); NodeArrayComparator nc = new NodeArrayComparator(nca); int i = nc.compare(new Node[] { new Literal( "\"1\"^^<http: new Node[] { new Literal( "\"2.0\"^^<http: true) }); assertEquals((int) Math.signum(new Double(1).compareTo(new Double(2))), (int) Math.signum(i)); }