View Javadoc

1   /**
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  
20  package org.apache.hadoop.hbase.security.access;
21  
22  import java.util.*;
23  
24  import org.apache.hadoop.classification.InterfaceAudience;
25  
26  /**
27   * A Static Interface.
28   * Instead of having this code in the the HbaseMapWritable code, where it
29   * blocks the possibility of altering the variables and changing their types,
30   * it is put here in this static interface where the static final Maps are
31   * loaded one time. Only byte[] and Cell are supported at this time.
32   * @deprecated  In place until we come up on 0.96 and then it can be removed
33   * along with {@link HbaseObjectWritableFor96Migration}; needed to read
34   * pre-0.96 TablePermissions.
35   */
36  @Deprecated
37  @InterfaceAudience.Private
38  interface CodeToClassAndBackFor96Migration {
39    /**
40     * Static map that contains mapping from code to class
41     */
42    Map<Byte, Class<?>> CODE_TO_CLASS =
43      new HashMap<Byte, Class<?>>();
44  
45    /**
46     * Static map that contains mapping from class to code
47     */
48    Map<Class<?>, Byte> CLASS_TO_CODE =
49      new HashMap<Class<?>, Byte>();
50  
51    /**
52     * Class list for supported classes
53     */
54    Class<?>[] classList = {byte[].class};
55  
56    /**
57     * The static loader that is used instead of the static constructor in
58     * HbaseMapWritable.
59     */
60    InternalStaticLoader sl =
61      new InternalStaticLoader(classList, CODE_TO_CLASS, CLASS_TO_CODE);
62  
63    /**
64     * Class that loads the static maps with their values.
65     */
66    class InternalStaticLoader{
67      InternalStaticLoader(Class<?>[] classList,
68          Map<Byte,Class<?>> CODE_TO_CLASS, Map<Class<?>, Byte> CLASS_TO_CODE){
69        byte code = 1;
70        for(int i=0; i<classList.length; i++){
71          CLASS_TO_CODE.put(classList[i], code);
72          CODE_TO_CLASS.put(code, classList[i]);
73          code++;
74        }
75      }
76    }
77  }