KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > controls > system > jdbc > parser > SqlFragment


1 /*
2  * Copyright 2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Header:$
17  */

18
19 package org.apache.beehive.controls.system.jdbc.parser;
20
21 import org.apache.beehive.controls.api.context.ControlBeanContext;
22 import org.apache.beehive.controls.system.jdbc.TypeMappingsFactory;
23
24 import java.lang.reflect.Method JavaDoc;
25
26 /**
27  * The abstract base class for fragments generated during parsing.
28  */

29 public abstract class SqlFragment {
30
31     /**
32      * True if this fragment shouldn't be cached since the prepared statement may change on each invocation.
33      * @return true if this fragment shouldn't be cached by the parser
34      */

35     boolean isDynamicFragment() {
36         return false;
37     }
38
39     /**
40      * Does this fragment contain a parameter value for a prepared statement
41      * @return true if this fragement doesn't contain a prepared statement value.
42      */

43     boolean hasParamValue() {
44         return false;
45     }
46
47     /**
48      * Get the SQL data type for the parameter value contained within this fragment.
49      * @return The SQL data type for this fragment.
50      */

51     int getParamSqlDataType() {
52         return TypeMappingsFactory.TYPE_UNKNOWN;
53     }
54
55     /**
56      * Get the prepared statement parameter value contained within this fragment.
57      *
58      * @param context A ControlBeanContext instance
59      * @param method The annotated method
60      * @param args The method's parameters
61      * @return null if this fragment doesn't contain a parameter value.
62      */

63     Object JavaDoc[] getParameterValues(ControlBeanContext context, Method JavaDoc method, Object JavaDoc[] args) {
64         return null;
65     }
66
67     /**
68      * Get the text for a prepared statement generated by this fragment.
69      * @param context A ControlBeanContext instance
70      * @param method The annotated method
71      * @param args The method's parameters
72      * @return A String containing the prepared statement text generated by this fragment
73      */

74     abstract String JavaDoc getPreparedStatementText(ControlBeanContext context, Method JavaDoc method, Object JavaDoc[] args);
75
76     /**
77      * Must be implemented for JUnit testing.
78      * @return The String value of this fragment.
79      */

80     public String JavaDoc toString() {
81         assert false : "Classes which extend SqlFragment must implement toString()";
82         return null;
83     }
84 }
85
Popular Tags