UC Berkeley Group for User Interface Research
Updated November 17, 2000

edu.berkeley.guir.lib.properties
Class FlexProperties

java.lang.Object
  |
  +--edu.berkeley.guir.lib.properties.FlexProperties
All Implemented Interfaces:
PropertyConstants
Direct Known Subclasses:
ClassProperties

public class FlexProperties
extends Object
implements PropertyConstants

Extensible and definable properties. Properties are specified through a PropertySchema object, and are set in this class.

The PropertySchema defines a single schema for a property. For example, it specifies the name of the property, and whether it is a simple one, bound, constrained, or indexed.

Simple, bound, constrained, and indexed properties are the same as in Java Beans.

The FlexProperties contains a set of PropertySchema objects, as well as the values for properties. When properties are set or modified, the schema is checked at runtime to ensure that everything is okay. If it is, then the property value is modified, and the appropriate listeners are notified.

This software is distributed under the Berkeley Software License.

 Revisions:  - GUIRLib-v1.0-1.0.0, Jun 02 2000, JH
               Created class
             - GUIRLib-v1.2-1.0.0, Jun 22 2000, JH
               Touched for GUIRLib release
             - GUIRLib-v1.3-1.0.0, Aug 11 2000, JH
               Touched for GUIRLib release
             - GUIRLib-v1.4-1.0.0, Aug 31 2000, JH
               Touched for GUIRLib release
 

Since:
JDK 1.3
Version:
GUIRLib-v1.4-1.0.0, Aug 31 2000
Author:
Jason Hong ( jasonh@cs.berkeley.edu )

Fields inherited from interface edu.berkeley.guir.lib.properties.PropertyConstants
PROPERTY_BOUND, PROPERTY_CONSTRAINED, PROPERTY_INDEXED, PROPERTY_SIMPLE
 
Constructor Summary
FlexProperties()
          Creates a new properties object, points to itself as the source.
FlexProperties(Object src)
          Creates a new properties object.
FlexProperties(Object src, boolean flag)
          Creates a new properties object that only allows a specified schema.
 
Method Summary
 void addIndexedProperty(String strPropertyName, Object newVal)
          Add a value to the back of the specified indexed property.
 void addPropertyChangeListener(PropertyChangeListener l)
          Add a listener on a bound property.
 void addPropertyChangeListener(String str, PropertyChangeListener l)
          Add a listener on a bound property.
 void addSchema(PropertySchema schema)
          Add a schema.
 void addVetoableChangeListener(String str, VetoableChangeListener l)
          Add a listener on a constrained property.
 void addVetoableChangeListener(VetoableChangeListener l)
          Add a listener on a constrained property.
 void clearIndexedProperty(String strPropertyName)
          Clear out all of the values from the specified indexed property.
 boolean containsSchema(PropertySchema schema)
          Check if it contains a certain schema.
 boolean containsSchema(String strPropertyName)
          Check if it contains a certain schema.
 void disableNotify()
           
 void disableNotify(String strProperty)
           
 void enableNotify()
          Enable notifications to be sent.
 void enableNotify(String strProperty)
          Enable notifications on the specified property.
 void firePropertyChange(PropertyChangeEvent evt)
          Fire if property is enabled.
 void firePropertyChange(String str, boolean oldVal, boolean newVal)
          Convenience method, see firePropertyChange(PropertyChangeEvent)
 void firePropertyChange(String str, int oldVal, int newVal)
          Convenience method, see firePropertyChange(PropertyChangeEvent)
 void firePropertyChange(String str, Object oldVal, Object newVal)
          Convenience method, see firePropertyChange(PropertyChangeEvent)
 void fireVetoableChange(PropertyChangeEvent evt)
          Fire if property is enabled.
 void fireVetoableChange(String str, boolean oldVal, boolean newVal)
          Convenience method, see fireVetoableChange(PropertyChangeEvent)
 void fireVetoableChange(String str, int oldVal, int newVal)
          Convenience method, see fireVetoableChange(PropertyChangeEvent)
 void fireVetoableChange(String str, Object oldVal, Object newVal)
          Convenience method, see fireVetoableChange(PropertyChangeEvent)
 List getIndexedProperty(String strPropertyName)
          Get all of an indexed property.
 Object getIndexedProperty(String strPropertyName, int index)
          Get an indexed property at the specified index.
 Object getProperty(String strPropertyName)
          Get a reference to a property.
 Iterator getPropertyNames()
           
 PropertySchema getSchema(String strPropertyName)
          Get a reference to the property schema by its property name.
 boolean isEnabled()
          See if notifications are enabled in general.
 boolean isEnabled(String strProperty)
          See if notifications are enabled on the specified property.
 List removeIndexedProperty(String strPropertyName)
          Remove an indexed property entirely.
 Object removeIndexedProperty(String strPropertyName, int index)
          Remove a value from the specified indexed property.
 Object removeProperty(String strPropertyName)
          Remove a property.
 void removePropertyChangeListener(PropertyChangeListener l)
          Remove a listener on a bound property.
 void removePropertyChangeListener(String str, PropertyChangeListener l)
          Remove a listener on a bound property.
 PropertySchema removeSchema(PropertySchema schema)
          Remove a schema.
 void removeVetoableChangeListener(String str, VetoableChangeListener l)
          Remove a listener on a constrained property.
 void removeVetoableChangeListener(VetoableChangeListener l)
          Remove a listener on a constrained property.
 void setDefaultPropertyType(int type)
          Sets the default schema type of all properties created in this instance.
 void setIndexedProperty(String strPropertyName, int index, Object newVal)
          Set a value in the specified indexed property.
 void setProperty(String strPropertyName, Object newVal)
          Set a property.
 void setSourceObject(Object obj)
          Set who this properties object is attached to.
 void setSpecifiedOnly(boolean flag)
          Set whether we accept properties that have been specified in the schema only or not.
 String toString()
          Print out schema and properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FlexProperties

