Package jsl.utilities
Class DataObservableArray
- java.lang.Object
-
- jsl.utilities.DataObservable
-
- jsl.utilities.IterativeDataObservable
-
- jsl.utilities.DataObservableArray
-
- All Implemented Interfaces:
ObservableIfc
,GetNameIfc
,GetValueIfc
,IdentityIfc
,PreviousValueIfc
public class DataObservableArray extends IterativeDataObservable
-
-
Field Summary
Fields Modifier and Type Field Description protected int
myCurrentIndex
protected double[]
myValues
-
Fields inherited from class jsl.utilities.IterativeDataObservable
END_SOURCE, myEndSourceFlag, RESET
-
Fields inherited from class jsl.utilities.DataObservable
myId, myIdCounter_, myName, NEW_VALUE
-
-
Constructor Summary
Constructors Constructor Description DataObservableArray(double[] values)
DataObservableArray(double[] values, int n, java.lang.String name)
DataObservableArray(double[] values, java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getValue(int i)
Returns the value at index i zero indexedboolean
hasNext()
Indicates to clients whether there is another value after the current value for the data sourcedouble
next()
Advances to the next value and returns it.void
reset()
This method should reset the IterativeDataSource so that it is positioned just prior to the 1st value to be returned via the use of the next() method Implementers should ensure that observers are notified of the reset and that the end of source indicator correctly reflects the resetprotected void
setValues(double[] values, int n)
int
size()
The size of the arrayjava.lang.String
toString()
-
Methods inherited from class jsl.utilities.IterativeDataObservable
getEndSourceFlag
-
Methods inherited from class jsl.utilities.DataObservable
addObserver, checkObserverState, contains, countObservers, deleteObserver, deleteObservers, getId, getName, getObserverState, getPreviousObserverState, getPreviousValue, getValue, notifyObservers, notifyObservers, setId, setName, setObserverState, setValue
-
-
-
-
Constructor Detail
-
DataObservableArray
public DataObservableArray(double[] values)
- Parameters:
values
-
-
DataObservableArray
public DataObservableArray(double[] values, java.lang.String name)
- Parameters:
values
-name
-
-
DataObservableArray
public DataObservableArray(double[] values, int n, java.lang.String name)
- Parameters:
values
-n
-name
-
-
-
Method Detail
-
hasNext
public boolean hasNext()
Description copied from class:IterativeDataObservable
Indicates to clients whether there is another value after the current value for the data source- Specified by:
hasNext
in classIterativeDataObservable
- Returns:
-
next
public double next()
Description copied from class:IterativeDataObservable
Advances to the next value and returns it. Implementers must use setValue(double value) to properly set the current value. getValue() should then return this current value until advanced again Should throw a NoSuchElementException if there is no next value- Specified by:
next
in classIterativeDataObservable
- Returns:
-
reset
public void reset()
Description copied from class:IterativeDataObservable
This method should reset the IterativeDataSource so that it is positioned just prior to the 1st value to be returned via the use of the next() method Implementers should ensure that observers are notified of the reset and that the end of source indicator correctly reflects the reset- Specified by:
reset
in classIterativeDataObservable
-
size
public int size()
The size of the array- Returns:
-
getValue
public double getValue(int i)
Returns the value at index i zero indexed- Parameters:
i
-- Returns:
-
setValues
protected void setValues(double[] values, int n)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-