QJCC homepage

biz.chitec.quarterback.gjsa.server
Class BurstMaker

java.lang.Object
  extended bybiz.chitec.quarterback.gjsa.server.BurstMaker
Direct Known Subclasses:
CombinedBurstMaker, FileTransferBurstMaker, IteratorBurstMaker, ListBurstMaker, SyncBurstReceiverDemo.IntegerBurstMaker, VectorBurstMaker

public abstract class BurstMaker
extends java.lang.Object

"Brain" of a burst. BurstMaker objects' getReplyPart or getCompleteReply method are called from Burster.run() to obtain a part of a bursted answer. A non-abstract derived object only has to implement getReplyPart. What to do there is up to the implementation. Burster will stop calling BurstMaker as soon as getReplyPart returns less entries in the List as possible.

Version:
$Id: 3251dbe1e51024c9ec246bfb3ee62a2c14e40bf3 $
Author:
Dirk Hillbrecht 1997-2000, chitec/Dirk Hillbrecht 2000. Distributed under the terms of the GNU LGPL.

Nested Class Summary
private  class BurstMaker.BurstMakerIterator
          Implementation of Iterator to loop over the BurstMaker using methods of the Collection framework.
private  class BurstMaker.ElementWiseIterator
          Wrapper around a BurstMakerIterator which allows a truly elementwise access to the burst.
 
Field Summary
protected  boolean loggable
          marker whether this is a loggable burster.
private  int refnr
          reference number of this burst (only for asynchonous bursts).
 
Constructor Summary
BurstMaker()
           
 
Method Summary
 java.util.Iterator burstIterator()
          Returns an iterator over the BurstMaker's content returning 50 elements on each call.
 java.util.Iterator burstIterator(int elementcount)
          Returns an iterator over the BurstMaker's content.
 java.util.Iterator elementIterator()
          Returns an element-wise iterator which uses bursts with 50 elements.
 java.util.Iterator elementIterator(int elementcount)
          Returns an element-wise iterator over the BurstMaker's content.
 java.util.List getCompleteReply()
          computes the complete reply, but at most 400 lines of it.
 java.util.List getCompleteReply(int maxdatacount)
          Computes all reply rows at once, but at most maxdatacount of it.
 int getRefNr()
          returns this bursts reference number.
abstract  java.util.List getReplyPart(int start, int num)
          constructs a part of the answer.
 boolean isLoggable()
          returns whether the answer should be logged
 java.util.Iterator iterator(boolean byelement)
          Returns either a burst-wise or an element-wise iterator with 50 burst elements.
 java.util.Iterator iterator(boolean byelement, int elementcount)
          Returns either a burst-wise or an element-wise iterator on the content of the burst.
abstract  boolean linearContinueable()
          returns whether more data is available.
 void setLoggable(boolean lx)
          Sets the logging flag
 void setRefNr(int rn)
          sets this bursts reference number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

refnr

private int refnr
reference number of this burst (only for asynchonous bursts).


loggable

protected boolean loggable
marker whether this is a loggable burster. This marker can be evaluated by any logging functionality which prints out objects, e.g. a logging facility for a command interface.

Constructor Detail

BurstMaker

public BurstMaker()
Method Detail

setRefNr

public void setRefNr(int rn)
sets this bursts reference number.


getRefNr

public int getRefNr()
returns this bursts reference number.


setLoggable

public void setLoggable(boolean lx)
Sets the logging flag


isLoggable

public boolean isLoggable()
returns whether the answer should be logged


getReplyPart

public abstract java.util.List getReplyPart(int start,
                                            int num)
                                     throws java.sql.SQLException
constructs a part of the answer. This method must be implemented by any actual BurstMaker.

Throws:
java.sql.SQLException

linearContinueable

public abstract boolean linearContinueable()
returns whether more data is available. This method returns true if another getReplyPart() call is possible where start is start+num of the last call.


getCompleteReply

public java.util.List getCompleteReply(int maxdatacount)
                                throws java.sql.SQLException
Computes all reply rows at once, but at most maxdatacount of it. Be careful as this can eat up your memory and arbitrary other item on your desk in case you use a limit too high. It strongly preferred to use the chunk-wise query methods instead.

Parameters:
maxdatacount - The maximum number of returned rows.
Returns:
List The returned data all in once
Throws:
java.sql.SQLException

getCompleteReply

public java.util.List getCompleteReply()
                                throws java.sql.SQLException
computes the complete reply, but at most 400 lines of it.

Throws:
java.sql.SQLException

burstIterator

public java.util.Iterator burstIterator(int elementcount)
Returns an iterator over the BurstMaker's content. Note that you must not use neither getReplyPart() nor getCompleteReply() in case you work with the iterator!

Parameters:
elementcount - Number of elements
Returns:
Iterator returning given number of elements of the burst maker on every call

burstIterator

public java.util.Iterator burstIterator()
Returns an iterator over the BurstMaker's content returning 50 elements on each call. Note that you must not use neither getReplyPart() nor getCompleteReply() in case you work with the iterator!

Returns:
Iterator returning 50 elements of the burst maker on every call

elementIterator

public java.util.Iterator elementIterator(int elementcount)
Returns an element-wise iterator over the BurstMaker's content. This iterator hides the "chunking" of the burst's content. I.e. it truly returns element by element and fills the bursts as they are needed. The elementcount parameter is therefore just for optimizing the underlying burst's behaviour, it has no effect on the actual output of the iterator.

Parameters:
elementcount - Internally used burst size
Returns:
Iterator which returns the burst's result element by element.

elementIterator

public java.util.Iterator elementIterator()
Returns an element-wise iterator which uses bursts with 50 elements.


iterator

public java.util.Iterator iterator(boolean byelement,
                                   int elementcount)
Returns either a burst-wise or an element-wise iterator on the content of the burst. Note that this method does mainly exist to have the usual ".iterator()" method in the API. When working with burst iterators, it is good style to always use either burstIterator() or elementIterator() directly. This method is nothing more than a wrapper around those two.

Parameters:
byelement - Flag whether to return an element- or a burst-wise iterator.
elementcount - Elements in the underlying bursts.
Returns:
Iterator over bursts or elements.

iterator

public java.util.Iterator iterator(boolean byelement)
Returns either a burst-wise or an element-wise iterator with 50 burst elements.


QJCC homepage