public FlexProperties()
Creates a new properties object, points to itself as the source.

FlexProperties

public FlexProperties(Object src)
Creates a new properties object.
Parameters:
src - is the Object this FlexProperties object represents (ie who contains the FlexProperties).

FlexProperties

public FlexProperties(Object src,
                      boolean flag)
Creates a new properties object that only allows a specified schema.
Parameters:
flag - is true if only specified properties are accepted.
src - is the Object this FlexProperties object represents (ie who contains the FlexProperties).
See Also:
setSpecifiedOnly(boolean)
Method Detail

setSourceObject

public void setSourceObject(Object obj)
Set who this properties object is attached to. Must be private because the property and vetoable change support do not allow the source to be changed.

setSpecifiedOnly

public void setSpecifiedOnly(boolean flag)
Set whether we accept properties that have been specified in the schema only or not.
Parameters:
flag - is true if only specified properties are accepted.

setDefaultPropertyType

public void setDefaultPropertyType(int type)
Sets the default schema type of all properties created in this instance.
Parameters:
type - is either PropertyConstants.PROPERTY_SIMPLE, PropertyConstants.PROPERTY_BOUND, or PropertyConstants.PROPERTY_CONSTRAINED. Don't use PropertyConstants.PROPERTY_INDEXED, since that is used automatically if one of the indexed property methods is used.

addSchema

public void addSchema(PropertySchema schema)
Add a schema.

removeSchema

public PropertySchema removeSchema(PropertySchema schema)
Remove a schema.

getSchema

public PropertySchema getSchema(String strPropertyName)
Get a reference to the property schema by its property name.
Returns:
A reference to the stored schema. This means if you change the returned value, you really change it for everyone.

containsSchema

public boolean containsSchema(PropertySchema schema)
Check if it contains a certain schema.

containsSchema

public boolean containsSchema(String strPropertyName)
Check if it contains a certain schema.

enableNotify

public void enableNotify()
Enable notifications to be sent. Should only be called after a disableNotify() method call, otherwise an exception will be thrown.
Throws:
RuntimeException - if there are an un-balanced number of disable and enable calls.

enableNotify

public void enableNotify(String strProperty)
Enable notifications on the specified property.
Throws:
RuntimeException - if there are an un-balanced number of disable and enable calls.

isEnabled

public boolean isEnabled()
See if notifications are enabled in general.

isEnabled

public boolean isEnabled(String strProperty)
See if notifications are enabled on the specified property.

disableNotify

public void disableNotify()
See Also:
enableNotify()

disableNotify

public void disableNotify(String strProperty)
See Also:
enableNotify(String)

firePropertyChange

public void firePropertyChange(PropertyChangeEvent evt)
Fire if property is enabled.
See Also:
isEnabled(), isEnabled(String)

firePropertyChange

public void firePropertyChange(String str,
                               boolean oldVal,
                               boolean newVal)
