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.literal;
22
23 import org.apache.expreval.client.InternalErrorException;
24 import org.apache.expreval.expr.MultipleExpressionContext;
25 import org.apache.expreval.expr.node.GenericValue;
26 import org.apache.hadoop.hbase.client.Result;
27 import org.apache.hadoop.hbase.filter.Filter;
28 import org.apache.hadoop.hbase.hbql.client.HBqlException;
29 import org.apache.hadoop.hbase.hbql.impl.AggregateValue;
30 import org.apache.hadoop.hbase.hbql.impl.HConnectionImpl;
31 import org.apache.hadoop.hbase.hbql.impl.InvalidServerFilterException;
32
33 import java.io.Serializable;
34
35 public abstract class GenericLiteral<T extends Serializable> implements GenericValue {
36
37 private final T value;
38
39 public GenericLiteral(final T value) {
40 this.value = value;
41 }
42
43 public T getValue(final HConnectionImpl conn, final Object object) {
44 return this.value;
45 }
46
47 public GenericValue getOptimizedValue() throws HBqlException {
48 return this;
49 }
50
51 public boolean isAConstant() {
52 return true;
53 }
54
55 public boolean isDefaultKeyword() {
56 return false;
57 }
58
59 public boolean isAnAggregateValue() {
60 return false;
61 }
62
63 public void initAggregateValue(final AggregateValue aggregateValue) throws HBqlException {
64 throw new InternalErrorException("Not applicable");
65 }
66
67 public void applyResultToAggregateValue(final AggregateValue aggregateValue,
68 final Result result) throws HBqlException {
69 throw new InternalErrorException("Not applicable");
70 }
71
72 public boolean hasAColumnReference() {
73 return false;
74 }
75
76 public boolean isAColumnReference() {
77 return false;
78 }
79
80 public void reset() {
81
82 }
83
84 public void setExpressionContext(final MultipleExpressionContext context) {
85 }
86
87 public Class<? extends GenericValue> validateTypes(final GenericValue parentExpr,
88 final boolean allowCollections) throws HBqlException {
89 return this.getReturnType();
90 }
91
92 protected abstract Class<? extends GenericValue> getReturnType();
93
94 public String asString() {
95 return "" + this.getValue(null, null);
96 }
97
98 public Filter getFilter() throws HBqlException {
99 throw new InvalidServerFilterException();
100 }
101 }