net.wotonomy.web
Class WOAssociation

java.lang.Object
  extended by net.wotonomy.web.WOAssociation
All Implemented Interfaces:
java.io.Serializable

public class WOAssociation
extends java.lang.Object
implements java.io.Serializable

A pure java implementation of WOAssociation.

A WOAssociation represents the mapping of a property on a WOComponent to a property on a WOAssociation. For example:

MyAssociation: WOString { value = currentCustomer.location.city };

This example represents a WOAssociation between the value field on a WOString element and the city property of the location property of the currentCustomer property of a WOComponent.

To resolve values, a property accessor method will be used in preference to a public field, if both exist. Any null value in the path will produce null.

A mapping represented in quotation marks: { value = "This is a test." } is considered a constant value.

Version:
$Revision: 893 $
Author:
michael@mpowers.net, $Author: cgruber $
See Also:
Serialized Form

Field Summary
protected  java.lang.String path
           
protected  java.lang.Object value
           
 
Constructor Summary
protected WOAssociation()
          The default constructor.
 
Method Summary
static WOAssociation associationWithKeyPath(java.lang.String aString)
          Creates a WOAssociation that maps to the specified key path.
static WOAssociation associationWithValue(java.lang.Object anObject)
          Creates a WOAssociation that maps to a constant value.
 boolean isValueConstant()
          Returns true if this association is constant and therefore read-only.
 boolean isValueSettable()
          Returns true if this association is writable; that is, returns true if this association is not constant.
 void setValue(java.lang.Object aValue, WOComponent aComponent)
          Sets the property in the specified component to the specified value.
 java.lang.String toString()
          For debugging purposes.
 java.lang.Object valueInComponent(WOComponent aComponent)
          Returns the value for this association's key path in the specified component, or null if any value in the path is null or if the key path is null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected java.lang.Object value

path

protected java.lang.String path
Constructor Detail

WOAssociation

protected WOAssociation()
The default constructor. The static factory methods should be used to create instances of WOAssociation.

Method Detail

associationWithValue

public static WOAssociation associationWithValue(java.lang.Object anObject)
Creates a WOAssociation that maps to a constant value.


associationWithKeyPath

public static WOAssociation associationWithKeyPath(java.lang.String aString)
Creates a WOAssociation that maps to the specified key path. If the path is null, the association will map to null. Throws an exception if the property cannot be resolved.


valueInComponent

public java.lang.Object valueInComponent(WOComponent aComponent)
Returns the value for this association's key path in the specified component, or null if any value in the path is null or if the key path is null.


setValue

public void setValue(java.lang.Object aValue,
                     WOComponent aComponent)
Sets the property in the specified component to the specified value. Throws an exception if the property cannot be resolved.


isValueSettable

public boolean isValueSettable()
Returns true if this association is writable; that is, returns true if this association is not constant.


isValueConstant

public boolean isValueConstant()
Returns true if this association is constant and therefore read-only.


toString

public java.lang.String toString()
For debugging purposes.

Overrides:
toString in class java.lang.Object


Copyright © 2006 null. All Rights Reserved.