ca.intelliware.amakihi.util.property
Class PropertiesManager

java.lang.Object
  |
  +--ca.intelliware.amakihi.util.property.PropertiesManager

public class PropertiesManager
extends java.lang.Object

This class provides some standard utilities for getting and using properties associated with a class.

Version:
$Revision: 1.1 $
Author:
Intelliware Development

Method Summary
static PropertiesManager getInstance()
           
 java.util.Properties getProperties(java.lang.Class aClass, java.lang.String resourceName)
           
 java.util.Properties getProperties(java.lang.Object obj, java.lang.String resourceName)
           
 void initializeBeanFrom(java.lang.Object bean, java.util.Properties properties)
          This method introspects a Java Bean and for all writeable bean properties, it looks in the provided properties file to get a value which will be used to set the property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getProperties

public java.util.Properties getProperties(java.lang.Class aClass,
                                          java.lang.String resourceName)

getInstance

public static PropertiesManager getInstance()

initializeBeanFrom

public void initializeBeanFrom(java.lang.Object bean,
                               java.util.Properties properties)
                        throws InitializeFromPropertiesException
This method introspects a Java Bean and for all writeable bean properties, it looks in the provided properties file to get a value which will be used to set the property.

Example:

Suppose the Java Bean had three properties:

  1. lastName : String
  2. firstName : String
  3. bankBalance : BigDecimal

This method will look in the properties file for each of these properties and will then call the appropriate set methods (setLastName(), setFirstName(), and setBankBalance()).

To handle the bankBalance (and other non-String classes), this method will look for a constructor that takes a String parameter, and perform the equivalent of new BigDecimal("12345.67").

This method knows how to handle the standard primitive types; an int property, for example, will be set by first calling the new Integer(propertyValueAsString) constructor of the object type.


getProperties

public java.util.Properties getProperties(java.lang.Object obj,
                                          java.lang.String resourceName)


Copyright 2002 Intelliware Development. All Rights Reserved.