net.sourceforge.esw.properties
Class DefaultPropertySource

java.lang.Object
  |
  +--net.sourceforge.esw.util.SupportObject
        |
        +--net.sourceforge.esw.graph.Node
              |
              +--net.sourceforge.esw.properties.DefaultPropertySource
All Implemented Interfaces:
java.lang.Cloneable, ICloneable, INode, IPropertySource, ISupportObject, java.io.Serializable

public class DefaultPropertySource
extends Node
implements IPropertySource

Default implementation of IPropertySource.

Properties are any persistent data source that parameterizes behavior of a running application. That data source could be XML, a relational database, or a java.util.Properties file..

For the ESW framework, properties are desinged to be aggregate. That is, multiple properites should be able to be searched against at a specific ranking. This allows many properity sources to be considered as one property source. It also allows one property source to override the properies found in another property source by holding a higher rank in the aggregate property set. See IPropertyAggregator for form information.

To load properties from their data source, call the load method.

Properties can be read-only or writable. The setWriteable and isWriteable methods determine whether an IPropertySource instance is writeable. Writeable indicates that a property cannot be saved, not that it cannot be added to this IPropertySource instance.

If the properties represented by this IPropertySource instance are writable, then the save method saves the properties to the represented property source.

To allow easy access to Properties, this IPropertySource implementor extends the INode interface.

To create an new instance of an IPropertySource and add it to the default IPropertyAggregator instance, see PropertyUtil.createXYZPropertySource().

To create a new instance of an IPropertySource independant of an IPropertyAggregator instance, see PropertyFactory.createPropertySource().

Examples:

    // To create a file based XML Property Source and add it to the default
    // IPropertyAggregator instance at the first, or highest, rank:
    PropertyUtil.createFileXMLPropertySource( "MyFilename.xml", 1 );

    // To create an URL based XML Property Source and add it to the default
    // IPropertyAggregator instance at the first, or highest, rank:
    PropertyUtil.createURLXMLPropertySource( "www.somewhere-that-does-not-exist.com", 1 );

    // To create an IPropertySource independant of the IPropertyAggregator:
    IPropertSource source = PropertyFactory.createPropertySource( getMyTransducer() );
 

See Also:
IPropertyAggregator, PropertyManager, PropertyFactory, Serialized Form

Field Summary
protected  boolean bWriteable
          States whether this DefaultPropertySource instance is a writeable IPropertySource instance.
protected  ITransducer transducer
          The ITransducer instance for this DefaultPropertySource instance.
 
Fields inherited from class net.sourceforge.esw.graph.Node
list, map, parents, value
 
Fields inherited from class net.sourceforge.esw.util.SupportObject
id, properties, propertyChildren, propertyListeners, vetoableChildren, vetoableListeners
 
Constructor Summary
protected DefaultPropertySource(ITransducer aTransducer)
          Creates a new DefaultPropertySource instance.
protected DefaultPropertySource(ITransducer aTransducer, boolean bWriteable)
          Creates a new DefaultPropertySource instance with the specified writeable setting.
 
Method Summary
 boolean isWriteable()
          Returns whether this IPropertySource instance is a writeable IPropertySource instance.
 void load()
          Loads properties from the properties source represented by this IPropertySource instance.
 void save()
          Saves all modified properties to the properties source represented by this IPropertySource instance.
 void setWriteable(boolean aWriteable)
          Sets whether this IPropertySource instance is a writeable IPropertySource instance.
 
Methods inherited from class net.sourceforge.esw.graph.Node
acceptVisitor, add, add, addParent, clear, clone, containsID, equals, get, get, getList, getParents, getValue, hashCode, hashCodeForNode, isEmpty, iterator, nodesEqual, remove, removeParent, setValue, size, toString
 
Methods inherited from class net.sourceforge.esw.util.SupportObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getID, getProperty, getPropertySize, propertyKeys, removeProperty, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener, setID, setProperty
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sourceforge.esw.graph.INode
acceptVisitor, add, add, addParent, clear, containsID, get, get, getList, getParents, getValue, isEmpty, iterator, remove, removeParent, setValue, size
 
Methods inherited from interface net.sourceforge.esw.util.ISupportObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getID, getProperty, getPropertySize, propertyKeys, removeProperty, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener, setID, setProperty
 
Methods inherited from interface net.sourceforge.esw.util.ICloneable
clone
 

Field Detail

bWriteable

protected boolean bWriteable
States whether this DefaultPropertySource instance is a writeable IPropertySource instance.

transducer

protected ITransducer transducer
The ITransducer instance for this DefaultPropertySource instance.
Constructor Detail

DefaultPropertySource

protected DefaultPropertySource(ITransducer aTransducer)
Creates a new DefaultPropertySource instance. By default, this DefaultPropertySource instance is writable.
Parameters:
aTransducer - the ITransducer instance used by this DefaultPropertySource instance to load or save Properties.

DefaultPropertySource

protected DefaultPropertySource(ITransducer aTransducer,
                                boolean bWriteable)
Creates a new DefaultPropertySource instance with the specified writeable setting.
Parameters:
aTransducer - the ITransducer instance used by this DefaultPropertySource instance to load or save Properties.
aWriteable - if true, this IPropertySource instance will be created as being writable, otherwise, this IPropertySource instance will be read-only.
Method Detail

isWriteable

public boolean isWriteable()
Returns whether this IPropertySource instance is a writeable IPropertySource instance.
Specified by:
isWriteable in interface IPropertySource
Returns:
true if this IPropertySource instance is writeable, false if not.

setWriteable

public void setWriteable(boolean aWriteable)
Sets whether this IPropertySource instance is a writeable IPropertySource instance.
Specified by:
setWriteable in interface IPropertySource
Parameters:
aWriteable - if true, then this IPropertySource instance is writeable, false otherwise.

save

public void save()
          throws java.lang.UnsupportedOperationException,
                 java.lang.Exception
Saves all modified properties to the properties source represented by this IPropertySource instance.
Specified by:
save in interface IPropertySource
Throws:
OptionNotSupportedException - if the operation is unsupported.
java.lang.Exception - if an error occurs during the save process.

load

public void load()
          throws java.lang.Exception
Loads properties from the properties source represented by this IPropertySource instance.
Specified by:
load in interface IPropertySource
Throws:
java.lang.Exception - if any error occurs during the load process.


Copyright 2002 Free Software Foundation. All Rights Reserved.