Class IRODSDataObjectStream

java.lang.Object
org.irods.irods4j.high_level.io.IRODSDataObjectStream
All Implemented Interfaces:
AutoCloseable

public class IRODSDataObjectStream extends Object implements AutoCloseable
A class which enables reading and writing of iRODS data objects.
Since:
0.1.0
  • Constructor Details

    • IRODSDataObjectStream

      public IRODSDataObjectStream()
      Initializes a new stream.
      Since:
      0.1.0
  • Method Details

    • open

      public void open(IRODSApi.RcComm comm, String logicalPath, int openMode) throws IOException, IRODSException
      Opens a data object.

      Depending on the openMode, nonexistent data objects may be created.

      Parameters:
      logicalPath - The absolute logical path to a data object.
      openMode - The open flags used to tell the server how to open the data object.
      Throws:
      IOException
      IRODSException
      Since:
      0.1.0
    • open

      public void open(IRODSApi.RcComm comm, String logicalPath, long replicaNumber, int openMode) throws IOException, IRODSException
      Opens a specific replica.

      This function does NOT create new replicas.

      Parameters:
      logicalPath - The absolute logical path to a data object.
      replicaNumber - The replica number identifying the replica.
      openMode - The open flags used to tell the server how to open the data object.
      Throws:
      IRODSException
      IOException
      Since:
      0.1.0
    • open

      public void open(IRODSApi.RcComm comm, String logicalPath, String rootResource, int openMode) throws IOException, IRODSException
      Opens a specific replica.

      Depending on the openMode, nonexistent data objects may be created.

      Parameters:
      logicalPath - The absolute logical path to a data object.
      rootResource - The root resource containing the target replica.
      openMode - The open flags used to tell the server how to open the data object.
      Throws:
      IRODSException
      IOException
      Since:
      0.1.0
    • open

      public void open(IRODSApi.RcComm comm, String replicaToken, String logicalPath, long replicaNumber, int openMode) throws IOException, IRODSException
      Opens a specific replica.

      This constructor is designed for cases involving parallel transfer. The replica of interest is assumed to have been opened prior to this call.

      This function does NOT create new replicas.

      Parameters:
      replicaToken - The token associated with the primary replica.
      logicalPath - The absolute logical path to a data object.
      replicaNumber - The replica number identifying the replica.
      openMode - The open flags used to tell the server how to open the data object.
      Throws:
      IRODSException
      IOException
      Since:
      0.1.0
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception
    • close

      public void close(IRODSDataObjectStream.OnCloseSuccess onCloseSuccess) throws IOException
      Closes an open replica with additional instructions.

      This form of close is designed for cases involving parallel transfer.

      Parameters:
      onCloseSuccess - Instructions for the server to carry out.
      Throws:
      IOException
      Since:
      0.1.0
    • seek

      public long seek(int offset, IRODSDataObjectStream.SeekDirection direction) throws IOException, IRODSException
      Changes the position of the read/write position.
      Parameters:
      offset - The number of bytes to move by.
      direction - Describes how the offset is to be interpreted.
      Returns:
      The new position of the read/write pointer.
      Throws:
      IOException
      IRODSException
      Since:
      0.1.0
    • read

      public int read(byte[] buffer, int count) throws IOException, IRODSException
      Reads bytes from a data object.
      Parameters:
      buffer - The byte buffer to fill.
      count - The size of the byte buffer.
      Returns:
      The number of bytes read.
      Throws:
      IOException
      IRODSException
      Since:
      0.1.0
    • write

      public int write(byte[] buffer, int count) throws IOException, IRODSException
      Writes bytes to a data object.
      Parameters:
      buffer - The byte buffer which will be written to the data object.
      count - The number of bytes to write.
      Returns:
      The number of bytes written.
      Throws:
      IOException
      IRODSException
      Since:
      0.1.0
    • isOpen

      public boolean isOpen()
      Returns whether the stream is open.
      Since:
      0.1.0
    • getNativeHandle

      public int getNativeHandle()
      Returns the native handle of the stream.

      The value returned will be an L1 descriptor. This is equivalent to a file descriptor in POSIX.

      Since:
      0.1.0
    • getReplicaNumber

      public long getReplicaNumber()
      Returns the replica number which identifies the open replica of the data object.
      Since:
      0.1.0
    • getReplicaToken

      public String getReplicaToken()
      Returns the replica access token associated with the open replica.
      Since:
      0.1.0