KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 2004 (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: BinaryLiteral.java,v 1.1 2004/03/22 04:58:13 jackknifebarber Exp $
9  */

10
11 package com.triactive.jdo.store;
12
13 import java.util.Arrays JavaDoc;
14
15
16 class BinaryLiteral extends BinaryExpression
17 {
18     private final byte[] value;
19
20     public BinaryLiteral(QueryStatement qs, byte[] value)
21     {
22         super(qs);
23
24         this.value = value;
25
26         DatabaseAdapter dba = qs.getStoreManager().getDatabaseAdapter();
27         st.appendParameter((ColumnMapping)dba.getMapping(byte[].class), value);
28     }
29
30     public BooleanExpression eq(SQLExpression expr)
31     {
32         if (expr instanceof BinaryLiteral)
33             return new BooleanLiteral(qs, Arrays.equals(value, ((BinaryLiteral)expr).value));
34         else
35             return super.eq(expr);
36     }
37
38     public BooleanExpression noteq(SQLExpression expr)
39     {
40         if (expr instanceof BinaryLiteral)
41             return new BooleanLiteral(qs, !Arrays.equals(value, ((BinaryLiteral)expr).value));
42         else
43             return super.noteq(expr);
44     }
45 }
46
Popular Tags