01: /*
02: * Copyright 2004 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: BinaryLiteral.java,v 1.1 2004/03/22 04:58:13 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: import java.util.Arrays;
14:
15: class BinaryLiteral extends BinaryExpression {
16: private final byte[] value;
17:
18: public BinaryLiteral(QueryStatement qs, byte[] value) {
19: super (qs);
20:
21: this .value = value;
22:
23: DatabaseAdapter dba = qs.getStoreManager().getDatabaseAdapter();
24: st.appendParameter(
25: (ColumnMapping) dba.getMapping(byte[].class), value);
26: }
27:
28: public BooleanExpression eq(SQLExpression expr) {
29: if (expr instanceof BinaryLiteral)
30: return new BooleanLiteral(qs, Arrays.equals(value,
31: ((BinaryLiteral) expr).value));
32: else
33: return super .eq(expr);
34: }
35:
36: public BooleanExpression noteq(SQLExpression expr) {
37: if (expr instanceof BinaryLiteral)
38: return new BooleanLiteral(qs, !Arrays.equals(value,
39: ((BinaryLiteral) expr).value));
40: else
41: return super.noteq(expr);
42: }
43: }
|