Convenience method, see firePropertyChange(PropertyChangeEvent)

firePropertyChange

public void firePropertyChange(String str,
                               int oldVal,
                               int newVal)
Convenience method, see firePropertyChange(PropertyChangeEvent)

firePropertyChange

public void firePropertyChange(String str,
                               Object oldVal,
                               Object newVal)
Convenience method, see firePropertyChange(PropertyChangeEvent)

fireVetoableChange

public void fireVetoableChange(PropertyChangeEvent evt)
                        throws PropertyVetoException
Fire if property is enabled.
See Also:
isEnabled(), isEnabled(String)

fireVetoableChange

public void fireVetoableChange(String str,
                               boolean oldVal,
                               boolean newVal)
                        throws PropertyVetoException
Convenience method, see fireVetoableChange(PropertyChangeEvent)

fireVetoableChange

public void fireVetoableChange(String str,
                               int oldVal,
                               int newVal)
                        throws PropertyVetoException
Convenience method, see fireVetoableChange(PropertyChangeEvent)

fireVetoableChange

public void fireVetoableChange(String str,
                               Object oldVal,
                               Object newVal)
                        throws PropertyVetoException
Convenience method, see fireVetoableChange(PropertyChangeEvent)

getPropertyNames

public Iterator getPropertyNames()
Returns:
an iterator on String objects.

getProperty

public Object getProperty(String strPropertyName)
Get a reference to a property.
Returns:
The property value, or null if it doesn't exist (or if its value is null). Remember that you get a reference to the stored value.

setProperty

public void setProperty(String strPropertyName,
                        Object newVal)
Set a property. Use for simple, bound, and constrained properties.

If setSpecifiedOnly(boolean) is set to false (which it is by default), then a property schema will be created. The type of this new schema is normally PropertyConstants.PROPERTY_SIMPLE unless another one is specified by setDefaultPropertyType(int).


removeProperty

public Object removeProperty(String strPropertyName)
Remove a property. Does nothing if it doesn't exist.

getIndexedProperty

public List getIndexedProperty(String strPropertyName)
Get all of an indexed property.

getIndexedProperty

public Object getIndexedProperty(String strPropertyName,
                                 int index)
Get an indexed property at the specified index.
Returns:
The property value, or null if it doesn't exist (or if its value is null). Remember that you get a reference to the stored value.
Throws:
IndexOutOfBoundsException - if out of bounds.

setIndexedProperty

public void setIndexedProperty(String strPropertyName,
                               int index,
                               Object newVal)
Set a value in the specified indexed property.
Throws:
IndexOutOfBoundsException - if out of bounds.

addIndexedProperty

public void addIndexedProperty(String strPropertyName,
                               Object newVal)
Add a value to the back of the specified indexed property.

If setSpecifiedOnly(boolean) is set to false (which it is by default), then an indexed property schema will be created.


removeIndexedProperty

public Object removeIndexedProperty(String strPropertyName,
                                    int index)
Remove a value from the specified indexed property.
Throws:
IndexOutOfBoundsException - if out of bounds.

removeIndexedProperty

public List removeIndexedProperty(String strPropertyName)
Remove an indexed property entirely.

clearIndexedProperty

public void clearIndexedProperty(String strPropertyName)
Clear out all of the values from the specified indexed property.

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)
Add a listener on a bound property. Why Javasoft didn't call it addBoundPropertiesListener() is beyond me...

addPropertyChangeListener

public void addPropertyChangeListener(String str,
                                      PropertyChangeListener l)
Add a listener on a bound property.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)
Remove a listener on a bound property.

removePropertyChangeListener

public void removePropertyChangeListener(String str,
                                         PropertyChangeListener l)
Remove a listener on a bound property.

addVetoableChangeListener

public void addVetoableChangeListener(VetoableChangeListener l)
Add a listener on a constrained property. Why Javasoft didn't call it addConstrainedPropertiesListener() is beyond me...

addVetoableChangeListener

public void addVetoableChangeListener(String str,
                                      VetoableChangeListener l)
Add a listener on a constrained property.

removeVetoableChangeListener

public void removeVetoableChangeListener(VetoableChangeListener l)
Remove a listener on a constrained property.

removeVetoableChangeListener

public void removeVetoableChangeListener(String str,
                                         VetoableChangeListener l)
Remove a listener on a constrained property.

toString

public String toString()
Print out schema and properties.
Overrides:
toString in class Object

Copyright Information