1 19 20 package org.netbeans.modules.xml.xpath.impl; 21 22 import org.netbeans.modules.xml.xpath.LocationStep; 23 import org.netbeans.modules.xml.xpath.StepNodeTest; 24 import org.netbeans.modules.xml.xpath.StepNodeNameTest; 25 import org.netbeans.modules.xml.xpath.StepNodeTypeTest; 26 import org.netbeans.modules.xml.xpath.XPathExpression; 27 import org.netbeans.modules.xml.xpath.XPathPredicateExpression; 28 import org.netbeans.modules.xml.xpath.visitor.XPathVisitor; 29 30 36 public class LocationStepImpl extends XPathExpressionImpl implements LocationStep { 37 38 39 private int mAxis; 40 41 42 private StepNodeTest mNodeTest; 43 44 45 private XPathPredicateExpression[] mPredicates = null; 46 47 48 public LocationStepImpl() { 49 this(0, null, null); 50 } 51 52 53 58 public LocationStepImpl(int axis, StepNodeTest nodeTest, XPathPredicateExpression[] predicates) { 59 setAxis(axis); 60 setNodeTest(nodeTest); 61 setPredicates(predicates); 62 } 63 64 65 69 public int getAxis() { 70 return mAxis; 71 } 72 73 74 78 public void setAxis(int axis) { 79 mAxis = axis; 80 } 81 82 86 public StepNodeTest getNodeTest() { 87 return mNodeTest; 88 } 89 90 91 95 public void setNodeTest(StepNodeTest nodeTest) { 96 mNodeTest = nodeTest; 97 } 98 99 103 public XPathPredicateExpression[] getPredicates() { 104 return mPredicates; 105 } 106 107 108 112 public void setPredicates(XPathPredicateExpression[] predicates) { 113 mPredicates = predicates; 114 } 115 116 120 public String getString() { 121 StringBuffer sb = new StringBuffer (); 122 123 if (LocationStep.AXIS_ATTRIBUTE == getAxis()) { 124 sb.append('@'); 125 } 126 127 StepNodeTest nodeTest = getNodeTest(); 128 if (nodeTest instanceof StepNodeNameTest) { 129 sb.append(((StepNodeNameTest) nodeTest).getNodeName()); 130 } else if (nodeTest instanceof StepNodeTypeTest) { 131 sb.append(((StepNodeTypeTest) nodeTest).getNodeTypeString()); 132 } 133 134 return sb.toString(); 135 } 136 137 138 public void accept(XPathVisitor visitor) { 139 visitor.visit(this); 140 } 141 142 143 } 144 | Popular Tags |