Package org.irods.irods4j.high_level.io
Class IRODSDataObjectStream
java.lang.Object
org.irods.irods4j.high_level.io.IRODSDataObjectStream
- All Implemented Interfaces:
AutoCloseable
A class which enables reading and writing of iRODS data objects.
- Since:
- 0.1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classInstructions for the iRODS server following a successful close of a data object.static enumSeek operation options. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidclose(IRODSDataObjectStream.OnCloseSuccess onCloseSuccess) Closes an open replica with additional instructions.intReturns the native handle of the stream.longReturns the replica number which identifies the open replica of the data object.Returns the replica access token associated with the open replica.booleanisOpen()Returns whether the stream is open.voidopen(IRODSApi.RcComm comm, String logicalPath, int openMode) Opens a data object.voidopen(IRODSApi.RcComm comm, String logicalPath, long replicaNumber, int openMode) Opens a specific replica.voidopen(IRODSApi.RcComm comm, String logicalPath, String rootResource, int openMode) Opens a specific replica.voidopen(IRODSApi.RcComm comm, String replicaToken, String logicalPath, long replicaNumber, int openMode) Opens a specific replica.intread(byte[] buffer, int count) Reads bytes from a data object.longseek(int offset, IRODSDataObjectStream.SeekDirection direction) Changes the position of the read/write position.intwrite(byte[] buffer, int count) Writes bytes to a data object.
-
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:
IOExceptionIRODSException- 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:
IRODSExceptionIOException- 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:
IRODSExceptionIOException- 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:
IRODSExceptionIOException- Since:
- 0.1.0
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
close
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:
IOExceptionIRODSException- Since:
- 0.1.0
-
read
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:
IOExceptionIRODSException- Since:
- 0.1.0
-
write
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:
IOExceptionIRODSException- 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
Returns the replica access token associated with the open replica.- Since:
- 0.1.0
-