KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > config > TypeMap


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.object.config;
5
6 import com.tc.util.ClassUtils;
7 import com.tc.util.ClassUtils.ClassSpec;
8
9 import java.text.ParseException JavaDoc;
10 import java.util.HashMap JavaDoc;
11 import java.util.Map JavaDoc;
12
13 /**
14  * Creates a set of Type objects from a set of field names.
15  */

16 public class TypeMap {
17   private final Map JavaDoc types = new HashMap JavaDoc();
18   
19   public TypeMap(String JavaDoc[] fieldNames) throws ParseException JavaDoc {
20     for (int i=0; i<fieldNames.length; i++) {
21       ClassSpec spec = ClassUtils.parseFullyQualifiedFieldName(fieldNames[i]);
22       addField(spec.getFullyQualifiedClassName(), spec.getShortFieldName());
23     }
24   }
25
26   private void addField(String JavaDoc className, String JavaDoc fieldName) {
27     Type type = (Type) types.get(className);
28     if (type == null) {
29       type = new Type();
30       type.setName(className);
31       types.put(className, type);
32     }
33     type.addTransient(fieldName);
34   }
35   
36   public Map JavaDoc getTypes() {
37     return types;
38   }
39 }
40
Popular Tags