01: /**********************************************************************
02: Copyright (c) 2002 Mike Martin (TJDO) 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: 2003 Andy Jefferson - coding standards
17: ...
18: **********************************************************************/package org.jpox.store.expression;
19:
20: import org.jpox.store.mapping.NullMapping;
21:
22: /**
23: * Representation of a Null literal in a Query.
24: *
25: * @version $Revision: 1.8 $
26: **/
27: public class NullLiteral extends ScalarExpression implements Literal {
28: /**
29: * Creates a null literal
30: * @param qs the QueryExpression
31: */
32: public NullLiteral(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 this ;
45: }
46:
47: public BooleanExpression eq(ScalarExpression expr) {
48: if (expr instanceof NullLiteral) {
49: return new BooleanLiteral(qs, mapping, true);
50: }
51: if (expr instanceof ObjectExpression) {
52: return expr.eq(this );
53: }
54: return new NullComparisonExpression(expr, true, this );
55: }
56:
57: public BooleanExpression noteq(ScalarExpression expr) {
58: if (expr instanceof NullLiteral) {
59: return new BooleanLiteral(qs, mapping, false);
60: }
61: if (expr instanceof ObjectExpression) {
62: return expr.noteq(this );
63: }
64: return new NullComparisonExpression(expr
65: .encloseWithInParentheses(), false, this );
66: }
67:
68: /**
69: * Method to save a "raw" value that this literal represents.
70: * This value differs from the literal value since that is of the same type as this literal.
71: * @param val The raw value
72: */
73: public void setRawValue(Object val) {
74: }
75:
76: /**
77: * Accessor for the "raw" value that this literal represents.
78: * This value differs from the literal value since that is of the same type as this literal.
79: * @return The raw value
80: */
81: public Object getRawValue() {
82: return null;
83: }
84: }
|