2 Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
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.
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.
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
18 package com.mysql.clusterj.core.query;
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;
29 /** This represents a named parameter that is bound at execution time
33 public class ParameterImpl implements PredicateOperand {
35 /** My message translator */
36 static final I18NHelper local = I18NHelper.getInstance(ParameterImpl.class);
39 static final Logger logger = LoggerFactoryService.getFactory().getInstance(ParameterImpl.class);
41 /** My domain object. */
42 protected QueryDomainTypeImpl<?> dobj;
44 /** My property (set when bound) */
45 protected PropertyImpl property;
47 /** My parameter name */
48 protected String parameterName;
50 /** Is a value bound to this parameter? */
51 protected boolean bound = false;
53 /** Is this parameter marked (used in the query)? */
54 protected boolean marked = false;
56 public ParameterImpl(QueryDomainTypeImpl<?> dobj, String parameterName) {
58 this.parameterName = parameterName;
65 boolean isMarkedAndUnbound(QueryExecutionContext context) {
66 return marked && !context.isBound(parameterName);
73 public String getName() {
77 public Object getParameterValue(QueryExecutionContext context) {
78 return property.getParameterValue(context, parameterName);
81 public Predicate equal(PredicateOperand predicateOperand) {
82 throw new UnsupportedOperationException(
83 local.message("ERR_NotImplemented"));
86 public Predicate between(PredicateOperand lower, PredicateOperand upper) {
87 throw new UnsupportedOperationException(
88 local.message("ERR_NotImplemented"));
91 public Predicate greaterThan(PredicateOperand other) {
92 throw new UnsupportedOperationException(
93 local.message("ERR_NotImplemented"));
96 public Predicate greaterEqual(PredicateOperand other) {
97 throw new UnsupportedOperationException(
98 local.message("ERR_NotImplemented"));
101 public Predicate lessThan(PredicateOperand other) {
102 throw new UnsupportedOperationException(
103 local.message("ERR_NotImplemented"));
106 public Predicate lessEqual(PredicateOperand other) {
107 throw new UnsupportedOperationException(
108 local.message("ERR_NotImplemented"));
111 public Predicate in(PredicateOperand other) {
112 throw new UnsupportedOperationException(
113 local.message("ERR_NotImplemented"));
116 public Predicate like(PredicateOperand other) {
117 throw new UnsupportedOperationException(
118 local.message("ERR_NotImplemented"));
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()));
126 this.property = property;