Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.sapia.util.cursor;

This class specifies cursor behavior. A Cursor is a sequence of Batch instances. A cursor instance creates batches through a CursorFeed.

Author(s):
Yanick Duchesne
Copyright:
Copyright &.169; 2002-2004 Sapia Open Source Software . All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site
See also:
Batch
CursorFeed
CursorFactory
 
 public interface Cursor {

  
Returns the number of items in this cursor. Note that the returned count should not be necessarily relied upon: a cursor might be fed asynchronously, and thus the number of items may not be constant over time, up to a certain limit.

Returns:
the number of items in this cursor (more precisely: the sum of the number of items that all batches in this instance hold).
 
   public int getItemCount();

  

Returns:
the number of Batch instances held with this instance.
See also:
getItemCount()
 
   public int getBatchCount();
  
  

Returns:
true if this instance has a batch pending.
 
   public boolean hasNextBatch();

  

Returns:
the next Batch
 
   public Batch nextBatch();

  

Returns:
true if this instance has a "previous" batch pending.
 
   public boolean hasPreviousBatch();

  

Returns:
the previous Batch
 
   public Batch previousBatch();
  

  

Returns:
true if this cursor has a "current" batch.
 
   public boolean hasCurrentBatch();
  
  
Returns the "current" batch (or, rather, the last batch that was fetched).

Returns:
the Batch that is currently pointed to.
 
   public Batch currentBatch();  

  

Returns:
the batch size with which this instance was configured.
 
   public int getBatchSize();
  
  

Parameters:
size the maximum size of the batches that this instance will return.
 
   public void setBatchSize(int size);

  
Positions this instance at the beginning of the first batch.

Returns:
this instance.
 
   public Cursor toFirst();

  
Position this instance at the beginning of the last batch.

Returns:
this instance.
  public Cursor toLast();
  
  

Returns:
the current position of the cursor, in terms of the batch it currently points to.
  public int getPos();
  
  
positions this cursor's internal index to the beginning (such that thereafter calling nextBatch() will return this instance's first batch.
  public void reset();  
  
  

Returns:
the current position of the cursor, in terms of the individual items it contains.
  public int getAbsolutePos();
  
  

Parameters:
pos the position to which this instance should be set, in terms of the individual items it contains.
  public void setAbsolutePos(int pos);
  
  

Returns:
true if this instance's current position corresponds to its first item.
  public boolean isStart();
  
  

Returns:
true if this instance's current position corresponds to its last item.
  
  public boolean isEnd();
  
  
Returns the object at the given position.

Parameters:
pos a position.
Returns:
the object at the given position.
  public Object getItemAt(int pos);
  
  
Removes the item at the given position and returns it.

Parameters:
pos
Returns:
the object at the given position.
  public Object removeItemAt(int pos);

  
This non-blocking method can be polled to inquire about the number of pending objects in this instance's underlying CursorFeed.

This method can be used in cases where an hasNext() call has returned false, and where the underlying feed is asynchronously filled with data. In such cases, the false hasNext() call may reflect a temporary situation. This method conveniently allows insuring that indeed no data is pending.

Returns:
the number of pending object in the underlying feed.
See also:
CursorFeed.available()
  public int available();
  
  
Client applications should call this method when they are finished with this instance. This allows all resources to be released. In particular, this allows sparing processing resources in cases where CursorFeeds have an asynchronous behavior.

  public void close();
New to GrepCode? Check out our FAQ X