KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > triactive > jdo > store > UnboundVariable


1 /*
2  * Copyright 2002 (C) TJDO.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the TJDO License version 1.0.
6  * See the terms of the TJDO License in the documentation provided with this software.
7  *
8  * $Id: UnboundVariable.java,v 1.4 2003/08/11 16:01:52 pierreg0 Exp $
9  */

10
11 package com.triactive.jdo.store;
12
13 import javax.jdo.JDOUserException;
14
15
16 class UnboundVariable extends SQLExpression
17 {
18     private final String JavaDoc name;
19     private final Class JavaDoc type;
20     private final JDOQLQuery.Compiler compiler;
21
22     public UnboundVariable(QueryStatement qs, String JavaDoc name, Class JavaDoc type, JDOQLQuery.Compiler compiler)
23     {
24         super(qs);
25
26         this.name = name;
27         this.type = type;
28         this.compiler = compiler;
29     }
30
31     public String JavaDoc getVariableName()
32     {
33         return name;
34     }
35
36     public Class JavaDoc getVariableType()
37     {
38         return type;
39     }
40
41     public void bindTo(QueryStatement.QueryColumn qsc)
42     {
43         StoreManager storeMgr = qs.getStoreManager();
44         DatabaseAdapter dba = storeMgr.getDatabaseAdapter();
45         Mapping m = dba.getMapping(type);
46
47         compiler.bindVariable(name, m.newSQLExpression(qs, qsc, "this"));
48     }
49
50     public StatementText toStatementText()
51     {
52         throw new JDOUserException("Unconstrained variable referenced: " + name);
53     }
54 }
55
Popular Tags