org.progeeks.util.beans
Class PropertyPath

java.lang.Object
  extended by org.progeeks.util.beans.PropertyPath

public class PropertyPath
extends java.lang.Object

Encapsulates the path from an object down a set of property references. If the object is a StandardBean implementation then change listeners are registered to detect changes in the path and the representive final property is changed accordingly with events fired as needed. The property path is defined by a simple field expression language where property name references are separated by '.' characters. So, foo.bar.baz is the equivalent of: obj.getFoo().getBar().getBaz()

Version:
$Revision: 1.10 $
Author:
Paul Speed

Nested Class Summary
protected static interface PropertyPath.PathElement
          Represents a single element from a parsed path string.
protected static interface PropertyPath.PathReference
          Generic worker object interface for PathElements.
protected static class PropertyPath.PropertyElement
          Represents a single field element refering to a bean property.
protected  class PropertyPath.PropertyReference
          Object used to supply the field information for a given object.
 
Constructor Summary
PropertyPath(java.lang.String pathExpression)
           
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a listener that will be notified whenever this path changes.
protected  PropertyPath.PathReference createReference(PropertyPath.PathElement element, java.lang.Object obj)
          Returns the appropriate path reference for the specified parsed element and object value.
protected  void createReferences(java.lang.Object obj, int start)
          Constructs references for the specified entry on, releasing any old listeners for the path that is being replaced.
 java.lang.String getPathExpression()
          Returns the path expression string that defines this path.
 java.lang.Object getProperty()
          Returns the value of the property at the end of the path.
protected  void parsePath(java.lang.String pathExpression)
           
protected  void referenceChanged(PropertyPath.PathReference reference)
          Called when the specified PathReference has detected that its value has changed.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes a listener that was previously registered
 void setObject(java.lang.Object obj)
          Sets the object from which this path starts.
 void setProperty(java.lang.Object value)
          Sets the value of the property at the end of the path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyPath

public PropertyPath(java.lang.String pathExpression)
Method Detail

setObject

public void setObject(java.lang.Object obj)
Sets the object from which this path starts.


getProperty

public java.lang.Object getProperty()
Returns the value of the property at the end of the path.


setProperty

public void setProperty(java.lang.Object value)
Sets the value of the property at the end of the path.


getPathExpression

public java.lang.String getPathExpression()
Returns the path expression string that defines this path.


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a listener that will be notified whenever this path changes.


removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a listener that was previously registered


createReference

protected PropertyPath.PathReference createReference(PropertyPath.PathElement element,
                                                     java.lang.Object obj)
Returns the appropriate path reference for the specified parsed element and object value.


createReferences

protected void createReferences(java.lang.Object obj,
                                int start)
Constructs references for the specified entry on, releasing any old listeners for the path that is being replaced. So, if a property change happens in index 4, then you'd call this method with start = 5 and pass 4's value in as the object.


referenceChanged

protected void referenceChanged(PropertyPath.PathReference reference)
Called when the specified PathReference has detected that its value has changed.


parsePath

protected void parsePath(java.lang.String pathExpression)


Copyright © 2002-2003 Paul Speed. All Rights Reserved.