1 16 19 package org.apache.xpath.functions; 20 21 import org.apache.xalan.res.XSLMessages; 22 import org.apache.xpath.Expression; 23 import org.apache.xpath.ExpressionOwner; 24 import org.apache.xpath.XPathVisitor; 25 26 30 public class Function2Args extends FunctionOneArg 31 { 32 33 35 Expression m_arg1; 36 37 43 public Expression getArg1() 44 { 45 return m_arg1; 46 } 47 48 58 public void fixupVariables(java.util.Vector vars, int globalsSize) 59 { 60 super.fixupVariables(vars, globalsSize); 61 if(null != m_arg1) 62 m_arg1.fixupVariables(vars, globalsSize); 63 } 64 65 66 75 public void setArg(Expression arg, int argNum) 76 throws WrongNumberArgsException 77 { 78 79 if (argNum == 0) 81 super.setArg(arg, argNum); 82 else if (1 == argNum) 83 { 84 m_arg1 = arg; 85 arg.exprSetParent(this); 86 } 87 else 88 reportWrongNumberArgs(); 89 } 90 91 99 public void checkNumberArgs(int argNum) throws WrongNumberArgsException 100 { 101 if (argNum != 2) 102 reportWrongNumberArgs(); 103 } 104 105 111 protected void reportWrongNumberArgs() throws WrongNumberArgsException { 112 throw new WrongNumberArgsException(XSLMessages.createXPATHMessage("two", null)); 113 } 114 115 121 public boolean canTraverseOutsideSubtree() 122 { 123 return super.canTraverseOutsideSubtree() 124 ? true : m_arg1.canTraverseOutsideSubtree(); 125 } 126 127 class Arg1Owner implements ExpressionOwner 128 { 129 132 public Expression getExpression() 133 { 134 return m_arg1; 135 } 136 137 138 141 public void setExpression(Expression exp) 142 { 143 exp.exprSetParent(Function2Args.this); 144 m_arg1 = exp; 145 } 146 } 147 148 149 152 public void callArgVisitors(XPathVisitor visitor) 153 { 154 super.callArgVisitors(visitor); 155 if(null != m_arg1) 156 m_arg1.callVisitors(new Arg1Owner(), visitor); 157 } 158 159 162 public boolean deepEquals(Expression expr) 163 { 164 if(!super.deepEquals(expr)) 165 return false; 166 167 if(null != m_arg1) 168 { 169 if(null == ((Function2Args)expr).m_arg1) 170 return false; 171 172 if(!m_arg1.deepEquals(((Function2Args)expr).m_arg1)) 173 return false; 174 } 175 else if(null != ((Function2Args)expr).m_arg1) 176 return false; 177 178 return true; 179 } 180 181 } 182 | Popular Tags |