01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19:
20: package org.apache.beehive.controls.system.jdbc.parser;
21:
22: import org.apache.beehive.controls.api.context.ControlBeanContext;
23:
24: import java.lang.reflect.Method;
25: import java.util.ArrayList;
26:
27: /**
28: * Represents an SQL escape sequence found in the SQL annotation's statement member. A JdbcFragment may
29: * contain child SqlFragments, typically these fragments consist of LiteralFragments and ReflectionFragments.
30: * Parameter substitutions may occur within the SQL escape delimiters {}.
31: *
32: * Syntactically an SQL escape sequence must match one of the following forms, where <i>_space_</i> is a whitespace character:
33: *
34: * <UL><LI>{call_space_.....}</LI>
35: * <LI>{?=_space_.....}</LI>
36: * <LI>{d_space_.....}</LI>
37: * <LI>{t_space_.....}</LI>
38: * <LI>{ts_space_.....}</LI>
39: * <LI>{fn_space_.....}</LI>
40: * <LI>{escape_space_.....}</LI>
41: * <LI>{oj_space_.....}</LI>
42: */
43: public final class JdbcFragment extends SqlFragmentContainer {
44:
45: /**
46: * Create a new JdbcFragment
47: */
48: JdbcFragment() {
49: super ();
50: }
51:
52: /**
53: * Get the prepared statement parameter value(s) contained within this fragment.
54: *
55: * @param context A ControlBeanContext instance.
56: * @param method The annotated method.
57: * @param args The method's arguments.
58: *
59: * @return null if this fragment doesn't contain a parameter value.
60: */
61: Object[] getParameterValues(ControlBeanContext context,
62: Method method, Object[] args) {
63:
64: ArrayList<Object> values = new ArrayList<Object>();
65: for (SqlFragment sf : _children) {
66: if (sf.hasParamValue()) {
67: Object[] moreValues = sf.getParameterValues(context,
68: method, args);
69: for (Object o : moreValues) {
70: values.add(o);
71: }
72: }
73: }
74: return values.toArray();
75: }
76: }
|