|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.shapelogic.streams.BaseCommonStream<E>
public abstract class BaseCommonStream<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.
I think that there could be a _nextElement that is calculated when hasNext()
is called. When next is called check if this exist and return it. After that
set it to null.
Field Summary | |
---|---|
protected java.util.Map |
_context
|
protected int |
_current
The last value that was calculated and looked at So if you want to see that again use this for a lookup |
protected boolean |
_dirty
|
protected int |
_last
Last value that can be calculated. |
protected int |
_maxLast
Highest value that last can take. |
protected java.lang.String |
_name
Does not always exist. |
protected boolean |
_nullLegalValue
|
protected RecursiveContext |
_parentContext
|
protected IQueryCalc |
_query
|
protected E |
_value
|
Constructor Summary | |
---|---|
BaseCommonStream()
|
Method Summary | |
---|---|
protected abstract boolean |
calcAddNext()
Try to calculate one more, independent of the _current. |
java.util.Map |
getContext()
The context if needed. |
java.lang.Object |
getInContext(java.lang.Object key)
|
int |
getIndex()
Index of last successfully processed element. |
int |
getLast()
Last possible element. |
int |
getMaxLast()
Manually set max value for last possible element. |
java.lang.String |
getName()
If a stream has a name. |
RecursiveContext |
getParentContext()
|
E |
getValue()
Starts a lazy calculation. |
abstract E |
invokeIndex(int index)
Calculate the value at an index. |
boolean |
isDeterministic()
Is the result of a calculation deterministic. |
boolean |
isDirty()
When dirty is false that means that the calculated value can be used |
boolean |
isNullLegalValue()
If null is a legal value. |
void |
remove()
|
protected void |
setLastFromInput()
|
void |
setMaxLast(int maxLast)
Set a max value for last possible element. |
void |
setNullLegalValue(boolean nullLegalValue)
|
void |
setup()
Currently not super well define used for 2 purposes: Reset: called from the outside if you want to reuse it init: Called from the inside when calculation start to have everything setup maybe the semantic could work for both? TODO: This should be separated better. |
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 |
---|
get |
Methods inherited from interface java.util.Iterator |
---|
hasNext, next |
Methods inherited from interface org.shapelogic.streams.StreamProperties |
---|
isCached, isRandomAccess |
Field Detail |
---|
protected int _current
protected int _last
protected int _maxLast
protected java.lang.String _name
protected boolean _dirty
protected E _value
protected java.util.Map _context
protected IQueryCalc _query
protected RecursiveContext _parentContext
protected boolean _nullLegalValue
Constructor Detail |
---|
public BaseCommonStream()
Method Detail |
---|
public abstract E invokeIndex(int index)
protected abstract boolean calcAddNext()
protected void setLastFromInput()
public int getLast()
NumberedStream
getLast
in interface NumberedStream<E>
public int getMaxLast()
NumberedStream
getMaxLast
in interface NumberedStream<E>
public void setMaxLast(int maxLast)
setMaxLast
in interface NumberedStream<E>
public boolean isNullLegalValue()
StreamProperties
isNullLegalValue
in interface StreamProperties
public void setNullLegalValue(boolean nullLegalValue)
public int getIndex()
NumberedStream
getIndex
in interface NumberedStream<E>
public java.lang.String getName()
StreamProperties
getName
in interface StreamProperties
public void setup()
LazyCalc
setup
in interface LazyCalc<E>
public java.util.Map getContext()
StreamProperties
getContext
in interface RecursiveContext
getContext
in interface StreamProperties
public RecursiveContext getParentContext()
getParentContext
in interface RecursiveContext
public E getValue()
CalcValue
getValue
in interface CalcValue<E>
public boolean isDeterministic()
StreamProperties
isDeterministic
in interface StreamProperties
public boolean isDirty()
LazyCalc
isDirty
in interface LazyCalc<E>
public void remove()
remove
in interface java.util.Iterator<E>
public java.lang.Object getInContext(java.lang.Object key)
getInContext
in interface ContextGettable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |