iText 7 7.1.9 API
iText.IO.Source.RandomAccessFileOrArray Class Reference

Class that is used to unify reading from random access files and arrays. More...

Public Member Functions

  RandomAccessFileOrArray (IRandomAccessSource byteSource)
  Creates a RandomAccessFileOrArray that wraps the specified byte source. More...
 
virtual iText.IO.Source.RandomAccessFileOrArray  CreateView ()
  Creates an independent view of this object (with it's own file pointer and push back queue). More...
 
virtual IRandomAccessSource  CreateSourceView ()
  Creates the view of the byte source of this object. More...
 
virtual void  PushBack (byte b)
  Pushes a byte back. More...
 
virtual int  Read ()
  Reads a single byte More...
 
virtual int  Read (byte[] b, int off, int len)
  Reads the specified amount of bytes to the buffer applying the offset. More...
 
virtual int  Read (byte[] b)
  Reads the bytes to the buffer. More...
 
virtual void  ReadFully (byte[] b)
 
virtual void  ReadFully (byte[] b, int off, int len)
 
virtual long  Skip (long n)
  Make an attempt to skip the specified amount of bytes in source. More...
 
virtual int  SkipBytes (int n)
 
virtual void  Close ()
  Closes the underlying source. More...
 
virtual long  Length ()
  Gets the total amount of bytes in the source. More...
 
virtual void  Seek (long pos)
  Sets the current position in the source to the specified index. More...
 
virtual long  GetPosition ()
  Gets the current position of the source considering the pushed byte to the source. More...
 
virtual bool  ReadBoolean ()
 
virtual byte  ReadByte ()
 
virtual int  ReadUnsignedByte ()
 
virtual short  ReadShort ()
 
short  ReadShortLE ()
  Reads a signed 16-bit number from this stream in little-endian order. More...
 
virtual int  ReadUnsignedShort ()
 
int  ReadUnsignedShortLE ()
  Reads an unsigned 16-bit number from this stream in little-endian order. More...
 
virtual char  ReadChar ()
 
char  ReadCharLE ()
  Reads a Unicode character from this stream in little-endian order. More...
 
virtual int  ReadInt ()
 
int  ReadIntLE ()
  Reads a signed 32-bit integer from this stream in little-endian order. More...
 
long  ReadUnsignedInt ()
  Reads an unsigned 32-bit integer from this stream. More...
 
long  ReadUnsignedIntLE ()
 
virtual long  ReadLong ()
 
long  ReadLongLE ()
 
virtual float  ReadFloat ()
 
float  ReadFloatLE ()
 
virtual double  ReadDouble ()
 
double  ReadDoubleLE ()
 
virtual String  ReadLine ()
 
virtual String  ReadString (int length, String encoding)
  Reads a String from the font file as bytes using the given encoding. More...
 

Static Public Attributes

static bool  plainRandomAccess = false
  When true the file access is not done through a memory mapped file. More...
 

Detailed Description

Class that is used to unify reading from random access files and arrays.

Constructor & Destructor Documentation

◆ RandomAccessFileOrArray()

iText.IO.Source.RandomAccessFileOrArray.RandomAccessFileOrArray ( IRandomAccessSource  byteSource )
inline

Creates a RandomAccessFileOrArray that wraps the specified byte source.

Creates a RandomAccessFileOrArray that wraps the specified byte source. The byte source will be closed when this RandomAccessFileOrArray is closed.

Parameters
byteSource the byte source to wrap

Member Function Documentation

◆ Close()

virtual void iText.IO.Source.RandomAccessFileOrArray.Close ( )
inlinevirtual

Closes the underlying source.

◆ CreateSourceView()

virtual IRandomAccessSource iText.IO.Source.RandomAccessFileOrArray.CreateSourceView ( )
inlinevirtual

Creates the view of the byte source of this object.

Creates the view of the byte source of this object. Closing the view won't affect this object. Closing source will have adverse effect on the view.

Returns
the byte source view.

◆ CreateView()

virtual iText.IO.Source.RandomAccessFileOrArray iText.IO.Source.RandomAccessFileOrArray.CreateView ( )
inlinevirtual

Creates an independent view of this object (with it's own file pointer and push back queue).

Creates an independent view of this object (with it's own file pointer and push back queue). Closing the new object will not close this object. Closing this object will have adverse effect on the view.

Returns
the new view

◆ GetPosition()

virtual long iText.IO.Source.RandomAccessFileOrArray.GetPosition ( )
inlinevirtual

Gets the current position of the source considering the pushed byte to the source.

Returns
the index of last read byte in the source in or the index of last read byte in source - 1 in case byte was pushed.

◆ Length()

virtual long iText.IO.Source.RandomAccessFileOrArray.Length ( )
inlinevirtual

Gets the total amount of bytes in the source.

Returns
source's size.

◆ PushBack()

virtual void iText.IO.Source.RandomAccessFileOrArray.PushBack ( byte  b )
inlinevirtual

Pushes a byte back.

Pushes a byte back. The next get() will return this byte instead of the value from the underlying data source

Parameters
b the byte to push

◆ Read() [1/3]

virtual int iText.IO.Source.RandomAccessFileOrArray.Read ( )
inlinevirtual

Reads a single byte

Returns
the byte, or -1 if EOF is reached

◆ Read() [2/3]

virtual int iText.IO.Source.RandomAccessFileOrArray.Read ( byte[]  b )
inlinevirtual

Reads the bytes to the buffer.

Reads the bytes to the buffer. This method will try to read as many bytes as the buffer can hold.

Parameters
b the destination buffer
Returns
the number of bytes actually read

◆ Read() [3/3]

virtual int iText.IO.Source.RandomAccessFileOrArray.Read ( byte[]  b,
int  off,
int  len 
)
inlinevirtual

Reads the specified amount of bytes to the buffer applying the offset.

Parameters
b destination buffer
off offset at which to start storing characters
len maximum number of characters to read
Returns
the number of bytes actually read or -1 in case of EOF

◆ ReadBoolean()

virtual bool iText.IO.Source.RandomAccessFileOrArray.ReadBoolean ( )
inlinevirtual

◆ ReadByte()

virtual byte iText.IO.Source.RandomAccessFileOrArray.ReadByte ( )
inlinevirtual

◆ ReadChar()

virtual char iText.IO.Source.RandomAccessFileOrArray.ReadChar ( )
inlinevirtual

◆ ReadCharLE()

char iText.IO.Source.RandomAccessFileOrArray.ReadCharLE ( )
inline

Reads a Unicode character from this stream in little-endian order.

Reads a Unicode character from this stream in little-endian order. This method reads two bytes from the stream, starting at the current stream pointer. If the bytes read, in order, are b1 and b2 , where 0 <= b1, b2 <= 255 , then the result is equal to:

(char)((b2 << 8) | b1)

This method blocks until the two bytes are read, the end of the stream is detected, or an exception is thrown.

Returns
the next two bytes of this stream as a Unicode character.

◆ ReadDouble()

virtual double iText.IO.Source.RandomAccessFileOrArray.ReadDouble ( )
inlinevirtual

◆ ReadFloat()

virtual float iText.IO.Source.RandomAccessFileOrArray.ReadFloat ( )
inlinevirtual

◆ ReadFully() [1/2]

virtual void iText.IO.Source.RandomAccessFileOrArray.ReadFully ( byte[]  b )
inlinevirtual

◆ ReadFully() [2/2]

virtual void iText.IO.Source.RandomAccessFileOrArray.ReadFully ( byte[]  b,
int  off,
int  len 
)
inlinevirtual

◆ ReadInt()

virtual int iText.IO.Source.RandomAccessFileOrArray.ReadInt ( )
inlinevirtual

◆ ReadIntLE()

int iText.IO.Source.RandomAccessFileOrArray.ReadIntLE ( )
inline

Reads a signed 32-bit integer from this stream in little-endian order.

Reads a signed 32-bit integer from this stream in little-endian order. This method reads 4 bytes from the stream, starting at the current stream pointer. If the bytes read, in order, are b1 , b2 , b3 , and b4 , where 0 <= b1, b2, b3, b4 <= 255 , then the result is equal to:

(b4 << 24) | (b3 << 16) + (b2 << 8) + b1

This method blocks until the four bytes are read, the end of the stream is detected, or an exception is thrown.

Returns
the next four bytes of this stream, interpreted as an int.

◆ ReadLine()

virtual String iText.IO.Source.RandomAccessFileOrArray.ReadLine ( )
inlinevirtual

◆ ReadLong()

virtual long iText.IO.Source.RandomAccessFileOrArray.ReadLong ( )
inlinevirtual

◆ ReadShort()

virtual short iText.IO.Source.RandomAccessFileOrArray.ReadShort ( )
inlinevirtual

◆ ReadShortLE()

short iText.IO.Source.RandomAccessFileOrArray.ReadShortLE ( )
inline

Reads a signed 16-bit number from this stream in little-endian order.

Reads a signed 16-bit number from this stream in little-endian order. The method reads two bytes from this stream, starting at the current stream pointer. If the two bytes read, in order, are b1 and b2 , where each of the two values is between 0 and 255 , inclusive, then the result is equal to:

(short)((b2 << 8) | b1)

This method blocks until the two bytes are read, the end of the stream is detected, or an exception is thrown.

Returns
the next two bytes of this stream, interpreted as a signed 16-bit number.

◆ ReadString()

virtual String iText.IO.Source.RandomAccessFileOrArray.ReadString ( int  length,
String  encoding 
)
inlinevirtual

Reads a String from the font file as bytes using the given encoding.

Parameters
length the length of bytes to read
encoding the given encoding
Returns
the String read

◆ ReadUnsignedByte()

virtual int iText.IO.Source.RandomAccessFileOrArray.ReadUnsignedByte ( )
inlinevirtual

◆ ReadUnsignedInt()

long iText.IO.Source.RandomAccessFileOrArray.ReadUnsignedInt ( )
inline

Reads an unsigned 32-bit integer from this stream.

Reads an unsigned 32-bit integer from this stream. This method reads 4 bytes from the stream, starting at the current stream pointer. If the bytes read, in order, are b1 , b2 , b3 , and b4 , where 0 <= b1, b2, b3, b4 <= 255 , then the result is equal to:

(b1 << 24) | (b2 << 16) + (b3 << 8) + b4

This method blocks until the four bytes are read, the end of the stream is detected, or an exception is thrown.

Returns
the next four bytes of this stream, interpreted as a long.

◆ ReadUnsignedShort()

virtual int iText.IO.Source.RandomAccessFileOrArray.ReadUnsignedShort ( )
inlinevirtual

◆ ReadUnsignedShortLE()

int iText.IO.Source.RandomAccessFileOrArray.ReadUnsignedShortLE ( )
inline

Reads an unsigned 16-bit number from this stream in little-endian order.

Reads an unsigned 16-bit number from this stream in little-endian order. This method reads two bytes from the stream, starting at the current stream pointer. If the bytes read, in order, are b1 and b2 , where 0 <= b1, b2 <= 255 , then the result is equal to:

(b2 << 8) | b1

This method blocks until the two bytes are read, the end of the stream is detected, or an exception is thrown.

Returns
the next two bytes of this stream, interpreted as an unsigned 16-bit integer.

◆ Seek()

virtual void iText.IO.Source.RandomAccessFileOrArray.Seek ( long  pos )
inlinevirtual

Sets the current position in the source to the specified index.

Parameters
pos the position to set

◆ Skip()

virtual long iText.IO.Source.RandomAccessFileOrArray.Skip ( long  n )
inlinevirtual

Make an attempt to skip the specified amount of bytes in source.

Make an attempt to skip the specified amount of bytes in source. However it may skip less amount of bytes. Possibly zero.

Parameters
n the number of bytes to skip
Returns
the actual number of bytes skipped

◆ SkipBytes()

virtual int iText.IO.Source.RandomAccessFileOrArray.SkipBytes ( int  n )
inlinevirtual

Member Data Documentation

◆ plainRandomAccess

bool iText.IO.Source.RandomAccessFileOrArray.plainRandomAccess = false
static

When true the file access is not done through a memory mapped file.

When true the file access is not done through a memory mapped file. Use it if the file is too big to be mapped in your address space.