KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > ejb > query > DateFunctionNode


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.ejb.query;
13
14 /**
15  * Functions that return date/time.
16  */

17 public class DateFunctionNode extends Node {
18
19     public static final int CURRENT_DATE = 1;
20     public static final int CURRENT_TIME = 2;
21     public static final int CURRENT_TIMESTAMP = 3;
22
23     private int function;
24
25     public DateFunctionNode(int function) {
26         this.function = function;
27     }
28
29     public int getFunction() {
30         return function;
31     }
32
33     public String JavaDoc getFunctionStr() {
34         switch (function) {
35             case CURRENT_DATE: return "CURRENT_DATE";
36             case CURRENT_TIME: return "CURRENT_TIME";
37             case CURRENT_TIMESTAMP: return "CURRENT_TIMESTAMP";
38         }
39         return "<? function " + function + " ?>";
40     }
41
42     public Object JavaDoc arrive(NodeVisitor v, Object JavaDoc msg) {
43         return v.arriveDateFunctionNode(this, msg);
44     }
45
46     public String JavaDoc toStringImp() {
47         return getFunctionStr();
48     }
49
50 }
51
52
Popular Tags