SolarMetric Kodo JDO 2.5.0 Reverse Schema Tool

com.solarmetric.rd.conf
Class AbstractConfiguration

java.lang.Object
  |
  +--com.solarmetric.rd.conf.AbstractConfiguration
All Implemented Interfaces:
java.beans.BeanInfo, Configuration, java.io.Externalizable, java.io.Serializable
Direct Known Subclasses:
SimpleConfiguration

public abstract class AbstractConfiguration
extends java.lang.Object
implements Configuration, java.io.Externalizable

Provides base configuration functionality, including serialization, the equals and hashCode contracts, and default property loading.

See the loadDefaults() method for a description of how this class goes about loading default property values.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface java.beans.BeanInfo
ICON_COLOR_16x16, ICON_COLOR_32x32, ICON_MONO_16x16, ICON_MONO_32x32
 
Constructor Summary
AbstractConfiguration()
           
 
Method Summary
protected  void checkFrozen()
          Checks if the configuration has been frozen and if so throws a IllegalStateException, otherwise returns silently.
 boolean equals(java.lang.Object other)
          Performs an equality check based on the properties returned from toProperties().
 void free()
          Free the resources used by this object.
 void fromProperties(java.util.Properties props)
          Set this Configuration via the given Properties.
 java.beans.BeanInfo[] getAdditionalBeanInfo()
           
 java.beans.BeanDescriptor getBeanDescriptor()
           
 int getDefaultEventIndex()
           
 int getDefaultPropertyIndex()
           
 java.beans.EventSetDescriptor[] getEventSetDescriptors()
           
 java.awt.Image getIcon(int kind)
           
 java.beans.MethodDescriptor[] getMethodDescriptors()
           
protected abstract  java.lang.String getProductName()
          Return the product name.
 java.beans.PropertyDescriptor[] getPropertyDescriptors()
           
protected abstract  java.util.Collection getValues()
          Return the configurable Values for this configuration.
 int hashCode()
          Computes hash code based on the properties returned from toProperties().
 boolean isFrozen()
          Return true if the configuration has been frozen.
 boolean loadDefaults()
          Invoke this method to load default values from properties.
 void readExternal(java.io.ObjectInput in)
          Implementation of the Externalizable interface to read from the properties written by writeExternal(java.io.ObjectOutput).
 void setFrozen(boolean frozen)
          Following a call to this method, calls to checkFrozen() will throw an exception.
 void setProperties(java.lang.String resourceName)
          This method loads the named resource as a properties file.
 java.util.Properties toProperties()
          Properties objects are cached once created so that calls to this method are relatively cheap (the properties object is still cloned for each call).
 void writeExternal(java.io.ObjectOutput out)
          Implementation of the Externalizable interface to write the properties returned by toProperties().
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.solarmetric.rd.conf.Configuration
getLog, getLogFactory, setLog, setLogFactory
 

Constructor Detail

AbstractConfiguration

public AbstractConfiguration()
Method Detail

getProductName

protected abstract java.lang.String getProductName()
Return the product name.

See Also:
loadDefaults()

getValues

protected abstract java.util.Collection getValues()
Return the configurable Values for this configuration.


loadDefaults

public boolean loadDefaults()
Invoke this method to load default values from properties. The method will first check the com.solarmetric.<product-name>.properties system property for the location of a properties file to parse, where product-name is the return value of the getProductName() method. If no system property is defined, the default resource location of <product-name>.properties is used. If it exists, the resource is parsed as a properties file. All system properties are then added; they override any same-named properties in the resource. The combined properties are then loaded into this configuration.

Returns:
true if a properties resource was found, false otherwise
See Also:
ClassLoader.getResource(java.lang.String)

setFrozen

public void setFrozen(boolean frozen)
Following a call to this method, calls to checkFrozen() will throw an exception. This method is meant to lock down the configuration; subclasses should therefore call checkFrozen() as the first line in all mutator methods.

Specified by:
setFrozen in interface Configuration

isFrozen

public boolean isFrozen()
Return true if the configuration has been frozen.

Specified by:
isFrozen in interface Configuration

toProperties

public java.util.Properties toProperties()
Properties objects are cached once created so that calls to this method are relatively cheap (the properties object is still cloned for each call). The cached instance is cleared on calls to checkFrozen(), because it precedes all state changes.

Specified by:
toProperties in interface Configuration
See Also:
Configuration.toProperties()

fromProperties

public void fromProperties(java.util.Properties props)
Description copied from interface: Configuration
Set this Configuration via the given Properties. Any keys missing from the given properties will not be set. Note that changes made to this Properties object will not be automatically reflected in this Configuration object.

Specified by:
fromProperties in interface Configuration

setProperties

public void setProperties(java.lang.String resourceName)
                   throws java.io.IOException
This method loads the named resource as a properties file. It is useful for auto-configuration tools so users can specify a properties value with the name of a resource.

java.io.IOException

checkFrozen

protected void checkFrozen()
Checks if the configuration has been frozen and if so throws a IllegalStateException, otherwise returns silently. Implementations should call this method before setting any state.


equals

public boolean equals(java.lang.Object other)
Performs an equality check based on the properties returned from toProperties().

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Computes hash code based on the properties returned from toProperties().

Overrides:
hashCode in class java.lang.Object

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Implementation of the Externalizable interface to read from the properties written by writeExternal(java.io.ObjectOutput).

Specified by:
readExternal in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Implementation of the Externalizable interface to write the properties returned by toProperties().

Specified by:
writeExternal in interface java.io.Externalizable
java.io.IOException

getAdditionalBeanInfo

public java.beans.BeanInfo[] getAdditionalBeanInfo()
Specified by:
getAdditionalBeanInfo in interface java.beans.BeanInfo

getBeanDescriptor

public java.beans.BeanDescriptor getBeanDescriptor()
Specified by:
getBeanDescriptor in interface java.beans.BeanInfo

getDefaultEventIndex

public int getDefaultEventIndex()
Specified by:
getDefaultEventIndex in interface java.beans.BeanInfo

getDefaultPropertyIndex

public int getDefaultPropertyIndex()
Specified by:
getDefaultPropertyIndex in interface java.beans.BeanInfo

getEventSetDescriptors

public java.beans.EventSetDescriptor[] getEventSetDescriptors()
Specified by:
getEventSetDescriptors in interface java.beans.BeanInfo

getIcon

public java.awt.Image getIcon(int kind)
Specified by:
getIcon in interface java.beans.BeanInfo

getMethodDescriptors

public java.beans.MethodDescriptor[] getMethodDescriptors()
Specified by:
getMethodDescriptors in interface java.beans.BeanInfo

getPropertyDescriptors

public java.beans.PropertyDescriptor[] getPropertyDescriptors()
Specified by:
getPropertyDescriptors in interface java.beans.BeanInfo

free

public void free()
Description copied from interface: Configuration
Free the resources used by this object.

Specified by:
free in interface Configuration

SolarMetric Kodo JDO 2.5.0 Reverse Schema Tool

Copyright 2001,2002,2003 SolarMetric, Inc. All Rights Reserved.