1 19 20 package org.netbeans.modules.xml.xpath.impl; 21 22 23 import java.util.Iterator ; 24 25 import org.netbeans.modules.xml.xpath.XPathCoreOperation; 26 import org.netbeans.modules.xml.xpath.visitor.XPathVisitable; 27 import org.netbeans.modules.xml.xpath.visitor.XPathVisitor; 28 29 30 36 public class XPathCoreOperationImpl 37 extends XPathOperatorOrFunctionImpl 38 implements XPathCoreOperation { 39 40 41 int mOperator; 42 43 44 48 public XPathCoreOperationImpl(int operator) { 49 super(); 50 setOperator(operator); 51 } 52 53 54 58 public int getOperator() { 59 return mOperator; 60 } 61 62 63 67 public void setOperator(int operator) { 68 mOperator = operator; 69 } 70 71 72 76 public String getName() { 77 int code = getOperator(); 78 79 switch (code) { 80 case XPathCoreOperation.OP_SUM: 81 return "addition"; 82 case XPathCoreOperation.OP_MINUS: 83 return "subtraction"; 84 case XPathCoreOperation.OP_MULT: 85 return "multiplication"; 86 case XPathCoreOperation.OP_DIV: 87 return "division"; 88 case XPathCoreOperation.OP_MOD: 89 return "remainder"; 90 case XPathCoreOperation.OP_NEGATIVE: 91 return "negative"; 92 case XPathCoreOperation.OP_AND: 93 return "and"; 94 case XPathCoreOperation.OP_OR: 95 return "or"; 96 case XPathCoreOperation.OP_EQ: 97 return "equal"; 98 case XPathCoreOperation.OP_NE: 99 return "not_equal"; 100 case XPathCoreOperation.OP_LT: 101 return "lesser_than"; 102 case XPathCoreOperation.OP_LE: 103 return "lesser_or_equal"; 104 case XPathCoreOperation.OP_GT: 105 return "greater_than"; 106 case XPathCoreOperation.OP_GE: 107 return "greater_or_equal"; 108 } 109 110 return null; 111 } 112 113 114 118 public String getSign() { 119 int code = getOperator(); 120 121 switch (code) { 122 case XPathCoreOperation.OP_SUM: 123 return "+"; 124 case XPathCoreOperation.OP_MINUS: 125 return "-"; 126 case XPathCoreOperation.OP_MULT: 127 return "*"; 128 case XPathCoreOperation.OP_DIV: 129 return "div"; 130 case XPathCoreOperation.OP_MOD: 131 return "mod"; 132 case XPathCoreOperation.OP_NEGATIVE: 133 return "-"; 134 case XPathCoreOperation.OP_AND: 135 return "and"; 136 case XPathCoreOperation.OP_OR: 137 return "or"; 138 case XPathCoreOperation.OP_EQ: 139 return "="; 140 case XPathCoreOperation.OP_NE: 141 return "!="; 142 case XPathCoreOperation.OP_LT: 143 return "<"; 144 case XPathCoreOperation.OP_LE: 145 return "<="; 146 case XPathCoreOperation.OP_GT: 147 return ">"; 148 case XPathCoreOperation.OP_GE: 149 return ">="; 150 } 151 152 return null; 153 } 154 155 159 public void accept(XPathVisitor visitor) { 160 visitor.visit(this); 161 } 162 } 163 | Popular Tags |