/tests/src/test/java/org/sigmah/endtoend/xpath/Step.java
Java | 42 lines | 31 code | 7 blank | 4 comment | 2 complexity | 8fdad8e1a7d0e60d39a988c550aeb57d MD5 | raw file
1/* 2 * All Sigmah code is released under the GNU General Public License v3 3 * See COPYRIGHT.txt and LICENSE.txt. 4 */ 5 6package org.sigmah.endtoend.xpath; 7 8public class Step { 9 private Axis axis; 10 private NodeTest nodeTest; 11 private Predicate[] predicates; 12 13 Step(Axis axis, NodeTest nodeTest, Predicate[] predicates) { 14 this(axis, predicates); 15 this.nodeTest = nodeTest; 16 } 17 18 Step(Axis axis, Predicate[] predicates) { 19 this.axis = axis; 20 this.predicates = predicates; 21 } 22 23 public Step(Axis axis, NodeTest nodeTest) { 24 this.axis = axis; 25 this.nodeTest = nodeTest; 26 this.predicates = new Predicate[0]; 27 } 28 29 @Override 30 public String toString() { 31 StringBuilder step = new StringBuilder(); 32 step.append(axis.getKeyword()).append("::"); 33 step.append(nodeTest == null ? "*" : nodeTest.toString()); 34 35 for(Predicate predicate : predicates) { 36 step.append("["); 37 step.append(predicate.toString()); 38 step.append("]"); 39 } 40 return step.toString(); 41 } 42}