edu.wpi.cs.dsrg.xmldb.xat.common.operator
Class XATPropertiesImp

java.lang.Object
  |
  +--edu.wpi.cs.dsrg.xmldb.xat.common.operator.XATPropertiesImp
Direct Known Subclasses:
StatisticsGatherer, XATQueryObjectImp

public abstract class XATPropertiesImp
extends java.lang.Object
implements XATProperties

Provides an abstract implementation of the XATProperties interface. Any type that wants to make use of Properties should derive from this type. Note, in order to make use of the StatisticsGatherer and Statistics the type should derive from XATQueryObjectImp b/c this type does not provide an interface to the StatisticsGatherer.

The setProperty method is abstract so that implementing classes can provide some validation. This class provides some basic validation- ensuring values are non zero. If more is required, it should be provided by the lower classes.

Each class that extends this class should set the initial properties in the setDefaultProperties method using addProperty.

The properties are used to configure the various objects in the system and this class provides a standard means to access the properties. The properties only support Strings for both name and value.

Since:
1.0

Constructor Summary
XATPropertiesImp()
          Create a new Properties, and calls setDefaultProperties().
 
Method Summary
protected  void addProperty(java.lang.String name, java.lang.String defaultValue)
          Adds a new property that will be supported with a given default value.
 java.util.Enumeration getProperties()
          Returns an enumeration of property names supported by this query object
 java.lang.String getProperty(java.lang.String name)
          retrieve the value of the property with the given name.
 boolean isValidPropertyName(java.lang.String nameToCheck)
          Checks if the given property is valid for this QueryObject.
protected  void setDefaultProperties()
          called by the constructor.
protected  void setNewPropertyValue(java.lang.String name, java.lang.String value)
          This method actually sets the property value.
 void setProperty(java.lang.String name, java.lang.String value)
          sets the given property to the new value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XATPropertiesImp

public XATPropertiesImp()
Create a new Properties, and calls setDefaultProperties().
Since:
1.0
Method Detail

addProperty

protected void addProperty(java.lang.String name,
                           java.lang.String defaultValue)
Adds a new property that will be supported with a given default value.
Parameters:
name - java.lang.String the name of the property
defaultValue - java.lang.String its default value.
Since:
1.0

getProperties

public java.util.Enumeration getProperties()
Returns an enumeration of property names supported by this query object
Specified by:
getProperties in interface XATProperties
Returns:
an Enumeration
Since:
1.0

getProperty

public java.lang.String getProperty(java.lang.String name)
retrieve the value of the property with the given name.
Specified by:
getProperty in interface XATProperties
Parameters:
name - the name of the property to return
Returns:
String the value of the property
Throws:
java.lang.IllegalArgumentException - if the given property cannot be found
Since:
1.0

isValidPropertyName

public boolean isValidPropertyName(java.lang.String nameToCheck)
Checks if the given property is valid for this QueryObject.
Specified by:
isValidPropertyName in interface XATProperties
Returns:
boolean true if the property is supported by this object, false otherwise.
Since:
1.0

setDefaultProperties

protected void setDefaultProperties()
called by the constructor. this will set the default properties that the ALL query objects will support. Each subclass should override this method and add their own unique properties, but should also call super.setDefaultProperties() so that the common properties may be set.
Since:
1.0

setNewPropertyValue

protected void setNewPropertyValue(java.lang.String name,
                                   java.lang.String value)
This method actually sets the property value. Because the properties variable is private, no other class may actually access it. Therefore, this method is needed so that sub classes may update the internal values.
Parameters:
name - java.lang.String
value - java.lang.String
Since:
1.0

setProperty

public void setProperty(java.lang.String name,
                        java.lang.String value)
                 throws java.lang.Exception
sets the given property to the new value. This method is responsible for validating the given property. An exception is thrown if the value is not correct. Validation should be done in the following manner: First the method should check if the object supports the given property by calling isValidPropertyName(String). If it is not a valid property name, then an exception should be thrown.

Once it is known that the object supports the property, the value must be validated. Each implementor of XATStatistics has a set of properties that are common to all of its types and some that are specific to types. For example, all XATOperators (which implement XATStatistics) have certain properties while an individual XATOperator has specific properties. The indivual types should only validate their own specific types. If the caller is trying to set a common type, it should be validated by the super class by calling super.setProperty(name, value). This will reduce duplicate code.

When it is determined the name / value pair is correct, the pair is updated using setNewPropertyValue()

XATStatisticsImp provides default validation by checking to see if the property's value is >=0. propertyValues that are Strings will just be set. If the property requires more strict constraints than this, it is up to the subclass that created the property to validate it (as described above).

Specified by:
setProperty in interface XATProperties
Parameters:
name - the name of the property to set
value - the new value of the property
Throws:
java.lang.Exception - if the given property cannot be found or if the value is not valid for the given property.
Since:
1.0