iText 8.0.4 API
iText.IO.Source.IRandomAccessSource Interface Reference

Represents an abstract source that bytes can be read from. More...

Inheritance diagram for iText.IO.Source.IRandomAccessSource:
iText.IO.Source.GetBufferedRandomAccessSource iText.IO.Source.IndependentRandomAccessSource iText.IO.Source.ThreadSafeRandomAccessSource iText.IO.Source.WindowRandomAccessSource

Public Member Functions

int  Get (long position)
  Gets a byte at the specified position More...
 
int  Get (long position, byte[] bytes, int off, int len)
  Read an array of bytes of specified length from the specified position of source to the buffer applying the offset. More...
 
long  Length ()
  Gets the length of the source More...
 
void  Close ()
  Closes this source. More...
 

Detailed Description

Represents an abstract source that bytes can be read from.

Represents an abstract source that bytes can be read from. This class forms the foundation for all byte input in iText. Implementations do not keep track of a current 'position', but rather provide absolute get methods. Tracking position should be handled in classes that use RandomAccessSource internally (via composition).

Member Function Documentation

◆ Close()

void iText.IO.Source.IRandomAccessSource.Close ( )

Closes this source.

Closes this source. The underlying data structure or source (if any) will also be closed

Implemented in iText.IO.Source.WindowRandomAccessSource, iText.IO.Source.GetBufferedRandomAccessSource, iText.IO.Source.IndependentRandomAccessSource, and iText.IO.Source.ThreadSafeRandomAccessSource.

◆ Get() [1/2]

int iText.IO.Source.IRandomAccessSource.Get ( long  position )

Gets a byte at the specified position

Parameters
position byte position
Returns
the byte, or -1 if EOF is reached

Implemented in iText.IO.Source.WindowRandomAccessSource, iText.IO.Source.GetBufferedRandomAccessSource, iText.IO.Source.IndependentRandomAccessSource, and iText.IO.Source.ThreadSafeRandomAccessSource.

◆ Get() [2/2]

int iText.IO.Source.IRandomAccessSource.Get ( long  position,
byte[]  bytes,
int  off,
int  len 
)

Read an array of bytes of specified length from the specified position of source to the buffer applying the offset.

Read an array of bytes of specified length from the specified position of source to the buffer applying the offset. If the number of bytes requested cannot be read, all the possible bytes will be read to the buffer, and the number of actually read bytes will be returned.

Parameters
position the position in the RandomAccessSource to read from
bytes output buffer
off offset into the output buffer where results will be placed
len the number of bytes to read
Returns
the number of bytes actually read, or -1 if the file is at EOF

Implemented in iText.IO.Source.WindowRandomAccessSource, iText.IO.Source.GetBufferedRandomAccessSource, iText.IO.Source.IndependentRandomAccessSource, and iText.IO.Source.ThreadSafeRandomAccessSource.

◆ Length()

long iText.IO.Source.IRandomAccessSource.Length ( )