01: /**********************************************************************
02: Copyright (c) 2008 Andy Jefferson and others. All rights reserved.
03: Licensed under the Apache License, Version 2.0 (the "License");
04: you may not use this file except in compliance with the License.
05: You may obtain a copy of the License at
06:
07: http://www.apache.org/licenses/LICENSE-2.0
08:
09: Unless required by applicable law or agreed to in writing, software
10: distributed under the License is distributed on an "AS IS" BASIS,
11: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: See the License for the specific language governing permissions and
13: limitations under the License.
14:
15: Contributors:
16: ...
17: **********************************************************************/package org.jpox.store.expression;
18:
19: import org.jpox.store.mapping.NullMapping;
20:
21: /**
22: * Representation of a unknown literal in a Query.
23: * This is a special literal with the sole purpose of representing a parameter where we don't currently
24: * have the value and want to pre-compile the query to check for other errors. Simply provides
25: * wrappers for operations that we would perform on a parameter value, and returns a valid expression.
26: **/
27: public class UnknownLiteral extends NullLiteral {
28: /**
29: * Creates an unknown literal.
30: * @param qs the QueryExpression
31: */
32: public UnknownLiteral(QueryExpression qs) {
33: super (qs);
34: this .mapping = new NullMapping(qs.getStoreManager()
35: .getDatastoreAdapter());
36: st.append("NULL");
37: }
38:
39: public Object getValue() {
40: return null;
41: }
42:
43: public ScalarExpression add(ScalarExpression expr) {
44: return expr;
45: }
46:
47: public BooleanExpression eq(ScalarExpression expr) {
48: return new BooleanLiteral(qs, mapping, true);
49: }
50:
51: public BooleanExpression noteq(ScalarExpression expr) {
52: return new BooleanLiteral(qs, mapping, true);
53: }
54:
55: public BooleanExpression and(ScalarExpression expr) {
56: return new BooleanLiteral(qs, mapping, true);
57: }
58:
59: public ScalarExpression div(ScalarExpression expr) {
60: return expr;
61: }
62:
63: public BooleanExpression gt(ScalarExpression expr) {
64: return new BooleanLiteral(qs, mapping, true);
65: }
66:
67: public BooleanExpression gteq(ScalarExpression expr) {
68: return new BooleanLiteral(qs, mapping, true);
69: }
70:
71: public BooleanExpression in(ScalarExpression expr) {
72: return new BooleanLiteral(qs, mapping, true);
73: }
74:
75: public BooleanExpression lt(ScalarExpression expr) {
76: return new BooleanLiteral(qs, mapping, true);
77: }
78:
79: public BooleanExpression lteq(ScalarExpression expr) {
80: return new BooleanLiteral(qs, mapping, true);
81: }
82:
83: public ScalarExpression mod(ScalarExpression expr) {
84: return expr;
85: }
86:
87: public ScalarExpression mul(ScalarExpression expr) {
88: return expr;
89: }
90:
91: public ScalarExpression sub(ScalarExpression expr) {
92: return expr;
93: }
94: }
|