org.gcube.common
Class OAIResumptionStream

java.lang.Object
  extended by org.gcube.common.OAIResumptionStream

public class OAIResumptionStream
extends Object

This class is used internally by other classes to handle all of the OAI responses which represent a list of values: OAIRecordList, OAIMetadataFormatList, and OAISetList. This is the class that allows the other classes to implement the forward-only cursor and transparently handle resumptionTokens, flow control, and other nuances of the OAI protocol. This is a private, internal class, and it is included for information only.


Constructor Summary
OAIResumptionStream(OAIRepository repo, String u, String v)
          Constructs an OAIResumptionStream object with the given OAIRepository, baseURL, and verb.
OAIResumptionStream(OAIRepository repo, String u, String v, String params)
          Constructs an OAIResumptionStream object with the given OAIRepository, baseURL, verb, and query parameters.
 
Method Summary
 void close()
           
 String getBaseURL()
          Returns the BASE-URL of the query.
 int getCompleteSize()
          Return the complete size of a returned list (if possible).
 int getIndex()
          Return the index of the current record: 0 to CompleteListSize-1
 Node getItem()
          Returns an XML node for the current object in the list.
 String getParams()
          Returns the query string parameters used for the request (minus the verb parameter).
 OAIRepository getRepository()
          Returns the OAIRepository object from which this list was created.
 String getRequestURL()
          Return the requestURL returned by the most recent response
 String getResponseDate()
          Return the responseDate returned by the most recent response
 int getResponseSize()
          Return the number of items contained in the most recent response
 int getResumptionCursor()
          Return the index which starts the most recent response.
 String getResumptionExpirationDate()
          Return the expiration date of the current resumptionToken or an empty string if there is none
 String getVerb()
          The verb parameter used for this request.
 boolean isResponseValid()
          Returns true if the response appears to be valid (well-formed, and if the Validation if Very Strict also valid according to the XML Schemas); if the Validation is Loose and the record is not well-formed, false is returned
 boolean more()
          Returns true if there are more objects which can be returned; else false.
 void moveNext()
          Moves the cursor location to the next object in the list.
 void requery()
          This will reset the entire list to the beginning, redoing the query from scratch.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OAIResumptionStream

public OAIResumptionStream(OAIRepository repo,
                           String u,
                           String v)
                    throws OAIException
Constructs an OAIResumptionStream object with the given OAIRepository, baseURL, and verb.

Throws:
OAIException

OAIResumptionStream

public OAIResumptionStream(OAIRepository repo,
                           String u,
                           String v,
                           String params)
                    throws OAIException
Constructs an OAIResumptionStream object with the given OAIRepository, baseURL, verb, and query parameters.

Throws:
OAIException
Method Detail

getCompleteSize

public int getCompleteSize()
                    throws OAIException
Return the complete size of a returned list (if possible). For OAI 2.0 repositories which return the completeListSize attribute on their resumptionTokens, that value will be used. Otherwise, this value will be -1, meaning unknown. If this is the last chunk of data to be retrieved (there is no resumptionToken) the CompleteListSize can be calculated from the count of all previously retrieved records, plus the size of this chunk, and that value will be returned.

Throws:
OAIException

getResumptionCursor

public int getResumptionCursor()
                        throws OAIException
Return the index which starts the most recent response. For OAI 2.0 repositories which return the cursor attribute on their resumptionTokens, that value will be used. Otherwise, this value will be calculated based on the count of total items returned thus far

Throws:
OAIException

getResumptionExpirationDate

public String getResumptionExpirationDate()
                                   throws OAIException
Return the expiration date of the current resumptionToken or an empty string if there is none

Throws:
OAIException

getIndex

public int getIndex()
             throws OAIException
Return the index of the current record: 0 to CompleteListSize-1

Throws:
OAIException

isResponseValid

public boolean isResponseValid()
Returns true if the response appears to be valid (well-formed, and if the Validation if Very Strict also valid according to the XML Schemas); if the Validation is Loose and the record is not well-formed, false is returned


more

public boolean more()
             throws OAIException
Returns true if there are more objects which can be returned; else false.

Throws:
OAIException

moveNext

public void moveNext()
              throws OAIException
Moves the cursor location to the next object in the list.

Throws:
OAIException

getBaseURL

public String getBaseURL()
                  throws OAIException
Returns the BASE-URL of the query.

Throws:
OAIException

getResponseDate

public String getResponseDate()
                       throws OAIException
Return the responseDate returned by the most recent response

Throws:
OAIException

getRequestURL

public String getRequestURL()
                     throws OAIException
Return the requestURL returned by the most recent response

Throws:
OAIException

getItem

public Node getItem()
             throws OAIException
Returns an XML node for the current object in the list. The type of node returned will depend on the type of request (the verb parameter).

Throws:
OAIException

getParams

public String getParams()
                 throws OAIException
Returns the query string parameters used for the request (minus the verb parameter).

Throws:
OAIException

getRepository

public OAIRepository getRepository()
Returns the OAIRepository object from which this list was created.


getVerb

public String getVerb()
               throws OAIException
The verb parameter used for this request.

Throws:
OAIException

requery

public void requery()
             throws OAIException
This will reset the entire list to the beginning, redoing the query from scratch.

Throws:
OAIException

getResponseSize

public int getResponseSize()
                    throws OAIException
Return the number of items contained in the most recent response

Throws:
OAIException

close

public void close()


Copyright © 2013. All Rights Reserved.