1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.expreval.expr.nullcomp;
22
23 import org.apache.expreval.client.NullColumnValueException;
24 import org.apache.expreval.client.ResultMissingColumnException;
25 import org.apache.expreval.expr.ExpressionType;
26 import org.apache.expreval.expr.NotValue;
27 import org.apache.expreval.expr.node.BooleanValue;
28 import org.apache.expreval.expr.node.GenericValue;
29 import org.apache.hadoop.hbase.hbql.client.HBqlException;
30 import org.apache.hadoop.hbase.hbql.impl.HConnectionImpl;
31
32 public abstract class GenericNullCompare extends NotValue<GenericNullCompare> implements BooleanValue {
33
34 protected GenericNullCompare(final ExpressionType type, final boolean not, final GenericValue arg0) {
35 super(type, not, arg0);
36 }
37
38 public String asString() {
39 return this.getExprArg(0).asString() + " IS" + notAsString() + " NULL";
40 }
41
42 public Boolean getValue(final HConnectionImpl conn, final Object object) throws HBqlException,
43 ResultMissingColumnException {
44 boolean retval;
45 try {
46 final Object val = this.getExprArg(0).getValue(conn, object);
47 retval = (val == null);
48 }
49 catch (NullColumnValueException e) {
50 retval = true;
51 }
52 return (this.isNot()) ? !retval : retval;
53 }
54 }