net.sf.morph.wrap
Interface Bean

All Superinterfaces:
Sizable, Wrapper
All Known Subinterfaces:
DecoratedBean

public interface Bean
extends Wrapper, Sizable

A wrapper around 'bean-like' structures. Examples of 'bean-like' structures include a java.lang.Object, a java.util.Map, or any other class that logically has a set of properties that can be manipulated by name.

Since:
Jan 16, 2005
Author:
Matt Sgarlata

Method Summary
 java.lang.Object get(java.lang.String propertyName)
          Retrieves the value of the given property.
 java.lang.String[] getPropertyNames()
          Gets the names of the properties which are currently defined for this bean.
 java.lang.Class getType(java.lang.String propertyName)
          Specifies the least restrictive type that may be assigned to the given property.
 boolean isReadable(java.lang.String propertyName)
          Specifies whether the given property is readable.
 boolean isWriteable(java.lang.String propertyName)
          Specifies whether the given property is writeable.
 void set(java.lang.String propertyName, java.lang.Object propertyValue)
          Sets the value of the given property.
 
Methods inherited from interface net.sf.morph.wrap.Sizable
getSize
 

Method Detail

getPropertyNames

java.lang.String[] getPropertyNames()
Gets the names of the properties which are currently defined for this bean. Note that some beans (e.g. - Maps) allow the creation of new properties, which means isWriteable may return true for property names that are not included in the return value of this method.

Returns:
the names of the properties which are currently defined for this bean. Note that some beans (e.g. - Maps) allow the creation of new properties, which means isWriteable may return true for property names that are not included in the return value of this method.

getType

java.lang.Class getType(java.lang.String propertyName)
                        throws WrapperException
Specifies the least restrictive type that may be assigned to the given property. In the case of a weakly typed bean, the correct value to return is simply Object.class, which indicates that any type can be assigned to the given property.

Parameters:
propertyName - the name of the property
Returns:
the least restrictive type that may be assigned to the given property. In the case of a weakly typed bean, the correct value to return is simply Object.class, which indicates that any type can be assigned to the given property
Throws:
WrapperException - if getPropertyNames returns null or if the type could not be retrieved for some reason

isReadable

boolean isReadable(java.lang.String propertyName)
                   throws WrapperException
Specifies whether the given property is readable. A reflector can always determine if a property is readable by attempting to read the property value, so this method can be counted on to truly indicate whether or not the given property is readable.

Parameters:
propertyName - the name of the property
Returns:
true if the property is readable, or
false, otherwise
Throws:
WrapperException - if getPropertyNames returns null or if the readability of the property cannot be determined

isWriteable

boolean isWriteable(java.lang.String propertyName)
                    throws WrapperException
Specifies whether the given property is writeable. If it is not possible to determine whether the given property is writeable, this method may simply return true. This method only guarantees that if isWriteable returns false, the method is not writeable. The method may or may not be writeable if this method returns true.

Parameters:
propertyName - the name of the property
Returns:
false if the property is not writeable or
true if the property is writeable or if this reflector cannot determine for sure whether or not the property is writeable
Throws:
WrapperException - if getPropertyNames returns null or if the writeability of the property cannot be determined

get

java.lang.Object get(java.lang.String propertyName)
                     throws WrapperException
Retrieves the value of the given property.

Parameters:
propertyName - the name of the property
Returns:
the property's value
Throws:
WrapperException - if getPropertyNames returns null or if the value of the property cannot be determined

set

void set(java.lang.String propertyName,
         java.lang.Object propertyValue)
         throws WrapperException
Sets the value of the given property.

Parameters:
propertyName - the name of the property
propertyValue - the value to assign to the given property
Throws:
WrapperException - if getPropertyNames returns null or if the property cannot be set for some other reason (e.g. because propertyValue is of the wrong type)


Copyright © 2004-2008.