|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.shapelogic.streams.BaseCommonStream<E> org.shapelogic.streams.BaseListCommonStream<E>
public abstract class BaseListCommonStream<E>
Implementation of ListStream.
Close to
1: a lazy stream.
2: a UNIX pipe.
This is close to org.apache.commons.collections.list.LazyList,
but that takes a factory to calculate next element, and that works badly here.
How should a step work?
Normally call the hasNext, in order for this to work it would have to do the
calculation.
So _current should be the last element that has been returned.
So when you call hasNext it will add that element to the list.
When you call next it will bump the counter up one element if goes too high
then do the calculation.
At the end it will get to a point where the calculation fails.
At that point last will be set to the current element.
I will ignore synchronization to begin with.
Field Summary | |
---|---|
protected java.util.List<E> |
_list
|
Fields inherited from class org.shapelogic.streams.BaseCommonStream |
---|
_context, _current, _dirty, _last, _maxLast, _name, _nullLegalValue, _parentContext, _query, _value |
Constructor Summary | |
---|---|
BaseListCommonStream()
|
Method Summary | |
---|---|
protected boolean |
calcAddNext()
Try to calculate one more, independent of the _current. |
E |
get(int inputIndex)
Get next element without advancing _current. |
int |
getCurrentSize()
|
java.util.List<E> |
getList()
Get underlying list. |
boolean |
hasNext()
|
boolean |
hasNextBase()
|
abstract E |
invokeIndex(int index)
Calculate the value at an index. |
boolean |
isCached()
If there is a list that contains all the results. |
boolean |
isRandomAccess()
If you can calculate 1 element independent of other elements. |
java.util.Iterator<E> |
iterator()
|
E |
next()
Get next element and advance _current. |
protected void |
setLastFromInput()
|
void |
setList(java.util.List<E> list)
Get underlying list. |
Methods inherited from class org.shapelogic.streams.BaseCommonStream |
---|
getContext, getInContext, getIndex, getLast, getMaxLast, getName, getParentContext, getValue, isDeterministic, isDirty, isNullLegalValue, remove, setMaxLast, setNullLegalValue, setup |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.shapelogic.streams.NumberedStream |
---|
getIndex, getLast, getMaxLast, setMaxLast |
Methods inherited from interface org.shapelogic.calculation.LazyCalc |
---|
isDirty, setup |
Methods inherited from interface org.shapelogic.calculation.CalcValue |
---|
getValue |
Methods inherited from interface java.util.Iterator |
---|
remove |
Field Detail |
---|
protected java.util.List<E> _list
Constructor Detail |
---|
public BaseListCommonStream()
Method Detail |
---|
public abstract E invokeIndex(int index)
invokeIndex
in class BaseCommonStream<E>
public boolean hasNext()
hasNext
in interface java.util.Iterator<E>
protected boolean calcAddNext()
calcAddNext
in class BaseCommonStream<E>
public boolean hasNextBase()
protected void setLastFromInput()
setLastFromInput
in class BaseCommonStream<E>
public E next()
next
in interface java.util.Iterator<E>
public E get(int inputIndex)
get
in interface NumberedStream<E>
public boolean isRandomAccess()
StreamProperties
isRandomAccess
in interface StreamProperties
public boolean isCached()
isCached
in interface StreamProperties
public int getCurrentSize()
public java.util.List<E> getList()
ListStream
getList
in interface ListStream<E>
public void setList(java.util.List<E> list)
ListStream
setList
in interface ListStream<E>
public java.util.Iterator<E> iterator()
iterator
in interface java.lang.Iterable<E>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |