Interface Cursor

All Superinterfaces:
java.lang.AutoCloseable

public interface Cursor
extends java.lang.AutoCloseable
Provides access to the results of a query. A cursor can be opened only if a read-only or a read/write transaction is active on the data store connection that the cursor was created on.
  • Method Summary

    Modifier and Type Method Description
    long advance()
    Advances the cursor and positions it to the next tuple.
    boolean canAdvance()
    Checks whether advance() can be called to continue iteration.
    void close()
    Closes the cursor by freeing all resources associated with it.
    java.lang.String getAnswerVariableName​(int argumentIndex)
    Returns the name of the answer variable for the given index.
    int getArity()
    Returns the arity (i.e., the number of columns) of the answers that the cursor computes.
    long getCurrentMultiplicity()
    Returns the multiplicity of the current tuple.
    long getCurrentOffset()
    Returns the offset of the current tuple.
    DataStoreConnection getDataStoreConnection()
    Returns the data store connection that this cursor is associated with.
    Resource getResource​(int argumentIndex)
    Returns the resource by for the given index in the current answer row.
    ResourceValue getResourceValue​(int argumentIndex)
    Returns the resource bound to the given index in the current answer row.
    long open()
    Opens the cursor and positions it to the first tuple.
    long open​(long skipToOffset)
    Opens the cursor and positions it to the tuple with the given offset.
    void stop()
    Stops this iterator by releasing all resources that the cursor might hold.
  • Method Details

    • getDataStoreConnection

      DataStoreConnection getDataStoreConnection() throws JRDFoxException
      Returns the data store connection that this cursor is associated with.
      Returns:
      the data store connection that this cursor is associated with
      Throws:
      JRDFoxException - thrown if an error is encountered
    • getArity

      int getArity() throws JRDFoxException
      Returns the arity (i.e., the number of columns) of the answers that the cursor computes.
      Returns:
      the arity of the cursor's answers
      Throws:
      JRDFoxException - thrown if an error is encountered
    • getAnswerVariableName

      java.lang.String getAnswerVariableName​(int argumentIndex) throws JRDFoxException
      Returns the name of the answer variable for the given index.
      Parameters:
      argumentIndex - the index of the variable whose name is to be returned
      Returns:
      the name of the variable at the given index
      Throws:
      JRDFoxException - thrown if an error is encountered
    • getResourceValue

      ResourceValue getResourceValue​(int argumentIndex) throws JRDFoxException
      Returns the resource bound to the given index in the current answer row.
      Parameters:
      argumentIndex - the index of the resource being returned
      Returns:
      the resource at the given index, or null if the given index in the row is unbound
      Throws:
      JRDFoxException - thrown if an error is encountered
    • getResource

      Resource getResource​(int argumentIndex) throws JRDFoxException
      Returns the resource by for the given index in the current answer row.
      Parameters:
      argumentIndex - the index of the resource being returned
      Returns:
      the resource corresponding to the given index, or null if the given index in the row is unbound
      Throws:
      JRDFoxException - thrown if an error is encountered
    • open

      long open() throws JRDFoxException
      Opens the cursor and positions it to the first tuple. It is allowed to open the cursor more than once.
      Returns:
      the multiplicity of the first tuple (0 if there are no tuples)
      Throws:
      JRDFoxException - thrown if an error is encountered
    • open

      long open​(long skipToOffset) throws JRDFoxException
      Opens the cursor and positions it to the tuple with the given offset. It is allowed to open the cursor more than once.
      Parameters:
      skipToOffset - the offset of the tuple to which the cursor should be positioned
      Returns:
      the multiplicity of the first tuple (0 if there are no tuples)
      Throws:
      JRDFoxException - thrown if an error is encountered
    • canAdvance

      boolean canAdvance() throws JRDFoxException
      Checks whether advance() can be called to continue iteration. Iteration cannot be continued if the data store has changed since this cursor was opened.
      Returns:
      true if the data store has not changed since this cursor was opened
      Throws:
      JRDFoxException - thrown if an error is encountered
    • advance

      long advance() throws JRDFoxException
      Advances the cursor and positions it to the next tuple.
      Returns:
      the multiplicity of the next tuple (0 if there are no more tuples)
      Throws:
      JRDFoxException - thrown if an error is encountered
    • getCurrentOffset

      long getCurrentOffset() throws JRDFoxException
      Returns the offset of the current tuple.
      Returns:
      the offset of the current tuple
      Throws:
      JRDFoxException - thrown if an error is encountered
    • getCurrentMultiplicity

      long getCurrentMultiplicity() throws JRDFoxException
      Returns the multiplicity of the current tuple.
      Returns:
      the multiplicity of the current tuple
      Throws:
      JRDFoxException - thrown if an error is encountered
    • stop

      void stop() throws JRDFoxException
      Stops this iterator by releasing all resources that the cursor might hold. This method should be called if a cursor is opened but not iterated to the end. It is called automatically after advance() returns 0.
      Throws:
      JRDFoxException - thrown if an error is encountered
    • close

      void close()
      Closes the cursor by freeing all resources associated with it. Once a cursor is closed, it cannot be used any further.
      Specified by:
      close in interface java.lang.AutoCloseable