View Javadoc

1   /*
2    * Copyright (c) 2011.  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.hadoop.hbase.hbql.mapping;
22  
23  import org.apache.expreval.expr.ArgumentListTypeSignature;
24  import org.apache.expreval.expr.ExpressionProperty;
25  import org.apache.expreval.expr.PropertyType;
26  import org.apache.expreval.expr.node.BooleanValue;
27  import org.apache.expreval.expr.node.GenericValue;
28  import org.apache.expreval.expr.node.IntegerValue;
29  
30  public class FamilyProperty extends ExpressionProperty {
31  
32      public static enum Type implements PropertyType {
33  
34          MAX_VERSIONS(new ArgumentListTypeSignature(IntegerValue.class), "MAX_VERSIONS"),
35          TTL(new ArgumentListTypeSignature(IntegerValue.class), "TTL"),
36          IN_MEMORY(new ArgumentListTypeSignature(BooleanValue.class), "IN_MEMORY"),
37          BLOCK_SIZE(new ArgumentListTypeSignature(IntegerValue.class), "BLOCK_SIZE"),
38          BLOCK_CACHE_ENABLED(new ArgumentListTypeSignature(BooleanValue.class), "BLOCK_CACHE_ENABLED"),
39          BLOOMFILTER_TYPE(new ArgumentListTypeSignature(), "BLOOMFILTER_TYPE"),
40          COMPRESSION_TYPE(new ArgumentListTypeSignature(), "COMPRESSION_TYPE");
41  
42          private final ArgumentListTypeSignature typeSignature;
43          private final String                    description;
44  
45          Type(final ArgumentListTypeSignature typeSignature, final String description) {
46              this.typeSignature = typeSignature;
47              this.description = description;
48          }
49  
50          public ArgumentListTypeSignature getTypeSignature() {
51              return this.typeSignature;
52          }
53  
54          public String getDescription() {
55              return this.description;
56          }
57      }
58  
59      public FamilyProperty(final String text, final GenericValue... arg0) {
60          super(FamilyProperty.Type.valueOf(text.toUpperCase()), arg0);
61      }
62  
63      public FamilyProperty(final Type type, final GenericValue... exprs) {
64          super(type, exprs);
65      }
66  
67      public Type getEnumType() {
68          return (Type)this.getPropertyType();
69      }
70  
71      public String asString() {
72          return this.getPropertyType().getDescription() + ": " + this.getGenericValue(0).asString();
73      }
74  }