org.xulux.dataprovider.bean
Class BeanField

java.lang.Object
  extended by org.xulux.dataprovider.bean.BeanField
All Implemented Interfaces:
org.xulux.api.dataprovider.IField

public class BeanField
extends java.lang.Object
implements org.xulux.api.dataprovider.IField

This class contains all the symantics for working on a bean.

Version:
$Id: BeanField.java,v 1.1 2005/12/18 12:58:23 mvdb Exp $
Author:
Martin van den Bemt

Constructor Summary
BeanField()
          Constructor for BeanField.
BeanField(java.lang.reflect.Method method)
          Contructor that takes a method
 
Method Summary
 void addParameter(BeanParameter parameter)
          Add a single parameter to the parameter list
 boolean equals(java.lang.Object object)
          Checks if we are talking about the same field..
 java.lang.String getAlias()
          Returns the alias.
protected  java.lang.Object[] getArgs()
           
protected  java.lang.reflect.Method getChangeMethod()
           
 org.xulux.api.dataprovider.IMapping getMapping()
           
 java.lang.reflect.Method getMethod()
          Returns the method.
 java.lang.String getName()
          Returns the name.
 java.util.List getParameters()
           
 java.lang.String getRealField()
           
protected  java.lang.Object[] getSetMethodArgs(java.lang.Object value)
          No nullchecking is done in this method, the caller should check if it can correctly call this method.
 java.lang.Class getType()
           
 java.lang.Object getValue(java.lang.Object bean)
          Get the value from the specified bean.
 boolean hasTempRealField()
           
 boolean isBaseType()
          Returns the baseType.
 boolean isReadOnly()
           
 void removeTempRealField()
          Remove the temporaray real field
 void setAlias(java.lang.String alias)
          Sets the alias.
 void setBaseType(boolean baseType)
          Sets the baseType.
 void setChangeMethod(java.lang.Class clazz, java.lang.String name)
          Convenience method to set the changemethod.
 void setChangeMethod(java.lang.reflect.Method method)
           
 void setMapping(BeanMapping mapping)
          Set the mapping for reference
 void setMethod(java.lang.reflect.Method method)
          Sets the method.
 void setParameters(java.util.List parameters)
          Sets the parameters of the beanfield.
 void setProperty(java.lang.String name, java.lang.String value)
           
 void setRealField(java.lang.String realField)
           
 void setTempRealField(java.lang.String realField)
          Set a temporary realfield, which is not dictionary based.
 java.lang.Object setValue(java.lang.Object bean, java.lang.Object value)
          Sets a new value in the field Exceptions will be eaten.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BeanField

public BeanField()
Constructor for BeanField.


BeanField

public BeanField(java.lang.reflect.Method method)
Contructor that takes a method

Parameters:
method - - the method to use for reading the value
Method Detail

isReadOnly

public boolean isReadOnly()
Specified by:
isReadOnly in interface org.xulux.api.dataprovider.IField
Returns:
specifies if the field is just for display (eg doesn't have a setter method)

setValue

public java.lang.Object setValue(java.lang.Object bean,
                                 java.lang.Object value)
Sets a new value in the field Exceptions will be eaten.

Specified by:
setValue in interface org.xulux.api.dataprovider.IField
Parameters:
bean - - the bean to set the value on
value - - the value to set to the bean
Returns:
false on failure or if field is read only

getValue

public java.lang.Object getValue(java.lang.Object bean)
Get the value from the specified bean. Exceptions will be eaten.

Specified by:
getValue in interface org.xulux.api.dataprovider.IField
Parameters:
bean - - the bean to get the value from
Returns:
the value of the field or null when an error has happened or no value exists

getArgs

protected java.lang.Object[] getArgs()
Returns:
the list of parameters to pass into the method.

getSetMethodArgs

protected java.lang.Object[] getSetMethodArgs(java.lang.Object value)
No nullchecking is done in this method, the caller should check if it can correctly call this method. (eg isReadOnly should be false)

Parameters:
value - get the setmethod for the specified value
Returns:
the list of methods to pass into a setmethod to correctly set a value.

getName

public java.lang.String getName()
Returns the name.

Specified by:
getName in interface org.xulux.api.dataprovider.IField
Returns:
String

getMethod

public java.lang.reflect.Method getMethod()
Returns the method.

Returns:
Method

setMethod

public void setMethod(java.lang.reflect.Method method)
Sets the method.

Parameters:
method - The method to set

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
String representation of the beanField

equals

public boolean equals(java.lang.Object object)
Checks if we are talking about the same field..

Overrides:
equals in class java.lang.Object
Parameters:
object - - the object to perform the equals on
Returns:
If the object is a String it will compare it with the Alias (case insensitive). If the object is another BeanField, it will see if the declaring class and the method name is the same In all other cases it will return false

isBaseType

public boolean isBaseType()
Returns the baseType.

Returns:
boolean

setBaseType

public void setBaseType(boolean baseType)
Sets the baseType.

Parameters:
baseType - The baseType to set

setChangeMethod

public void setChangeMethod(java.lang.reflect.Method method)
Parameters:
method - - the change method for this field.

setChangeMethod

public void setChangeMethod(java.lang.Class clazz,
                            java.lang.String name)
Convenience method to set the changemethod. It will figure out which changemethod it will be..

Parameters:
clazz - the class to investigate
name - the name of the change method

getAlias

public java.lang.String getAlias()
Returns the alias.

Specified by:
getAlias in interface org.xulux.api.dataprovider.IField
Returns:
String

setAlias

public void setAlias(java.lang.String alias)
Sets the alias.

Parameters:
alias - The alias to set

setParameters

public void setParameters(java.util.List parameters)
Sets the parameters of the beanfield. This will overwrite all previous values. Use addParameter instead if you want to preserve them

Parameters:
parameters - the parameters to use

getParameters

public java.util.List getParameters()
Returns:
a list with currently know parameters or null when no parameters are known.

addParameter

public void addParameter(BeanParameter parameter)
Add a single parameter to the parameter list

Parameters:
parameter - the parameter to add

setRealField

public void setRealField(java.lang.String realField)
Parameters:
realField - the real field to use

setTempRealField

public void setTempRealField(java.lang.String realField)
Set a temporary realfield, which is not dictionary based.

Parameters:
realField - the temporary realfield

hasTempRealField

public boolean hasTempRealField()
Returns:
if this field has a temporary realfield

removeTempRealField

public void removeTempRealField()
Remove the temporaray real field


getRealField

public java.lang.String getRealField()
Returns:
the real underlying field.

getType

public java.lang.Class getType()
Specified by:
getType in interface org.xulux.api.dataprovider.IField
Returns:
the returntype of the getmethod.

getChangeMethod

protected java.lang.reflect.Method getChangeMethod()
Returns:
the changemethod

getMapping

public org.xulux.api.dataprovider.IMapping getMapping()
Specified by:
getMapping in interface org.xulux.api.dataprovider.IField
See Also:
IField.getMapping()

setMapping

public void setMapping(BeanMapping mapping)
Set the mapping for reference

Parameters:
mapping - the mapping

setProperty

public void setProperty(java.lang.String name,
                        java.lang.String value)
Specified by:
setProperty in interface org.xulux.api.dataprovider.IField
See Also:
IField.setProperty(java.lang.String, java.lang.String)


Copyright © 2006-2007 Martin van den Bemt. All Rights Reserved.