View Javadoc

1   /*
2    * Copyright (c) 2010.  The Apache Software Foundation
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  
21  package org.apache.expreval.expr;
22  
23  import org.apache.expreval.expr.node.GenericValue;
24  import org.apache.hadoop.hbase.hbql.client.HBqlException;
25  
26  public abstract class ExpressionProperty extends MultipleExpressionContext {
27  
28      private final PropertyType propertyType;
29  
30      public ExpressionProperty(final PropertyType propertyType, final GenericValue... exprs) {
31          super(propertyType.getTypeSignature(), exprs);
32          this.propertyType = propertyType;
33      }
34  
35      // This is for DefaultArg
36      public ExpressionProperty(final ArgumentListTypeSignature argumentListTypeSignature, final GenericValue expr) {
37          super(argumentListTypeSignature, expr);
38          this.propertyType = null;
39      }
40  
41      public PropertyType getPropertyType() {
42          return this.propertyType;
43      }
44  
45      public boolean useResultData() {
46          return false;
47      }
48  
49      public boolean allowColumns() {
50          return false;
51      }
52  
53      public void validate() throws HBqlException {
54          this.validateTypes(this.allowColumns(), false);
55      }
56  
57      public int getIntegerValue() throws HBqlException {
58          return ((Number)this.evaluateConstant(0, false)).intValue();
59      }
60  
61      public boolean getBooleanValue() throws HBqlException {
62          return ((Boolean)this.evaluateConstant(0, false));
63      }
64  }