public interface RandomAccessor
 A RandomAccessor instance is associated with a particular document.  The
 read(long, byte[], int, int) method allows random access to the
 document's content, using the ContentObject referenced by the document
 when the RandomAccessor was created.  The content size can be obtained
 by calling length().
 
 If a RandomAccessor is writeable, the document's
 content can be updated by calling write(long, byte[], int, int)
 and truncate(long).  As changes are made by write
 and truncate, they are visible to read and
 length.  However, the changes are not visible outside of the
 RandomAccessor until close() is called.  Upon close,
 a new ContentObject is created and the document's CONTENTOBJECT attribute
 is set to reference that new ContentObject.  If, prior to close,
 LibrarySession.beginTransaction() was called to
 start an explicit transaction, these changes occur within that transaction
 and will not be visible to other sessions until that transaction completes.
 If the transaction is instead aborted, the changes are discarded.  The
 changes are also discarded if dispose() is called instead of
 close.
 
 Prior to close, the RandomAccessor may be used in successive
 transactions in a session.  However, the effect of aborting a transaction
 in which write or truncate was called is
 unspecified, unless close was also called in the same
 transaction, in which case the changes are discarded.  This is because
 some Medias are non-transactional.
 
 In general, successive reads and writes against a RandomAccessor will be
 more performant if they are performed in a single transaction created by
 calling LibrarySession.beginTransaction().  This
 is because RandomAccessor needs to re-establish some of its internal state
 when the in-progress transaction changes.
 
 A RandomAccessor is initially bound to the session in which it was created.
 The setSession(LibrarySessionInterface) method may be called to
 bind the RandomAccessor to a different session.  This capability must be
 used carefully.  Once either write or truncate
 have been invoked on a RandomAccessor, setSession will throw
 an exception if the RandomAccessor has been used within a transaction that
 has yet to complete or abort.
 
 When a writeable RandomAccessor is created, an expiration period can be
 specified.  If no expiration period is specified, the expiration period
 defaults to the domain property named IFS.DOMAIN.RANDOMACCESSOR.ExpirationPeriod.
 If a time interval equal to the expiration period passes in which neither
 write nor truncate is called, the RandomAccessor
 will expire as if dispose had been called.  Expiration is
 performed periodically in the background.  Once a RandomAccessor expires,
 further operations on it will throw an exception.  A writeable RandomAccessor
 will not expire if its content has not been changed (that is, if neither
 write nor truncate has been called).  A writeable
 RandomAccessor will also not expire if it has been used within a transaction
 that has yet to complete or abort.  Non-writeable RandomAccessors never expire.
| Modifier and Type | Method and Description | 
|---|---|
void | 
close()
Closes this RandomAccessor, saving any changes to the document. 
 | 
void | 
dispose()
Disposes this RandomAccessor, discarding any changes to the document. 
 | 
Long | 
getContentObjectId()
Gets the id of the ContentObject being accessed by this RandomAccessor. 
 | 
Long | 
getDocumentId()
Gets the id of the Document being accessed by this RandomAccessor. 
 | 
LibrarySessionInterface | 
getSession()
Gets the session associated with this RandomAccessor. 
 | 
boolean | 
isWriteable()
Gets whether this RandomAccessor is writeable. 
 | 
long | 
length()
Gets the content length. 
 | 
int | 
read(long pos,
    byte[] b,
    int off,
    int len)
Reads bytes from content into a byte array. 
 | 
void | 
setSession(LibrarySessionInterface session)
Sets the session associated with this RandomAccessor. 
 | 
void | 
truncate(long len)
Truncates the content to exactly  
len bytes in length. | 
void | 
write(long pos,
     byte[] b,
     int off,
     int len)
Writes bytes from a byte array. 
 | 
Long getDocumentId() throws IfsException
IfsException - if the operation failsLong getContentObjectId() throws IfsException
IfsException - if the operation failsvoid setSession(LibrarySessionInterface session) throws IfsException
A RandomAccessor is initially bound to the session in which it was created. Call this method to safely use the RandomAccessor in the context of a different session.
session - the sessionIfsException - if the operation failsLibrarySessionInterface getSession() throws IfsException
IfsException - if the operation failsint read(long pos,
         byte[] b,
         int off,
         int len)
  throws IfsException
 Reads from position pos in content, where 0 is the first byte
 in content, 1 is the second byte, and so forth.
 
 Attempts to read as many as len bytes, but a smaller number
 of bytes may actually be read.  Returns 0 if len is 0.
 Otherwise, blocks until at least one byte is read, the end of file is
 detected, or an error occurs.  Returns the number of bytes actually read.
 
 The bytes are read into b starting at index off.
 If r is the number of bytes actually read (as returned by the
 method), the bytes are read into elements b[off] through
 b[off+r-1].  Elements b[off+r] through
 b[off+len-1] are not changed.  Additionally, elements
 b[0] through b[off-1] are never changed.
 Similarly, b[off+len] through b[b.length-1]
 are never changed.
 
An exception is thrown upon any of the following conditions:
pos < 0pos >= length()b == nulloff < 0len < 0off + len > b.lengthpos - the position in content from which to readb - the buffer into which to readoff - the offset in the bufferlen - the maximum number of bytes to readIfsException - if the operation failsboolean isWriteable()
             throws IfsException
IfsException - if the operation failsvoid write(long pos,
           byte[] b,
           int off,
           int len)
    throws IfsException
 If len is 0, the content is unchanged.  Otherwise, the
 content is changed as specified in the following two paragraphs.
 
 The bytes b[off] through b[off+len-1] are
 written to positions pos through pos + len - 1
 in the content, where 0 is the position of the first byte in content, 1
 is the second byte, and so forth.
 
 If, prior to the call, pos + len > length(), the method will
 extend the content so that pos + len == length().
 
An exception is thrown upon any of the following conditions:
pos < 0b == nulloff < 0len < 0off + len > b.lengthpos - the position in content from which to writeb - the buffer from which to writeoff - the offset in the bufferlen - the number of bytes to writeIfsException - if the operation failsvoid truncate(long len)
       throws IfsException
len bytes in length.
 
 If len > length(), the content at byte positions
 len through length() - 1 are dropped,
 where 0 is the position of the first byte in content, 1 the second
 byte, and so forth.
 
 If len < length(), the content is resized by zero-filling
 positions length() through len - 1.
 
 If len == length(), the method has no effect.
 
 In all three cases, after the method returns, length() will
 return len.
 
 An exception is thrown if len < 0 or this RandomAccessor is
 not writeable.
len - the desired content lengthIfsException - if the operation failslong length()
     throws IfsException
IfsException - if the operation failsvoid dispose()
      throws IfsException
 To release resources held by the RandomAccessor, an application should
 call either close (to save changes) or dispose
 (to discard changes).
IfsException - if the operation failsvoid close()
    throws IfsException
For a writeable RandomAccessor, a new ContentObject is created for the updated content, and the document's CONTENTOBJECT attribute is set to reference this new ContentObject. Any other changes specified by the DocumentDefinition supplied in creating this RandomAccessor are also applied.
 For a non-writeable RandomAccessor, close is equivalent to
 dispose.
 
 To release resources held by the RandomAccessor, an application should
 call either close (to save changes) or dispose
 (to discard changes).
IfsException - if the operation failsCopyright © 2025. All rights reserved.