KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > beans > PropertyDescriptor

java.beans
Class PropertyDescriptor

java.lang.Object
  extended by java.beans.FeatureDescriptor
      extended by java.beans.PropertyDescriptor
Direct Known Subclasses:
IndexedPropertyDescriptor
See Also:
Top Examples, Source Code

public PropertyEditor createPropertyEditor(Object bean)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean equals(Object obj)
See Also:
Hashtable, Object.hashCode()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Class<?> getPropertyEditorClass()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Class<?> getPropertyType()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Method getReadMethod()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1614]JavaBean Introspection
By Anonymous on 2005/11/04 20:23:08  Rate
//Copy Java Bean 
 public static String transfer  ( Object source, Object target )  
  {   
   PropertyDescriptor [  ]  sourceProperties = null; 
   PropertyDescriptor [  ]  targetProperties = null; 
 try 
  {  
     sourceProperties = Introspector.getBeanInfo  ( source.getClass  (  )  )  
       .getPropertyDescriptors  (  ) ; 
     targetProperties = Introspector.getBeanInfo  ( target.getClass  (  )  )  
       .getPropertyDescriptors  (  ) ; 
  }  
 catch  ( IntrospectionException ex )  
  {  
     return  ( "Couldn't derive property descriptors." ) ; 
  }  
  
  
 StringBuffer results = new StringBuffer  (  ) ; 
 Object [  ]  value =  {  null  } ; 
  
  
 Source:  
 for  ( int s = 0; s  <  sourceProperties.length; ++s )  
  {  
     String name = sourceProperties [ s ] .getName  (  ) ; 
     try 
      {  
   Target:  
   for  ( int t = 0; t  <  targetProperties.length; ++t )  
       if  ( targetProperties [ t ] .getName  (  ) .equals  ( name )  )  
        {  
     Method read = sourceProperties [ s ] .getReadMethod  (  ) ; 
     Method write = targetProperties [ t ] .getWriteMethod  (  ) ; 
     if  ( read == null || write == null )  
         break Target; 
  
  
     value [ 0 ]  = read.invoke  ( source, null ) ; 
     write.invoke  ( target, value ) ; 
  
  
     results.append  ( "Transferred property " )  
            .append  ( name )  
            .append  ( " = " )  
            .append  ( value [ 0 ]  )  
            .append  ( "." )  
            .append  ( "\r\n" ) ; 
  
  
     break Target; 
        }  
      }  
     catch  ( Exception ex )  
      {  
   results.append  ( "Exception transferring property " )  
          .append  ( name )  
          .append  ( ": " )  
          .append  ( ex.getClass  (  ) .getName  (  )  )  
          .append  ( "\r\n" ) ; 
      }  
  }  
  
  
   return results.toString  (  ) ; 
  
  
  } 


public Method getWriteMethod()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[814]Invoke JavaBean method via introspection
By mohan { at } componentplus { dot } com on 2004/06/21 09:09:53  Rate
import java.beans.*; 
 import java.lang.reflect.*; 
  
  
 public class BeanUtil  {  
 ...... 
 .... 
  
  
  
 CustomerBean bean = new CustomerBean (  ) ; 
 BeanInfo bi = Introspector.getBeanInfo ( bean.getClass (  )  ) ; 
 PropertyDescriptor pd = getPropertyDescriptor ( bean, "CustomerName" ) ; 
 Method setter = pd.getWriteMethod (  ) ; 
 Class [  ]  paramTypes = setter.getParameterTypes (  ) ; 
 Object [  ]  args = new Object [ 1 ] ; 
 args [ 0 ]  = "Mohan"; 
 setter.invoke ( bean, args ) ;


public int hashCode()
See Also:
Hashtable, Object.equals(java.lang.Object)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isBound()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isConstrained()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public PropertyDescriptor(String propertyName,
                          Class<?> beanClass)
                   throws IntrospectionException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public PropertyDescriptor(String propertyName,
                          Class<?> beanClass,
                          String readMethodName,
                          String writeMethodName)
                   throws IntrospectionException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public PropertyDescriptor(String propertyName,
                          Method readMethod,
                          Method writeMethod)
                   throws IntrospectionException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setBound(boolean bound)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setConstrained(boolean constrained)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setPropertyEditorClass(Class<?> propertyEditorClass)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setReadMethod(Method readMethod)
                   throws IntrospectionException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setWriteMethod(Method writeMethod)
                    throws IntrospectionException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags