org.apache.tapestry
Interface IBinding

All Superinterfaces:
ILocatable
All Known Implementing Classes:
AbstractBinding, ExpressionBinding, FieldBinding, ListenerBinding, StaticBinding, StringBinding

public interface IBinding
extends ILocatable

A binding is the mechanism used to provide values for parameters of specific IComponent instances. The component doesn't care where the required value comes from, it simply requires that a value be provided when needed.

Bindings are set inside the containing component's specification. Bindings may be static or dynamic (though that is irrelevant to the component). Components may also use a binding to write a value back through a property to some other object (typically, another component).

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

Method Summary
 boolean getBoolean()
          Invokes getObject(), then coerces the value to a boolean.
 double getDouble()
          Gets the value of the Binding using getObject() and coerces it to a double.
 int getInt()
          Gets the value of the Binding using getObject() and coerces it to an int.
 Object getObject()
          Returns the value of this binding.
 Object getObject(String parameterName, Class type)
          Returns the value for the binding after performing some basic checks.
 String getString()
          Invokes getObject() and converts the result to java.lang.String.
 boolean isInvariant()
          Returns true if the value is invariant (not changing; the same value returned each time).
 void setBoolean(boolean value)
          Constructs a Boolean and invokes setObject(Object).
 void setDouble(double value)
          Constructs an Double and invokes setObject(Object).
 void setInt(int value)
          Constructs an Integer and invokes setObject(Object).
 void setObject(Object value)
          Updates the value of the binding, if possible.
 void setString(String value)
          Invokes setObject(Object).
 
Methods inherited from interface org.apache.tapestry.ILocatable
getLocation
 

Method Detail

getBoolean

boolean getBoolean()
Invokes getObject(), then coerces the value to a boolean. The following rules are used to perform the coercion:

See Also:
Tapestry.evaluateBoolean(Object)

getInt

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

Throws:
ClassCastException - if the binding's value is not of a usable class.
BindingException - if the binding's value is null.

getDouble

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

Throws:
ClassCastException - if the binding's value is not of a usable class.
BindingException - if the binding's value is null.

getString

String getString()
Invokes getObject() and converts the result to java.lang.String.


getObject

Object getObject()
Returns the value of this binding. This is the essential method. Other methods get this value and cast or coerce the value.


getObject

Object getObject(String parameterName,
                 Class type)
Returns the value for the binding after performing some basic checks.

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
Throws:
BindingException - if the value is not assignable to the specified type
Since:
0.2.9

isInvariant

boolean isInvariant()
Returns true if the value is invariant (not changing; the same value returned each time). Static and field bindings are always invariant, and ExpressionBindings may be marked invariant (as an optimization).

Since:
2.0.3

setBoolean

void setBoolean(boolean value)
Constructs a Boolean and invokes setObject(Object).


setInt

void setInt(int value)
Constructs an Integer and invokes setObject(Object).


setDouble

void setDouble(double value)
Constructs an Double and invokes setObject(Object).


setString

void setString(String value)
Invokes setObject(Object).


setObject

void setObject(Object value)
Updates the value of the binding, if possible.

Throws:
BindingException - If the binding is read only.