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 intmyCurrentIndexprotected 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 doublegetValue(int i)Returns the value at index i zero indexedbooleanhasNext()Indicates to clients whether there is another value after the current value for the data sourcedoublenext()Advances to the next value and returns it.voidreset()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 voidsetValues(double[] values, int n)intsize()The size of the arrayjava.lang.StringtoString()-
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:IterativeDataObservableIndicates to clients whether there is another value after the current value for the data source- Specified by:
hasNextin classIterativeDataObservable- Returns:
-
next
public double next()
Description copied from class:IterativeDataObservableAdvances 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:
nextin classIterativeDataObservable- Returns:
-
reset
public void reset()
Description copied from class:IterativeDataObservableThis 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:
resetin 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:
toStringin classjava.lang.Object
-
-