org.apache.tapestry.binding
Class AbstractBinding

java.lang.Object
  extended by org.apache.tapestry.binding.AbstractBinding
All Implemented Interfaces:
IBinding, ILocatable
Direct Known Subclasses:
ExpressionBinding, FieldBinding, ListenerBinding, StaticBinding, StringBinding

public abstract class AbstractBinding
extends Object
implements IBinding

Base class for IBinding implementations.

Version:
$Id: AbstractBinding.java 243791 2004-02-19 17:38:13Z hlship $
Author:
Howard Lewis Ship

Constructor Summary
protected AbstractBinding(ILocation location)
           
 
Method Summary
protected  BindingException createReadOnlyBindingException(IBinding binding)
           
 boolean getBoolean()
          Cooerces the raw value into a true or false, according to the rules set by Tapestry.evaluateBoolean(Object).
 double getDouble()
          Gets the value of the Binding using IBinding.getObject() and coerces it to a double.
 int getInt()
          Gets the value of the Binding using IBinding.getObject() and coerces it to an int.
 ILocation getLocation()
          Returns the location from which this object orginates, or null if not known.
 Object getObject(String parameterName, Class type)
          Returns the value for the binding after performing some basic checks.
 String getString()
          Gets the value for the binding.
 boolean isInvariant()
          Default implementation: returns true.
 boolean isWrapper(Class primitiveType, Class subjectClass)
           
 void setBoolean(boolean value)
          Constructs a Boolean and invokes IBinding.setObject(Object).
 void setDouble(double value)
          Constructs an Double and invokes IBinding.setObject(Object).
 void setInt(int value)
          Constructs an Integer and invokes IBinding.setObject(Object).
 void setObject(Object value)
          Updates the value of the binding, if possible.
 void setString(String value)
          Invokes IBinding.setObject(Object).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.tapestry.IBinding
getObject
 

Constructor Detail

AbstractBinding

protected AbstractBinding(ILocation location)
Since:
3.0
Method Detail

getLocation

public ILocation getLocation()
Description copied from interface: ILocatable
Returns the location from which this object orginates, or null if not known.

Specified by:
getLocation in interface ILocatable

getBoolean

public boolean getBoolean()
Cooerces the raw value into a true or false, according to the rules set by Tapestry.evaluateBoolean(Object).

Specified by:
getBoolean in interface IBinding
See Also:
Tapestry.evaluateBoolean(Object)

getInt

public int getInt()
Description copied from interface: IBinding
Gets the value of the Binding using IBinding.getObject() and coerces it to an int. Strings will be parsed, and other java.lang.Number classes will have intValue() invoked.

Specified by:
getInt in interface IBinding

getDouble

public double getDouble()
Description copied from interface: IBinding
Gets the value of the Binding using IBinding.getObject() and coerces it to a double. Strings will be parsed, and other java.lang.Number classes will have doubleValue() invoked.

Specified by:
getDouble in interface IBinding

getString

public String getString()
Gets the value for the binding. If null, returns null, otherwise, returns the String (toString()) version of the value.

Specified by:
getString in interface IBinding

setBoolean

public void setBoolean(boolean value)
Description copied from interface: IBinding
Constructs a Boolean and invokes IBinding.setObject(Object).

Specified by:
setBoolean in interface IBinding
Throws:
BindingException - always.

setInt

public void setInt(int value)
Description copied from interface: IBinding
Constructs an Integer and invokes IBinding.setObject(Object).

Specified by:
setInt in interface IBinding
Throws:
BindingException - always.

setDouble

public void setDouble(double value)
Description copied from interface: IBinding
Constructs an Double and invokes IBinding.setObject(Object).

Specified by:
setDouble in interface IBinding
Throws:
BindingException - always.

setString

public void setString(String value)
Description copied from interface: IBinding
Invokes IBinding.setObject(Object).

Specified by:
setString in interface IBinding
Throws:
BindingException - always.

setObject

public void setObject(Object value)
Description copied from interface: IBinding
Updates the value of the binding, if possible.

Specified by:
setObject in interface IBinding
Throws:
BindingException - always.

isInvariant

public boolean isInvariant()
Default implementation: returns true.

Specified by:
isInvariant in interface IBinding
Since:
2.0.3

getObject

public Object getObject(String parameterName,
                        Class type)
Description copied from interface: IBinding
Returns the value for the binding after performing some basic checks.

Specified by:
getObject in interface IBinding
Parameters:
parameterName - the name of the parameter (used to build the message if an exception is thrown).
type - if not null, the value must be assignable to the specific class

isWrapper

public boolean isWrapper(Class primitiveType,
                         Class subjectClass)

createReadOnlyBindingException

protected BindingException createReadOnlyBindingException(IBinding binding)
Since:
3.0