Package com.itextpdf.text.pdf
Class PRTokeniser
- java.lang.Object
-
- com.itextpdf.text.pdf.PRTokeniser
-
public class PRTokeniser extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PRTokeniser.TokenType
Enum representing the possible token types
-
Field Summary
Fields Modifier and Type Field Description static boolean[]
delims
(package private) static java.lang.String
EMPTY
private RandomAccessFileOrArray
file
protected int
generation
protected boolean
hexString
private java.lang.StringBuilder
outBuf
protected int
reference
protected java.lang.String
stringValue
protected PRTokeniser.TokenType
type
-
Constructor Summary
Constructors Constructor Description PRTokeniser(RandomAccessFileOrArray file)
Creates a PRTokeniser for the specifiedRandomAccessFileOrArray
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
backOnePosition(int ch)
void
checkFdfHeader()
static long[]
checkObjectStart(byte[] line)
char
checkPdfHeader()
void
close()
RandomAccessFileOrArray
getFile()
long
getFilePointer()
int
getGeneration()
int
getHeaderOffset()
static int
getHex(int v)
int
getReference()
Gets current reference number.RandomAccessFileOrArray
getSafeFile()
long
getStartxref()
java.lang.String
getStringValue()
PRTokeniser.TokenType
getTokenType()
int
intValue()
static boolean
isDelimiter(int ch)
static boolean
isDelimiterWhitespace(int ch)
boolean
isHexString()
static boolean
isWhitespace(int ch)
Is a certain character a whitespace? Currently checks on the following: '0', '9', '10', '12', '13', '32'.static boolean
isWhitespace(int ch, boolean isWhitespace)
Checks whether a character is a whitespace.long
length()
long
longValue()
boolean
nextToken()
void
nextValidToken()
int
read()
boolean
readLineSegment(byte[] input)
Reads data into the provided byte[].boolean
readLineSegment(byte[] input, boolean isNullWhitespace)
Reads data into the provided byte[].java.lang.String
readString(int size)
void
seek(long pos)
void
throwError(java.lang.String error)
-
-
-
Field Detail
-
outBuf
private final java.lang.StringBuilder outBuf
-
delims
public static final boolean[] delims
-
EMPTY
static final java.lang.String EMPTY
- See Also:
- Constant Field Values
-
file
private final RandomAccessFileOrArray file
-
type
protected PRTokeniser.TokenType type
-
stringValue
protected java.lang.String stringValue
-
reference
protected int reference
-
generation
protected int generation
-
hexString
protected boolean hexString
-
-
Constructor Detail
-
PRTokeniser
public PRTokeniser(RandomAccessFileOrArray file)
Creates a PRTokeniser for the specifiedRandomAccessFileOrArray
. 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 Detail
-
seek
public void seek(long pos) throws java.io.IOException
- Throws:
java.io.IOException
-
getFilePointer
public long getFilePointer() throws java.io.IOException
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Throws:
java.io.IOException
-
length
public long length() throws java.io.IOException
- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException
- Throws:
java.io.IOException
-
getSafeFile
public RandomAccessFileOrArray getSafeFile()
-
getFile
public RandomAccessFileOrArray getFile()
-
readString
public java.lang.String readString(int size) throws java.io.IOException
- Throws:
java.io.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 callingisWhiteSpace(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
- intisWhitespace
- 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 java.lang.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(java.lang.String error) throws java.io.IOException
- Throws:
java.io.IOException
-
getHeaderOffset
public int getHeaderOffset() throws java.io.IOException
- Throws:
java.io.IOException
-
checkPdfHeader
public char checkPdfHeader() throws java.io.IOException
- Throws:
java.io.IOException
-
checkFdfHeader
public void checkFdfHeader() throws java.io.IOException
- Throws:
java.io.IOException
-
getStartxref
public long getStartxref() throws java.io.IOException
- Throws:
java.io.IOException
-
getHex
public static int getHex(int v)
-
nextValidToken
public void nextValidToken() throws java.io.IOException
- Throws:
java.io.IOException
-
nextToken
public boolean nextToken() throws java.io.IOException
- Throws:
java.io.IOException
-
longValue
public long longValue()
-
intValue
public int intValue()
-
readLineSegment
public boolean readLineSegment(byte[] input) throws java.io.IOException
Reads data into the provided byte[]. Checks on leading whitespace. SeeisWhiteSpace(int)
orisWhiteSpace(int, boolean)
for a list of whitespace characters.
The same as callingreadLineSegment(input, true)
.- Parameters:
input
- byte[]- Returns:
- boolean
- Throws:
java.io.IOException
- Since:
- 5.5.1
-
readLineSegment
public boolean readLineSegment(byte[] input, boolean isNullWhitespace) throws java.io.IOException
Reads data into the provided byte[]. Checks on leading whitespace. SeeisWhiteSpace(int)
orisWhiteSpace(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 methodreadLineSegment(input)
- Returns:
- boolean
- Throws:
java.io.IOException
- Since:
- 5.5.1
-
checkObjectStart
public static long[] checkObjectStart(byte[] line)
-
isHexString
public boolean isHexString()
-
-