01: /*
02: * Copyright (c) 1998 - 2005 Versant Corporation
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Versant Corporation - initial API and implementation
10: */
11: package com.versant.core.ejb.query;
12:
13: /**
14: * Functions that return numerics.
15: */
16: public class NumericFunctionNode extends Node {
17:
18: public static final int LENGTH = 1;
19: public static final int LOCATE = 2;
20: public static final int ABS = 3;
21: public static final int SQRT = 4;
22: public static final int MOD = 5;
23: public static final int BIT_LENGTH = 6;
24:
25: private int function;
26: private Node args;
27:
28: public NumericFunctionNode(int function, Node args) {
29: this .function = function;
30: this .args = args;
31: }
32:
33: public int getFunction() {
34: return function;
35: }
36:
37: public Node getArgs() {
38: return args;
39: }
40:
41: public String getFunctionStr() {
42: switch (function) {
43: case LENGTH:
44: return "LENGTH";
45: case LOCATE:
46: return "LOCATE";
47: case ABS:
48: return "ABS";
49: case SQRT:
50: return "SQRT";
51: case MOD:
52: return "MOD";
53: case BIT_LENGTH:
54: return "BIT_LENGTH";
55: }
56: return "<? function " + function + " ?>";
57: }
58:
59: public Object arrive(NodeVisitor v, Object msg) {
60: return v.arriveNumericFunctionNode(this , msg);
61: }
62:
63: public String toStringImp() {
64: StringBuffer s = new StringBuffer();
65: s.append(getFunctionStr());
66: s.append('(');
67: if (args != null) {
68: args.appendList(s);
69: }
70: s.append(')');
71: return s.toString();
72: }
73:
74: public void resolve(ResolveContext rc) {
75: args.resolve(rc);
76: }
77:
78: }
|