MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ParameterImpl.java
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 
33 public class ParameterImpl implements PredicateOperand {
34 
36  static final I18NHelper local = I18NHelper.getInstance(ParameterImpl.class);
37 
39  static final Logger logger = LoggerFactoryService.getFactory().getInstance(ParameterImpl.class);
40 
42  protected QueryDomainTypeImpl<?> dobj;
43 
46 
48  protected String parameterName;
49 
51  protected boolean bound = false;
52 
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 
87  throw new UnsupportedOperationException(
88  local.message("ERR_NotImplemented"));
89  }
90 
92  throw new UnsupportedOperationException(
93  local.message("ERR_NotImplemented"));
94  }
95 
97  throw new UnsupportedOperationException(
98  local.message("ERR_NotImplemented"));
99  }
100 
102  throw new UnsupportedOperationException(
103  local.message("ERR_NotImplemented"));
104  }
105 
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 
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 }