01: /*
02: $Header: /cvsroot/xorm/xorm/src/org/xorm/query/QueryContext.java,v 1.2 2003/04/02 03:39:31 wbiggs Exp $
03:
04: This file is part of XORM.
05:
06: XORM is free software; you can redistribute it and/or modify
07: it under the terms of the GNU General Public License as published by
08: the Free Software Foundation; either version 2 of the License, or
09: (at your option) any later version.
10:
11: XORM is distributed in the hope that it will be useful,
12: but WITHOUT ANY WARRANTY; without even the implied warranty of
13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: GNU General Public License for more details.
15:
16: You should have received a copy of the GNU General Public License
17: along with XORM; if not, write to the Free Software
18: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20: package org.xorm.query;
21:
22: import java.util.HashMap;
23: import java.util.Map;
24:
25: /**
26: * Represents a Query where parameters have been bound to
27: * specific values.
28: */
29: public class QueryContext {
30: private Map nameToValue = new HashMap();
31: private Map varToValue = new HashMap();
32: private Class candidateClass;
33: private boolean subclasses;
34: private Object candidate;
35:
36: public QueryContext(Class candidateClass) {
37: this .candidateClass = candidateClass;
38: }
39:
40: public QueryContext(Class candidateClass, boolean subclasses) {
41: this (candidateClass);
42: this .subclasses = subclasses;
43: }
44:
45: public void setCandidate(Object candidate) {
46: this .candidate = candidate;
47: }
48:
49: public Object getCandidate() {
50: return candidate;
51: }
52:
53: public void setMap(Map nameToValue) {
54: this .nameToValue = nameToValue;
55: }
56:
57: public void bindParameter(String name, Object value) {
58: nameToValue.put(name, value);
59: }
60:
61: public Object resolveParameter(String name) {
62: return nameToValue.get(name);
63: }
64:
65: public boolean hasParameter(String name) {
66: return nameToValue.containsKey(name);
67: }
68:
69: public void bindVariable(String name, Object value) {
70: varToValue.put(name, value);
71: }
72:
73: public Object resolveVariable(String name) {
74: return varToValue.get(name);
75: }
76:
77: public Class getCandidateClass() {
78: return candidateClass;
79: }
80: }
|