com.lowagie.text.rtf.parser
public class RtfParser extends Object
Since: 2.0.8
Field Summary | |
---|---|
long | binByteCount
When the tokeniser is Binary. |
long | binSkipByteCount
When the tokeniser is set to skip bytes, binSkipByteCount is the number of bytes to skip. |
long | byteCount
Total bytes read. |
long | characterCount
Total clear text characters processed. |
long | closeGroupCount
Total } encountered as a close group token. |
int | conversionType
Conversion type. |
long | ctrlWordCount
Total control words processed.
|
long | ctrlWordHandledCount
Total control words recognized. |
long | ctrlWordNotHandledCount
Total control words not handled. |
long | ctrlWordSkippedCount
Total control words skipped. |
RtfParserState | currentState
The current parser state. |
static boolean | debugParser
Debugging flag. |
RtfDestinationMgr | destinationMgr
The RtfDestinationMgr object to manage destinations. |
int | docGroupLevel
The current document group nesting level. |
Document | document
The iText document to add the RTF document to. |
static int | DESTINATION_NORMAL
Destination is normal. |
static int | DESTINATION_SKIP
Destination is skipping. |
Date | endDate
End date as a date. |
long | endTime
Stop time as a long. |
static int | errAssertion |
static int | errBadTable |
static int | errCtrlWordNotFound |
static int | errEndOfFile |
static int | errInvalidHex |
static int | errOK |
static int | errStackOverflow |
static int | errStackUnderflow |
static int | errUnmatchedBrace |
int | groupLevel
The current group nesting level. |
long | groupSkippedCount
Total groups skipped. |
RtfImportMgr | importMgr
The RtfImportHeader to store imported font and color mappings in. |
RtfCtrlWordData | lastCtrlWordParam
Last control word and parameter processed. |
ArrayList | listeners The RtfCtrlWordListener . |
boolean | logAppend |
String | logFile |
boolean | logging |
long | openGroupCount
Total { encountered as an open group token. |
PushbackInputStream | pbReader
The pushback reader to read the input stream. |
static int | PARSER_ERROR
Currently the parser is in an error state. |
static int | PARSER_ERROR_EOF
The parser reached the end of the file. |
static int | PARSER_IN_BLIPUID
Currently a blipuid control word is being parsed. |
static int | PARSER_IN_CHARSET
Currently the RTF charset is being parsed. |
static int | PARSER_IN_COLOR_TABLE
Currently the RTF color table is being parsed. |
static int | PARSER_IN_DEFFONT
Currently the RTF deffont is being parsed. |
static int | PARSER_IN_DOCUMENT
Currently the RTF document content is being parsed. |
static int | PARSER_IN_FILE_TABLE
Currently the RTF filetbl is being parsed. |
static int | PARSER_IN_FONT_TABLE
Currently the RTF font table is being parsed. |
static int | PARSER_IN_FONT_TABLE_INFO
Currently a RTF font table info element is being parsed. |
static int | PARSER_IN_GENERATOR
Currently the RTF generator is being parsed. |
static int | PARSER_IN_HEADER
Currently the RTF document header is being parsed. |
static int | PARSER_IN_INFO_GROUP
Currently the RTF info group is being parsed. |
static int | PARSER_IN_LATENTSTYLES
Currently the Latent Style and Formatting usage restrictions |
static int | PARSER_IN_LISTOVERRIDE_TABLE
Currently the RTF listtable override is being parsed. |
static int | PARSER_IN_LIST_TABLE
Currently the RTF listtables is being parsed. |
static int | PARSER_IN_OLDCPROPS
Currently the RTF Old Properties. |
static int | PARSER_IN_OLDPPROPS
Currently the RTF Old Properties. |
static int | PARSER_IN_OLDSPROPS
Currently the RTF Old Properties. |
static int | PARSER_IN_OLDTPROPS
Currently the RTF Old Properties. |
static int | PARSER_IN_PARAGRAPH_GROUP_PROPERTIES |
static int | PARSER_IN_PARAGRAPH_TABLE
Currently the RTF Paragraph group properties Table (word 2002) |
static int | PARSER_IN_PICPROP
Currently a picprop control word is being parsed. |
static int | PARSER_IN_PICT
Currently a pict control word is being parsed. |
static int | PARSER_IN_PROT_USER_TABLE
Currently the RTF User Protection Information. |
static int | PARSER_IN_REV_TABLE
Currently the RTF revtbl is being parsed. |
static int | PARSER_IN_RSID_TABLE
Currently the RTF rsidtable is being parsed. |
static int | PARSER_IN_SHPPICT
Currently a shppict control word is being parsed. |
static int | PARSER_IN_STYLESHEET
Currently the RTF stylesheet is being parsed. |
static int | PARSER_IN_UNKNOWN
Currently the parser is in an unknown state. |
static int | PARSER_IN_UPR |
static int | PARSER_STARTSTOP
The parser is at the beginning or the end of the file. |
RtfDocument | rtfDoc
The RtfDocument to add the RTF document or fragment to. |
RtfCtrlWordMgr | rtfKeywordMgr
The RtfKeywords that creates and handles keywords that are implemented. |
int | skipGroupLevel
When the tokeniser is set to skip to next group, this is the group indentifier to return to. |
Stack | stackState
Stack for saving states for groups |
Date | startDate
Start date as a date. |
long | startTime
Start time as a long. |
static int | TOKENISER_BINARY
The RtfTokeniser is currently reading binary stream. |
static int | TOKENISER_HEX
The RtfTokeniser is currently reading hex data. |
static int | TOKENISER_IGNORE_RESULT
The RtfTokeniser ignore result |
static int | TOKENISER_NORMAL
The RtfTokeniser is in its ground state. |
static int | TOKENISER_SKIP_BYTES
The last token parsed was a slash. |
static int | TOKENISER_SKIP_GROUP
The RtfTokeniser is currently tokenising a control word. |
static int | TOKENISER_STATE_IN_ERROR
The RtfTokeniser is currently in error state |
static int | TOKENISER_STATE_IN_UNKOWN
The RtfTokeniser is currently in an unkown state |
static int | TYPE_CONVERT
Conversion type is a conversion. |
static int | TYPE_IMPORT_FRAGMENT
Conversion type is an import of a partial file/fragment. |
static int | TYPE_IMPORT_FULL
Conversion type is an import. |
static int | TYPE_UNIDENTIFIED
Conversion type is unknown |
Constructor Summary | |
---|---|
RtfParser(Document doc) |
Method Summary | |
---|---|
void | addListener(EventListener listener)
Adds a EventListener to the RtfCtrlWordMgr .
|
void | convertRtfDocument(InputStream readerIn, Document doc)
Converts an RTF document to an iText document.
|
int | getConversionType()
Get the conversion type.
|
RtfDestination | getCurrentDestination()
Get the current destination object.
|
RtfDestination | getDestination(String destination)
Get a destination from the map
|
Document | getDocument()
Get the Document object. |
boolean | getExtendedDestination()
Helper method to indicate if this control word was a \* control word. |
RtfImportMgr | getImportManager()
Get the RtfImportHeader object. |
int | getLevel()
Gets the current group level
|
String | getLogFile()
Get the logfile name.
|
int | getParserState()
Get the current state of the parser.
|
RtfDocument | getRtfDocument()
Get the RTF Document object. |
RtfParserState | getState()
Get the state of the parser.
|
int | getTokeniserState()
Get the current state of the tokeniser. |
int | handleCharacter(int nextChar)
Handles text tokens. |
int | handleCloseGroup()
Handles close group tokens. |
int | handleCtrlWord(RtfCtrlWordData ctrlWordData)
Handles control word tokens. |
void | handleImportMappings(RtfImportMappings importMappings)
Imports the mappings defined in the RtfImportMappings into the
RtfImportHeader of this RtfParser2.
|
int | handleOpenGroup()
Handles open group tokens. |
void | importRtfDocument(InputStream readerIn, RtfDocument rtfDoc)
Imports a complete RTF document.
|
void | importRtfFragment(InputStream readerIn, RtfDocument rtfDoc, RtfImportMappings importMappings)
Imports an RTF fragment.
|
void | init(int type, RtfDocument rtfDoc, InputStream readerIn, Document doc)
Initialize the parser object values.
|
PushbackInputStream | init_Reader(InputStream readerIn)
Casts the input reader to a PushbackReader or
creates a new PushbackReader from the Reader passed in.
|
protected void | init_stats()
Initialize the statistics values. |
boolean | isConvert()
Helper method to determin if conversion is TYPE_CONVERT |
boolean | isImport()
Helper method to determin if conversion is TYPE_IMPORT_FULL or TYPE_IMPORT_FRAGMENT |
boolean | isImportFragment()
Helper method to determin if conversion is TYPE_IMPORT_FRAGMENT |
boolean | isImportFull()
Helper method to determin if conversion is TYPE_IMPORT_FULL |
boolean | isLogAppend() |
boolean | isLogging()
Get flag indicating if logging is on or off.
|
boolean | isNewGroup()
Helper method to determine if this is a new group.
|
static void | outputDebug(Object doc, int groupLevel, String str) |
int | parseChar(int nextChar)
Process the character and send it to the current destination. |
int | parseCtrlWord(PushbackInputStream reader)
Parses a keyword and it's parameter if one exists |
void | removeListener(EventListener listener)
Removes a EventListener from the RtfCtrlWordMgr .
|
boolean | setCurrentDestination(String destination)
Set the current destination object for the current state. |
boolean | setExtendedDestination(boolean value)
Helper method to set the extended control word flag. |
void | setLogAppend(boolean logAppend) |
void | setLogFile(String logFile)
Set the logFile name
|
void | setLogFile(String logFile, boolean logAppend)
Set the logFile name
|
void | setLogging(boolean logging)
Set flag indicating if logging is on or off |
boolean | setNewGroup(boolean value)
Helper method to set the new group flag |
int | setParserState(int newState)
Set the state value of the parser.
|
void | setTokeniserSkipBytes(long numberOfBytesToSkip)
Sets the number of bytes to skip and the state of the tokeniser.
|
int | setTokeniserState(int value)
Set the current state of the tokeniser. |
void | setTokeniserStateBinary(int binaryCount)
Sets the number of binary bytes.
|
void | setTokeniserStateBinary(long binaryCount)
Sets the number of binary bytes.
|
void | setTokeniserStateNormal()
Set the tokeniser state to skip to the end of the group.
|
void | setTokeniserStateSkipGroup()
Set the tokeniser state to skip to the end of the group.
|
void | tokenise()
Read through the input file and parse the data stream into tokens.
|
ctrlWordCount
should equal
ctrlWrodHandlecCount
+ ctrlWordNotHandledCount
ctrlWordSkippedCountRtfCtrlWordListener
.EventListener
to the RtfCtrlWordMgr
.
Parameters: listener the new EventListener.
Parameters: readerIn The Reader to read the RTF file from. doc The iText document that the RTF file is to be added to.
Throws: IOException On I/O errors.
Returns: The type of the conversion. Import or Convert.
Returns: The current state destination
Parameters: destination The string destination.
Returns: The destination object from the map
Returns: Returns the object rtfDoc.
Returns: true if it was a \* control word, otherwise false
Returns: Returns the object importHeader.
Returns: The current group level value.
Returns: the logFile
Returns: The current state of the parser.
Returns: Returns the object rtfDoc.
Returns: The current RtfParserState state object.
Returns: The current state of the tokeniser.
Parameters: nextChar The text token to handle.
Returns: errOK if ok, other if an error occurred.
Returns: errOK if ok, other if an error occurred.
Parameters: ctrlWordData The control word to handle.
Returns: errOK if ok, other if an error occurred.
Parameters: importMappings The RtfImportMappings to import.
Returns: errOK if ok, other if an error occurred.
Parameters: readerIn The Reader to read the RTF document from. rtfDoc The RtfDocument to add the imported document to.
Throws: IOException On I/O errors.
Parameters: readerIn The Reader to read the RTF fragment from. rtfDoc The RTF document to add the RTF fragment to. importMappings The RtfImportMappings defining font and color mappings for the fragment.
Throws: IOException On I/O errors.
Parameters: type Type of conversion or import rtfDoc The RtfDocument
readerIn The input stream doc The iText Document
Parameters: readerIn The Reader object for the input file.
Returns: PushbackReader object
Returns: true if TYPE_CONVERT, otherwise false
See Also: TYPE_CONVERT
Returns: true if TYPE_CONVERT, otherwise false
See Also: TYPE_IMPORT_FULL TYPE_IMPORT_FRAGMENT
Returns: true if TYPE_CONVERT, otherwise false
See Also: TYPE_IMPORT_FRAGMENT
Returns: true if TYPE_CONVERT, otherwise false
See Also: TYPE_IMPORT_FULL
Returns: the logAppend
Returns: the logging
Returns: true if this is a new group, otherwise it returns false.
Parameters: nextChar The character to process
Returns: Returns an error code or errOK if no error.
Parameters: reader This is a pushback reader for file input.
Returns: Returns an error code or errOK if no error.
Throws: IOException Catch any file read problem.
EventListener
from the RtfCtrlWordMgr
.
Parameters: listener the EventListener that has to be removed.
Parameters: destination The destination value to set.
Parameters: value Boolean to set the value to.
Returns: isExtendedDestination.
Parameters: logAppend the logAppend to set
Parameters: logFile the logFile to set
Parameters: logFile the logFile to set
Parameters: logging true
to turn on logging, false
to turn off logging.
Parameters: value The boolean value to set the flag
Returns: The value of newGroup
Parameters: newState The new state for the parser
Returns: The state of the parser.
Parameters: numberOfBytesToSkip The numbere of bytes to skip in the file.
Parameters: value The new state of the tokeniser.
Returns: The state of the tokeniser.
Parameters: binaryCount The number of binary bytes.
Parameters: binaryCount The number of binary bytes.
Throws: IOException on IO error.