1 14 15 package com.sun.facelets.tag; 16 17 import java.beans.BeanInfo ; 18 import java.beans.IntrospectionException ; 19 import java.beans.Introspector ; 20 import java.beans.PropertyDescriptor ; 21 import java.lang.reflect.Method ; 22 import java.util.HashMap ; 23 import java.util.Map ; 24 25 30 final class MetadataTargetImpl extends MetadataTarget { 31 32 private final Map pd; 33 private final Class type; 34 35 36 public MetadataTargetImpl(Class type) throws IntrospectionException { 37 this.type = type; 38 this.pd = new HashMap (); 39 BeanInfo info = Introspector.getBeanInfo(type); 40 PropertyDescriptor [] pda = info.getPropertyDescriptors(); 41 for (int i = 0; i < pda.length; i++) { 42 this.pd.put(pda[i].getName(), pda[i]); 43 } 44 } 45 46 public PropertyDescriptor getProperty(String name) { 47 return (PropertyDescriptor ) this.pd.get(name); 48 } 49 50 public boolean isTargetInstanceOf(Class type) { 51 return type.isAssignableFrom(this.type); 52 } 53 54 public Class getTargetClass() { 55 return this.type; 56 } 57 58 public Class getPropertyType(String name) { 59 PropertyDescriptor pd = this.getProperty(name); 60 if (pd != null) { 61 return pd.getPropertyType(); 62 } 63 return null; 64 } 65 66 public Method getWriteMethod(String name) { 67 PropertyDescriptor pd = this.getProperty(name); 68 if (pd != null) { 69 return pd.getWriteMethod(); 70 } 71 return null; 72 } 73 74 public Method getReadMethod(String name) { 75 PropertyDescriptor pd = this.getProperty(name); 76 if (pd != null) { 77 return pd.getReadMethod(); 78 } 79 return null; 80 } 81 82 } 83 | Popular Tags |