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 Function3Args extends Function2Args 31 { 32 33 35 Expression m_arg2; 36 37 43 public Expression getArg2() 44 { 45 return m_arg2; 46 } 47 48 58 public void fixupVariables(java.util.Vector vars, int globalsSize) 59 { 60 super.fixupVariables(vars, globalsSize); 61 if(null != m_arg2) 62 m_arg2.fixupVariables(vars, globalsSize); 63 } 64 65 74 public void setArg(Expression arg, int argNum) 75 throws WrongNumberArgsException 76 { 77 78 if (argNum < 2) 79 super.setArg(arg, argNum); 80 else if (2 == argNum) 81 { 82 m_arg2 = arg; 83 arg.exprSetParent(this); 84 } 85 else 86 reportWrongNumberArgs(); 87 } 88 89 97 public void checkNumberArgs(int argNum) throws WrongNumberArgsException 98 { 99 if (argNum != 3) 100 reportWrongNumberArgs(); 101 } 102 103 109 protected void reportWrongNumberArgs() throws WrongNumberArgsException { 110 throw new WrongNumberArgsException(XSLMessages.createXPATHMessage("three", null)); 111 } 112 113 119 public boolean canTraverseOutsideSubtree() 120 { 121 return super.canTraverseOutsideSubtree() 122 ? true : m_arg2.canTraverseOutsideSubtree(); 123 } 124 125 class Arg2Owner implements ExpressionOwner 126 { 127 130 public Expression getExpression() 131 { 132 return m_arg2; 133 } 134 135 136 139 public void setExpression(Expression exp) 140 { 141 exp.exprSetParent(Function3Args.this); 142 m_arg2 = exp; 143 } 144 } 145 146 147 150 public void callArgVisitors(XPathVisitor visitor) 151 { 152 super.callArgVisitors(visitor); 153 if(null != m_arg2) 154 m_arg2.callVisitors(new Arg2Owner(), visitor); 155 } 156 157 160 public boolean deepEquals(Expression expr) 161 { 162 if(!super.deepEquals(expr)) 163 return false; 164 165 if(null != m_arg2) 166 { 167 if(null == ((Function3Args)expr).m_arg2) 168 return false; 169 170 if(!m_arg2.deepEquals(((Function3Args)expr).m_arg2)) 171 return false; 172 } 173 else if (null != ((Function3Args)expr).m_arg2) 174 return false; 175 176 return true; 177 } 178 179 180 } 181 | Popular Tags |