KickJava   Java API By Example, From Geeks To Geeks.

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


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
23 import java.lang.reflect.Method JavaDoc;
24 import java.util.ArrayList JavaDoc;
25
26 /**
27  * Represents an SQL escape sequence found in the SQL annotation's statement member. A JdbcFragment may
28  * contain child SqlFragments, typically these fragments consist of LiteralFragments and ReflectionFragments.
29  * Parameter substitutions may occur within the SQL escape delimiters {}.
30  *
31  * Syntactically an SQL escape sequence must match one of the following forms, where <i>_space_</i> is a whitespace character:
32  *
33  * <UL><LI>{call_space_.....}</LI>
34  * <LI>{?=_space_.....}</LI>
35  * <LI>{d_space_.....}</LI>
36  * <LI>{t_space_.....}</LI>
37  * <LI>{ts_space_.....}</LI>
38  * <LI>{fn_space_.....}</LI>
39  * <LI>{escape_space_.....}</LI>
40  * <LI>{oj_space_.....}</LI>
41  */

42 public final class JdbcFragment extends SqlFragmentContainer {
43
44     /**
45      * Create a new JdbcFragment
46      */

47     JdbcFragment() {
48         super();
49     }
50
51     /**
52      * Get the prepared statement parameter value(s) contained within this fragment.
53      *
54      * @param context A ControlBeanContext instance.
55      * @param method The annotated method.
56      * @param args The method's arguments.
57      *
58      * @return null if this fragment doesn't contain a parameter value.
59      */

60     Object JavaDoc[] getParameterValues(ControlBeanContext context, Method JavaDoc method, Object JavaDoc[] args) {
61
62         ArrayList JavaDoc<Object JavaDoc> values = new ArrayList JavaDoc<Object JavaDoc>();
63         for (SqlFragment sf : _children) {
64             if (sf.hasParamValue()) {
65                 Object JavaDoc[] moreValues = sf.getParameterValues(context, method, args);
66                 for (Object JavaDoc o : moreValues) {
67                     values.add(o);
68                 }
69             }
70         }
71         return values.toArray();
72     }
73 }
74
Popular Tags