]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/lib/javame/src/org/apache/thrift/meta_data/FieldMetaData.java
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / lib / javame / src / org / apache / thrift / meta_data / FieldMetaData.java
CommitLineData
f67539c2
TL
1/*
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
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
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
17 * under the License.
18 */
19/*
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
27 *
28 * http://www.apache.org/licenses/LICENSE-2.0
29 *
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
35 * under the License.
36 */
37
38package org.apache.thrift.meta_data;
39
40import org.apache.thrift.TBase;
41
42import java.util.Hashtable;
43
44
45/**
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.
48 *
49 */
50public class FieldMetaData {
51 public final String fieldName;
52 public final byte requirementType;
53 public final FieldValueMetaData valueMetaData;
54 private static Hashtable structMap;
55
56 static {
57 structMap = new Hashtable();
58 }
59
60 public FieldMetaData(String name, byte req, FieldValueMetaData vMetaData){
61 this.fieldName = name;
62 this.requirementType = req;
63 this.valueMetaData = vMetaData;
64 }
65
66 public static synchronized void addStructMetaDataMap(Class sClass, Hashtable map){
67 structMap.put(sClass, map);
68 }
69
70 /**
71 * Returns a map with metadata (i.e. instances of FieldMetaData) that
72 * describe the fields of the given class.
73 *
74 * @param sClass The TBase class for which the metadata map is requested
75 */
76 public static synchronized Hashtable getStructMetaDataMap(Class sClass){
77 if (!structMap.containsKey(sClass)){ // Load class if it hasn't been loaded
78 try{
79 sClass.newInstance();
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());
84 }
85 }
86 return (Hashtable) structMap.get(sClass);
87 }
88}