public abstract class ValueSupplier
extends java.util.Observable
"update(double value)"
method of an observer to
pass the changed value directly to one other object interested. Using the
direct call allows easy passing of a value to a single observer. No instance
of this ValueSupplier
class is needed using direct passing of
values.ValueSupplier
to publish the information to
interested observers requires you to derive a class and implement the call of
the observer's update(Observable, Object)
method with the
required values. This way of passing values involves more code to be written,
but offer the potential to have multiple observers and change the number of
observers during runtime. These options are not available when using the
simpler version above.notifyStatistics(Object arg)
by Soenke Claassen
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You
may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the License for the specific language governing
permissions and limitations under the License.Constructor and Description |
---|
ValueSupplier(java.lang.String name)
Constructs a simple valuesupplier by giving it a name.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getName()
Returns the name of the named object.
|
java.lang.String |
getQuotedName()
Returns the quoted name of the named object.
|
void |
notifyStatistics(java.lang.Object arg)
Indicates that this ValueSupplier (as an Observable) has changed and
notifies all its observers of this change providing the modified value as
parameter.
|
void |
rename(java.lang.String newName)
Changes the name of the named object.
|
java.lang.String |
toString()
Overrides the java.lang.Object's toString method to return the named
object's name when given as parameter to a method that expects a string
to be passed.
|
abstract double |
value()
When using the Pull-Model or the automatic update function this method
must be overridden by the user in a way that it provides the value (as a
double ) desired. |
public ValueSupplier(java.lang.String name)
public java.lang.String getName()
public java.lang.String getQuotedName()
public void notifyStatistics(java.lang.Object arg)
arg
) to the Observer (thus the
StatisticObject
).arg
- Object : The Object wrapping the value with which the
observers will be updatedpublic void rename(java.lang.String newName)
newName
- java.lang.String : The new name for the named objectpublic java.lang.String toString()
toString
in class java.lang.Object
public abstract double value()
double
) desired.