Interface NumberExpression
- All Superinterfaces:
Observable,ObservableNumberValue,ObservableValue<Number>
- All Known Subinterfaces:
NumberBinding
- All Known Implementing Classes:
DoubleBinding,DoubleExpression,DoubleProperty,DoublePropertyBase,IntegerBinding,IntegerExpression,IntegerProperty,IntegerPropertyBase,LongBinding,LongExpression,LongProperty,LongPropertyBase,NumberExpressionBase,ReadOnlyDoubleProperty,ReadOnlyIntegerProperty,ReadOnlyIntegerPropertyBase,ReadOnlyLongProperty,SimpleDoubleProperty,SimpleIntegerProperty,SimpleLongProperty,StyleableIntegerProperty
NumberExpression is a
ObservableNumberValue plus additional convenience
methods to generate bindings in a fluent style.
This API allows to mix types when defining arithmetic operations. The type of the result is defined by the same rules as in the Java Language.
- If one of the operands is a double, the result is a double.
- If not and one of the operands is a float, the result is a float.
- If not and one of the operands is a long, the result is a long.
- The result is an integer otherwise.
To be able to deal with an unspecified return type, two interfaces
NumberExpression and its counterpart
NumberBinding were introduced. That means if the
return type is specified as NumberBinding, the method will either
return a DoubleBinding,
FloatBinding,
LongBinding or
IntegerBinding, depending on the types of the
operands.
The API tries to do its best in determining the correct return type, e.g.
combining a ObservableNumberValue with a primitive
double will always result in a DoubleBinding. In
cases where the return type is not known by the API, it is the responsibility
of the developer to call the correct getter (ObservableNumberValue.intValue() etc.). If
the internal representation does not match the type of the getter, a standard
cast is done.
- Since:
- JavaFX 2.0
-
Method Summary
Methods inherited from interface javafx.beans.Observable
addListener, removeListenerMethods inherited from interface javafx.beans.value.ObservableNumberValue
doubleValue, floatValue, intValue, longValueMethods inherited from interface javafx.beans.value.ObservableValue
addListener, getValue, removeListener
-
Method Details
-
asString
StringBinding asString()Creates aStringBindingthat holds the value of theNumberExpressionturned into aString. If the value of thisNumberExpressionchanges, the value of theStringBindingwill be updated automatically.The conversion is done without any formatting applied.
- Returns:
- the new
StringBinding
-