2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
20 * Licensed to the Apache Software Foundation (ASF) under one
21 * or more contributor license agreements. See the NOTICE file
22 * distributed with this work for additional information
23 * regarding copyright ownership. The ASF licenses this file
24 * to you under the Apache License, Version 2.0 (the
25 * "License"); you may not use this file except in compliance
26 * with the License. You may obtain a copy of the License at
28 * http://www.apache.org/licenses/LICENSE-2.0
30 * Unless required by applicable law or agreed to in writing,
31 * software distributed under the License is distributed on an
32 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
33 * KIND, either express or implied. See the License for the
34 * specific language governing permissions and limitations
38 package org
.apache
.thrift
.meta_data
;
40 import org
.apache
.thrift
.TBase
;
42 import java
.util
.Hashtable
;
46 * This class is used to store meta data about thrift fields. Every field in a
47 * a struct should have a corresponding instance of this class describing it.
50 public class FieldMetaData
{
51 public final String fieldName
;
52 public final byte requirementType
;
53 public final FieldValueMetaData valueMetaData
;
54 private static Hashtable structMap
;
57 structMap
= new Hashtable();
60 public FieldMetaData(String name
, byte req
, FieldValueMetaData vMetaData
){
61 this.fieldName
= name
;
62 this.requirementType
= req
;
63 this.valueMetaData
= vMetaData
;
66 public static synchronized void addStructMetaDataMap(Class sClass
, Hashtable map
){
67 structMap
.put(sClass
, map
);
71 * Returns a map with metadata (i.e. instances of FieldMetaData) that
72 * describe the fields of the given class.
74 * @param sClass The TBase class for which the metadata map is requested
76 public static synchronized Hashtable
getStructMetaDataMap(Class sClass
){
77 if (!structMap
.containsKey(sClass
)){ // Load class if it hasn't been loaded
80 } catch (InstantiationException e
){
81 throw new RuntimeException("InstantiationException for TBase class: " + sClass
.getName() + ", message: " + e
.getMessage());
82 } catch (IllegalAccessException e
){
83 throw new RuntimeException("IllegalAccessException for TBase class: " + sClass
.getName() + ", message: " + e
.getMessage());
86 return (Hashtable
) structMap
.get(sClass
);