se.datadosen.util
Class BeanBinder

java.lang.Object
  extended by se.datadosen.util.BeanBinder

public class BeanBinder
extends java.lang.Object

Utility class for synchronizing a Swing GUI with JavaBean properties. Also synchronizes a bean with a property file or command line parameters. Synchronization is performed when calling getProperties() and setProperties(). Matching is done where the name of a property corresponds to the name of a GUI element.
Copyright (c) 2005, David Ekholm Datadosen


Constructor Summary
BeanBinder()
           
 
Method Summary
static void debug(java.lang.Object bean, java.lang.Object jComponentHolder)
           
static java.util.Properties getProperties(java.lang.Object bean)
          Return a java.util.Property object representing the state of a JavaBean
static java.util.Properties getProperties(java.lang.Object bean, boolean nullProperties)
          Return a java.util.Property object representing the state of a JavaBean
static java.util.Properties getProperties(java.lang.Object bean, boolean nullProperties, java.util.Properties existing)
          Return a java.util.Property object representing the state of a JavaBean
static void getProperties(java.lang.Object bean, java.lang.Object jComponentHolder)
          Update a Swing GUI with the properties from a JavaBean.
static void getProperties(java.lang.Object bean, java.lang.Object[] holders)
           
static java.util.Properties getProperties(java.lang.Object bean, java.util.Properties existing)
          Return a java.util.Property object representing the state of a JavaBean
static java.util.Properties parseArgsOptions(java.lang.String[] args)
          Utility method to generate a Property object from command line parameters
static void setProperties(java.lang.Object bean, java.util.Map props)
          Set JavaBean properties given a Map object
static void setProperties(java.lang.Object bean, java.lang.Object jComponentHolder)
          Update a JavaBean from a Swing GUI.
static void setProperties(java.lang.Object bean, java.lang.Object[] source)
          Update a JavaBean from a Swing GUI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanBinder

public BeanBinder()
Method Detail

debug

public static void debug(java.lang.Object bean,
                         java.lang.Object jComponentHolder)
                  throws java.lang.Exception
Throws:
java.lang.Exception

getProperties

public static void getProperties(java.lang.Object bean,
                                 java.lang.Object[] holders)
                          throws java.lang.Exception
Throws:
java.lang.Exception

getProperties

public static void getProperties(java.lang.Object bean,
                                 java.lang.Object jComponentHolder)
Update a Swing GUI with the properties from a JavaBean. Currently supports the following types of GUI elements:

getProperties

public static java.util.Properties getProperties(java.lang.Object bean)
                                          throws java.lang.Exception
Return a java.util.Property object representing the state of a JavaBean

Throws:
java.lang.Exception

getProperties

public static java.util.Properties getProperties(java.lang.Object bean,
                                                 java.util.Properties existing)
                                          throws java.lang.Exception
Return a java.util.Property object representing the state of a JavaBean

Parameters:
bean - JavaBean to read properties from
existing - Existing properties object to add properties to
Throws:
java.lang.Exception

getProperties

public static java.util.Properties getProperties(java.lang.Object bean,
                                                 boolean nullProperties)
                                          throws java.lang.Exception
Return a java.util.Property object representing the state of a JavaBean

Parameters:
bean - JavaBean to read properties from
nullProperties - if null-value properties are to be included
Throws:
java.lang.Exception

getProperties

public static java.util.Properties getProperties(java.lang.Object bean,
                                                 boolean nullProperties,
                                                 java.util.Properties existing)
                                          throws java.lang.Exception
Return a java.util.Property object representing the state of a JavaBean

Parameters:
nullProperties - if null-value properties are to be included
existing - existing Properties object to add properties to
Throws:
java.lang.Exception

setProperties

public static void setProperties(java.lang.Object bean,
                                 java.util.Map props)
                          throws BeanBinderException
Set JavaBean properties given a Map object

Throws:
BeanBinderException

setProperties

public static void setProperties(java.lang.Object bean,
                                 java.lang.Object[] source)
Update a JavaBean from a Swing GUI. See getProperties() for a list of supported GUI elements.

Parameters:
bean - JavaBean to set properties on
source - objects with GUI elements (public instances of JComponent objects)

setProperties

public static void setProperties(java.lang.Object bean,
                                 java.lang.Object jComponentHolder)
                          throws BeanBinderException
Update a JavaBean from a Swing GUI. See getProperties() for a list of supported GUI elements.

Parameters:
bean - JavaBean to set properties on
jComponentHolder - object with GUI elements (public instances of JComponent objects)
Throws:
BeanBinderException

parseArgsOptions

public static java.util.Properties parseArgsOptions(java.lang.String[] args)
Utility method to generate a Property object from command line parameters