Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.jdaemon.util
Class BeanAccessor  view BeanAccessor download BeanAccessor.java

java.lang.Object
  extended byorg.jdaemon.util.BeanAccessor
All Implemented Interfaces:
Accessor

public class BeanAccessor
extends java.lang.Object
implements Accessor

Accessor which allows items stored in a bean-like object to be given symbolic names. Every symbolic name will have to have a corresponding 'get' method. For example, an attribute AccountName will have to have a corresponding getAccountName method.


Field Summary
private  java.util.HashMap get_methods
           
private  java.lang.Class my_class
           
 
Constructor Summary
BeanAccessor(java.lang.Class my_class)
          Creates a new instance of BeanAccessor.
BeanAccessor(java.lang.Class my_class, java.lang.String[] attributes)
          Creates a new instance of BeanAccessor.
 
Method Summary
 java.lang.Object getAttribute(java.lang.String name, java.lang.Object obj)
          Retrieve the attribute value corresponding to an attribute name from specific data object.
 java.util.Iterator getAttributeNames()
          Return an iterator over all the attributes understood by this Accessor.
 void setAttribute(java.lang.String name, java.lang.Object bean, java.lang.Object value)
          Not currently supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

my_class

private java.lang.Class my_class

get_methods

private java.util.HashMap get_methods
Constructor Detail

BeanAccessor

public BeanAccessor(java.lang.Class my_class)
Creates a new instance of BeanAccessor. All no-arg methods which have 'get' as the first three letters of the method name are undestood to be attribute accessors. The attribute name is taken to be the method name less the 'get' prefix.


BeanAccessor

public BeanAccessor(java.lang.Class my_class,
                    java.lang.String[] attributes)
             throws java.lang.NoSuchMethodException
Creates a new instance of BeanAccessor. This constuctor searches the given class for an accessor method for every attribute specified in the attributes array. If there is no such method for any attribute in the array, an exception is thrown.

Method Detail

getAttribute

public java.lang.Object getAttribute(java.lang.String name,
                                     java.lang.Object obj)
Retrieve the attribute value corresponding to an attribute name from specific data object.

Specified by:
getAttribute in interface Accessor

getAttributeNames

public java.util.Iterator getAttributeNames()
Return an iterator over all the attributes understood by this Accessor. An attribute name is understood by this accessor if a get method matching the attribute name exists in the class specified in the constructor.

Specified by:
getAttributeNames in interface Accessor

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object bean,
                         java.lang.Object value)
Not currently supported.

Specified by:
setAttribute in interface Accessor