org.shapelogic.streams
Class NamedNumberedStreamLazySetup<E>

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

public class NamedNumberedStreamLazySetup<E>
extends java.lang.Object
implements NumberedStream<E>, SetupFlagged

Get a Named Stream out of the context.
With lazy setup, so the input stream is only found when you start to use the values in the stream.

Author:
Sami Badawi

Field Summary
protected  NumberedStream<E> _inputStream
           
protected  java.lang.String _name
           
protected  boolean _setup
           
 
Constructor Summary
NamedNumberedStreamLazySetup(java.lang.String name)
           
NamedNumberedStreamLazySetup(java.lang.String name, 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.
 int getMaxLast()
          Set a max value for last possible element.
 java.lang.String getName()
          Not sure if Name is the best choice.
 E getValue()
          Starts a lazy calculation.
 boolean hasNext()
           
 boolean isDirty()
          When dirty is false that means that the calculated value can be used
 boolean isSetup()
           
 E next()
           
 void remove()
           
 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

_name

protected java.lang.String _name

_inputStream

protected NumberedStream<E> _inputStream

_setup

protected boolean _setup
Constructor Detail

NamedNumberedStreamLazySetup

public NamedNumberedStreamLazySetup(java.lang.String name,
                                    int maxLast)

NamedNumberedStreamLazySetup

public NamedNumberedStreamLazySetup(java.lang.String name)
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>
Specified by:
setup in interface SetupFlagged

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>

isSetup

public boolean isSetup()
Specified by:
isSetup in interface SetupFlagged

getName

public java.lang.String getName()
Not sure if Name is the best choice.



Copyright © 2008. All Rights Reserved.