]> review.fuel-infra Code Review - packages/trusty/mysql-wsrep-5.6.git/blob
9455eb9cb7c4282ba4caae5dc54f5cead90e17f2
[packages/trusty/mysql-wsrep-5.6.git] /
1 /*
2    Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
3
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; version 2 of the License.
7
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11    GNU General Public License for more details.
12
13    You should have received a copy of the GNU General Public License
14    along with this program; if not, write to the Free Software
15    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
16 */
17
18 package com.mysql.clusterj.core.query;
19
20
21 import com.mysql.clusterj.ClusterJUserException;
22 import com.mysql.clusterj.core.spi.QueryExecutionContext;
23 import com.mysql.clusterj.core.util.I18NHelper;
24 import com.mysql.clusterj.core.util.Logger;
25 import com.mysql.clusterj.core.util.LoggerFactoryService;
26 import com.mysql.clusterj.query.Predicate;
27 import com.mysql.clusterj.query.PredicateOperand;
28
29 /** This represents a named parameter that is bound at execution time
30  * to a value.
31  * 
32  */
33 public class ParameterImpl implements PredicateOperand {
34
35     /** My message translator */
36     static final I18NHelper local = I18NHelper.getInstance(ParameterImpl.class);
37
38     /** My logger */
39     static final Logger logger = LoggerFactoryService.getFactory().getInstance(ParameterImpl.class);
40
41     /** My domain object. */
42     protected QueryDomainTypeImpl<?> dobj;
43
44     /** My property (set when bound) */
45     protected PropertyImpl property;
46
47     /** My parameter name */
48     protected String parameterName;
49
50     /** Is a value bound to this parameter? */
51     protected boolean bound = false;
52
53     /** Is this parameter marked (used in the query)? */
54     protected boolean marked = false;
55
56     public ParameterImpl(QueryDomainTypeImpl<?> dobj, String parameterName) {
57         this.dobj = dobj;
58         this.parameterName = parameterName;
59     }
60
61     public void mark() {
62         marked = true;
63     }
64
65     boolean isMarkedAndUnbound(QueryExecutionContext context) {
66         return marked && !context.isBound(parameterName);
67     }
68
69     void unmark() {
70         marked = false;
71     }
72
73     public String getName() {
74         return parameterName;
75     }
76
77     public Object getParameterValue(QueryExecutionContext context) {
78         return property.getParameterValue(context, parameterName);
79     }
80
81     public Predicate equal(PredicateOperand predicateOperand) {
82             throw new UnsupportedOperationException(
83                     local.message("ERR_NotImplemented"));
84     }
85
86     public Predicate between(PredicateOperand lower, PredicateOperand upper) {
87             throw new UnsupportedOperationException(
88                     local.message("ERR_NotImplemented"));
89     }
90
91     public Predicate greaterThan(PredicateOperand other) {
92             throw new UnsupportedOperationException(
93                     local.message("ERR_NotImplemented"));
94     }
95
96     public Predicate greaterEqual(PredicateOperand other) {
97             throw new UnsupportedOperationException(
98                     local.message("ERR_NotImplemented"));
99     }
100
101     public Predicate lessThan(PredicateOperand other) {
102             throw new UnsupportedOperationException(
103                     local.message("ERR_NotImplemented"));
104     }
105
106     public Predicate lessEqual(PredicateOperand other) {
107         throw new UnsupportedOperationException(
108                 local.message("ERR_NotImplemented"));
109     }
110
111     public Predicate in(PredicateOperand other) {
112         throw new UnsupportedOperationException(
113                 local.message("ERR_NotImplemented"));
114     }
115
116     public Predicate like(PredicateOperand other) {
117         throw new UnsupportedOperationException(
118                 local.message("ERR_NotImplemented"));
119     }
120
121     public void setProperty(PropertyImpl property) {
122         if (this.property != null && this.property.fmd.getType() != property.fmd.getType()) {
123             throw new ClusterJUserException(local.message("ERR_Multiple_Parameter_Usage", parameterName,
124                     this.property.fmd.getType().getName(), property.fmd.getType().getName()));
125         } else {
126             this.property = property;
127         }
128     }
129
130 }