View Javadoc

1   package net.sf.crispy.util;
2   
3   import java.util.Hashtable;
4   import java.util.Map;
5   
6   import net.sf.crispy.impl.ServiceManager;
7   
8   /**
9    * Cache to a Class a Map with all setter/getter method for a performant access.
10   * 
11   * @author Linke
12   *
13   */
14  public class ClassPropertiesCache {
15  
16  	Map classPropertiesMap = new Hashtable();
17  	
18  	public void addClassPropertiesMap (Class pvClass, Map pvClassProperteiesMap) {
19  		classPropertiesMap.put(pvClass, pvClassProperteiesMap);
20  	}
21  	
22  	public boolean addClassPropertiesMap (Map pvClassProperteiesMap) {
23  		String lvClassString = (String) pvClassProperteiesMap.get("class");
24  		if (lvClassString != null) {
25  			Class lvClass = null;
26  			try {
27  				lvClass = Class.forName(lvClassString);
28  				addClassPropertiesMap(lvClass, pvClassProperteiesMap);
29  				return true;
30  			} catch (ClassNotFoundException e) {
31  				if (ServiceManager.DEBUG_MODE_ON) {
32  					e.printStackTrace();
33  				}
34  				return false;
35  			}
36  		} else {
37  			return false;
38  		}
39  	}
40  
41  	
42  	public Map getClassPropertiesMapByClass (Class pvClass) {
43  		return (Map) classPropertiesMap.get(pvClass);
44  	}
45  	
46  	public int size() {
47  		return classPropertiesMap.size();
48  	}
49  }