public interface Settable extends Nameable
In addition, an attribute class that implements this interface needs to maintain a list of listeners that are informed whenever the value of the attribute changes. It should inform those listeners whenever setExpression() is called.
Among other uses, this interface marks attributes whose value can be set via the value attribute of a MoML property element. For example, if class XXX implements Settable, then the following is valid MoML:
<property name="xxx" class="XXX" value="yyy"/>
This interface also supports annotations that hint to a user interface the level of visibility that an instance should have. The visibility is specified as one of the static instances of the inner class Visibility, currently NONE, EXPERT, FULL, and NOT_EDITABLE NONE indicates that the user should never see the instance, and should not be able to set its value through the user interface. EXPERT means that only expert users should see the instance. FULL means that the instance is always visible, and a user interface should always allow it to be set. NOT_EDITABLE is similar to FULL, except that the value of the expression is visible, but not editable by the user. This is commonly used for feedback from the model.
Modifier and Type | Interface and Description |
---|---|
static class |
Settable.Visibility
Inner class used for the static enumeration of indicators of
visibility.
|
Modifier and Type | Field and Description |
---|---|
static Settable.Visibility |
EXPERT
Indicator that a user interface should make an instance visible
only to experts.
|
static Settable.Visibility |
FULL
Indicator that a user interface should make an instance visible.
|
static Settable.Visibility |
NONE
Indicator that a user interface should not make an instance visible.
|
static Settable.Visibility |
NOT_EDITABLE
Indicator that a user interface should make an instance
visible, but not allow editing of the variable.
|
Modifier and Type | Method and Description |
---|---|
void |
addValueListener(ValueListener listener)
Add a listener to be notified when the value of this settable
object changes.
|
java.lang.String |
getDefaultExpression()
Return the default value of this attribute, if there is
one, or null if there is none.
|
java.lang.String |
getDisplayName()
Return a name to present to the user.
|
java.lang.String |
getExpression()
Get the expression of the attribute that has been set by setExpression(),
or null if there is none.
|
java.lang.String |
getValueAsString()
Get the value of the attribute, which is the evaluated expression.
|
Settable.Visibility |
getVisibility()
Get the visibility of this Settable, as set by setVisibility().
|
void |
removeValueListener(ValueListener listener)
Remove a listener from the list of listeners that are
notified when the value of this variable changes.
|
void |
setExpression(java.lang.String expression)
Set the value of the attribute by giving some expression.
|
void |
setVisibility(Settable.Visibility visibility)
Set the visibility of this Settable.
|
java.util.Collection |
validate()
Check the validity of the expression set in setExpression().
|
description, getContainer, getFullName, getName, getName, setName
static final Settable.Visibility NONE
static final Settable.Visibility EXPERT
static final Settable.Visibility FULL
static final Settable.Visibility NOT_EDITABLE
void addValueListener(ValueListener listener)
listener
- The listener to add.removeValueListener(ValueListener)
java.lang.String getDefaultExpression()
java.lang.String getDisplayName()
getDisplayName
in interface Nameable
java.lang.String getExpression()
setExpression(String)
java.lang.String getValueAsString()
getExpression()
Settable.Visibility getVisibility()
setVisibility(Settable.Visibility)
void removeValueListener(ValueListener listener)
listener
- The listener to remove.addValueListener(ValueListener)
void setExpression(java.lang.String expression) throws IllegalActionException
expression
- The value of the attribute.IllegalActionException
- If the expression is invalid.getExpression()
void setVisibility(Settable.Visibility visibility)
visibility
- The visibility of this Settable.getVisibility()
java.util.Collection validate() throws IllegalActionException
IllegalActionException
- If the expression is not valid, or
its value is not acceptable to the container or the listeners.