/tests/src/test/java/org/sigmah/endtoend/xpath/Step.java

http://sigma-h.googlecode.com/ · 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. package org.sigmah.endtoend.xpath;
  6. public class Step {
  7. private Axis axis;
  8. private NodeTest nodeTest;
  9. private Predicate[] predicates;
  10. Step(Axis axis, NodeTest nodeTest, Predicate[] predicates) {
  11. this(axis, predicates);
  12. this.nodeTest = nodeTest;
  13. }
  14. Step(Axis axis, Predicate[] predicates) {
  15. this.axis = axis;
  16. this.predicates = predicates;
  17. }
  18. public Step(Axis axis, NodeTest nodeTest) {
  19. this.axis = axis;
  20. this.nodeTest = nodeTest;
  21. this.predicates = new Predicate[0];
  22. }
  23. @Override
  24. public String toString() {
  25. StringBuilder step = new StringBuilder();
  26. step.append(axis.getKeyword()).append("::");
  27. step.append(nodeTest == null ? "*" : nodeTest.toString());
  28. for(Predicate predicate : predicates) {
  29. step.append("[");
  30. step.append(predicate.toString());
  31. step.append("]");
  32. }
  33. return step.toString();
  34. }
  35. }