1 2 12 package com.versant.core.ejb.query; 13 14 17 public class NumericFunctionNode extends Node { 18 19 public static final int LENGTH = 1; 20 public static final int LOCATE = 2; 21 public static final int ABS = 3; 22 public static final int SQRT = 4; 23 public static final int MOD = 5; 24 public static final int BIT_LENGTH = 6; 25 26 private int function; 27 private Node args; 28 29 public NumericFunctionNode(int function, Node args) { 30 this.function = function; 31 this.args = args; 32 } 33 34 public int getFunction() { 35 return function; 36 } 37 38 public Node getArgs() { 39 return args; 40 } 41 42 public String getFunctionStr() { 43 switch (function) { 44 case LENGTH: return "LENGTH"; 45 case LOCATE: return "LOCATE"; 46 case ABS: return "ABS"; 47 case SQRT: return "SQRT"; 48 case MOD: return "MOD"; 49 case BIT_LENGTH: return "BIT_LENGTH"; 50 } 51 return "<? function " + function + " ?>"; 52 } 53 54 public Object arrive(NodeVisitor v, Object msg) { 55 return v.arriveNumericFunctionNode(this, msg); 56 } 57 58 public String toStringImp() { 59 StringBuffer s = new StringBuffer (); 60 s.append(getFunctionStr()); 61 s.append('('); 62 if (args != null) { 63 args.appendList(s); 64 } 65 s.append(')'); 66 return s.toString(); 67 } 68 69 public void resolve(ResolveContext rc) { 70 args.resolve(rc); 71 } 72 73 } 74 75 | Popular Tags |