org.shapelogic.streams
Class NamedListStream<E>

java.lang.Object
  extended by org.shapelogic.streams.NamedListStream<E>
All Implemented Interfaces:
java.lang.Iterable<E>, java.util.Iterator<E>, CalcValue<E>, LazyCalc<E>, ListStream<E>, NumberedStream<E>, Stream<E>

public class NamedListStream<E>
extends java.lang.Object
implements ListStream<E>

Get a Named Stream out of the context.

Author:
Sami Badawi

Field Summary
protected  ListStream<E> _inputStream
           
protected  java.lang.String _key
           
 
Constructor Summary
NamedListStream(java.lang.String key)
           
NamedListStream(java.lang.String key, int maxLast)
           
 
Method Summary
 E get(int input)
          Get the calculate value for index based on the previous stream So it just calls invoke(getInputStream().get(index), index)
 int getIndex()
          Index of last successfully processed element.
 int getLast()
          Last possible element.
 java.util.List<E> getList()
          Get underlying list.
 int getMaxLast()
          Set a max value for last possible element.
 E getValue()
          Starts a lazy calculation.
 boolean hasNext()
           
 boolean isDirty()
          When dirty is false that means that the calculated value can be used
 java.util.Iterator<E> iterator()
           
 E next()
           
 void remove()
           
 void setList(java.util.List<E> list)
          Get underlying list.
 void setMaxLast(int maxLast)
          Set a max value for last possible element.
 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
 

Field Detail

_key

protected java.lang.String _key

_inputStream

protected ListStream<E> _inputStream
Constructor Detail

NamedListStream

public NamedListStream(java.lang.String key,
                       int maxLast)

NamedListStream

public NamedListStream(java.lang.String key)
Method Detail

get

public E get(int input)
Description copied from interface: NumberedStream
Get the calculate value for index based on the previous stream So it just calls invoke(getInputStream().get(index), index)

Specified by:
get in interface NumberedStream<E>
Returns:

getIndex

public int getIndex()
Description copied from interface: NumberedStream
Index of last successfully processed element.

Specified by:
getIndex in interface NumberedStream<E>

getLast

public int getLast()
Description copied from interface: NumberedStream
Last possible element.

Specified by:
getLast in interface NumberedStream<E>

getMaxLast

public int getMaxLast()
Description copied from interface: NumberedStream
Set a max value for last possible element.

Specified by:
getMaxLast in interface NumberedStream<E>

setMaxLast

public void setMaxLast(int maxLast)
Description copied from interface: NumberedStream
Set a max value for last possible element.

Specified by:
setMaxLast in interface NumberedStream<E>

isDirty

public boolean isDirty()
Description copied from interface: LazyCalc
When dirty is false that means that the calculated value can be used

Specified by:
isDirty in interface LazyCalc<E>

setup

public void setup()
Description copied from interface: LazyCalc
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.

Specified by:
setup in interface LazyCalc<E>

getValue

public E getValue()
Description copied from interface: CalcValue
Starts a lazy calculation. If dirty do calc() else return cached value. This should maybe be moved up in the hierarchy

Specified by:
getValue in interface CalcValue<E>

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<E>

next

public E next()
Specified by:
next in interface java.util.Iterator<E>

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<E>

getList

public java.util.List<E> getList()
Description copied from interface: ListStream
Get underlying list.

Specified by:
getList in interface ListStream<E>

setList

public void setList(java.util.List<E> list)
Description copied from interface: ListStream
Get underlying list.

Specified by:
setList in interface ListStream<E>

iterator

public java.util.Iterator<E> iterator()
Specified by:
iterator in interface java.lang.Iterable<E>


Copyright © 2008. All Rights Reserved.