Class PRTokeniser

java.lang.Object
com.itextpdf.text.pdf.PRTokeniser

public class PRTokeniser extends Object
  • Field Details

  • Constructor Details

    • PRTokeniser

      public PRTokeniser(RandomAccessFileOrArray file)
      Creates a PRTokeniser for the specified RandomAccessFileOrArray. The beginning of the file is read to determine the location of the header, and the data source is adjusted as necessary to account for any junk that occurs in the byte source before the header
      Parameters:
      file - the source
  • Method Details

    • seek

      public void seek(long pos) throws IOException
      Throws:
      IOException
    • getFilePointer

      public long getFilePointer() throws IOException
      Throws:
      IOException
    • close

      public void close() throws IOException
      Throws:
      IOException
    • length

      public long length() throws IOException
      Throws:
      IOException
    • read

      public int read() throws IOException
      Throws:
      IOException
    • getSafeFile

      public RandomAccessFileOrArray getSafeFile()
    • getFile

      public RandomAccessFileOrArray getFile()
    • readString

      public String readString(int size) throws IOException
      Throws:
      IOException
    • isWhitespace

      public static final boolean isWhitespace(int ch)
      Is a certain character a whitespace? Currently checks on the following: '0', '9', '10', '12', '13', '32'.
      The same as calling isWhiteSpace(ch, true).
      Parameters:
      ch - int
      Returns:
      boolean
      Since:
      5.5.1
    • isWhitespace

      public static final boolean isWhitespace(int ch, boolean isWhitespace)
      Checks whether a character is a whitespace. Currently checks on the following: '0', '9', '10', '12', '13', '32'.
      Parameters:
      ch - int
      isWhitespace - boolean
      Returns:
      boolean
      Since:
      5.5.1
    • isDelimiter

      public static final boolean isDelimiter(int ch)
    • isDelimiterWhitespace

      public static final boolean isDelimiterWhitespace(int ch)
    • getTokenType

      public PRTokeniser.TokenType getTokenType()
    • getStringValue

      public String getStringValue()
    • getReference

      public int getReference()
      Gets current reference number. If parsing was failed with NumberFormatException -1 will be return.
      Returns:
      a positive integer for correct reference, or negative for incorrect.
    • getGeneration

      public int getGeneration()
    • backOnePosition

      public void backOnePosition(int ch)
    • throwError

      public void throwError(String error) throws IOException
      Throws:
      IOException
    • getHeaderOffset

      public int getHeaderOffset() throws IOException
      Throws:
      IOException
    • checkPdfHeader

      public char checkPdfHeader() throws IOException
      Throws:
      IOException
    • checkFdfHeader

      public void checkFdfHeader() throws IOException
      Throws:
      IOException
    • getStartxref

      public long getStartxref() throws IOException
      Throws:
      IOException
    • getHex

      public static int getHex(int v)
    • nextValidToken

      public void nextValidToken() throws IOException
      Throws:
      IOException
    • nextToken

      public boolean nextToken() throws IOException
      Throws:
      IOException
    • longValue

      public long longValue()
    • intValue

      public int intValue()
    • readLineSegment

      public boolean readLineSegment(byte[] input) throws IOException
      Reads data into the provided byte[]. Checks on leading whitespace. See isWhiteSpace(int) or isWhiteSpace(int, boolean) for a list of whitespace characters.
      The same as calling readLineSegment(input, true).
      Parameters:
      input - byte[]
      Returns:
      boolean
      Throws:
      IOException
      Since:
      5.5.1
    • readLineSegment

      public boolean readLineSegment(byte[] input, boolean isNullWhitespace) throws IOException
      Reads data into the provided byte[]. Checks on leading whitespace. See isWhiteSpace(int) or isWhiteSpace(int, boolean) for a list of whitespace characters.
      Parameters:
      input - byte[]
      isNullWhitespace - boolean to indicate whether '0' is whitespace or not. If in doubt, use true or overloaded method readLineSegment(input)
      Returns:
      boolean
      Throws:
      IOException
      Since:
      5.5.1
    • checkObjectStart

      public static long[] checkObjectStart(byte[] line)
    • isHexString

      public boolean isHexString()