Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.lowagie.text.rtf.direct
Class RtfParser

    java.lang.Object
      com.lowagie.text.rtf.direct.RtfParser

    public class RtfParser

extends Object

The RtfParser allows the importing of RTF documents or RTF document fragments. The RTF document or fragment is tokenised, font and color definitions corrected and then added to the document being written.

Version:
  $Revision: 3013 $
Author:
  Mark Hall (mhall@edu.uni-klu.ac.at), Howard Shanks (hgshank@yahoo.com)

Field Summary
`private RtfColorTableParser` | `colorTableParser` The RtfColorTableParser to use for parsing the color table.
`private RtfFontTableParser` | `fontTableParser` The RtfFontTableParser to use for parsing the font table.
`private RtfImportHeader` | `importHeader` The RtfImportHeader to store imported font and color mappings in.
`private static int` | `PARSER_IN_COLOR_TABLE` Currently the RTF color table is being parsed.
`private static int` | `PARSER_IN_DOCUMENT` Currently the RTF document content is being parsed.
`private static int` | `PARSER_IN_FONT_TABLE` Currently the RTF font table is being parsed.
`private static int` | `PARSER_IN_HEADER` Currently the RTF document header is being parsed.
`private static int` | `PARSER_IN_INFO_GROUP` Currently the RTF info group is being parsed.
`private RtfDocument` | `rtfDoc` The RtfDocument to add the RTF document or fragment to.
`private int` | `state` The current parser state.
`private RtfTokeniser` | `tokeniser` The RtfTokeniser to use for tokenising the RTF document or fragment.

Constructor Summary
`RtfParser()`

Method Summary
`void` | `handleCloseGroup(int groupLevel)` Handles close group tokens.
`void` | `handleCtrlCharacter(String ctrlCharacter, int groupLevel)` Handles single control character tokens.
`void` | `handleCtrlWord(String ctrlWord, int groupLevel)` Handles control word tokens.
`private void` | `handleImportMappings(RtfImportMappings importMappings)` Imports the mappings defined in the RtfImportMappings into the RtfImportHeader of this RtfParser.
`void` | `handleOpenGroup(int groupLevel)` Handles open group tokens.
`void` | `handleText(String text, int groupLevel)` Handles text tokens.
`void` | `importRtfDocument(Reader reader, RtfDocument rtfDoc)` Imports a complete RTF document.
`void` | `importRtfFragment(Reader reader, RtfDocument rtfDoc, RtfImportMappings importMappings)` Imports an RTF fragment.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### PARSER_IN_HEADER

    private static final int PARSER_IN_HEADER

  Currently the RTF document header is being parsed.

  See Also:
    Constant Field Values

### PARSER_IN_FONT_TABLE

    private static final int PARSER_IN_FONT_TABLE

  Currently the RTF font table is being parsed.

  See Also:
    Constant Field Values

### PARSER_IN_COLOR_TABLE

    private static final int PARSER_IN_COLOR_TABLE

  Currently the RTF color table is being parsed.

  See Also:
    Constant Field Values

### PARSER_IN_INFO_GROUP

    private static final int PARSER_IN_INFO_GROUP

  Currently the RTF info group is being parsed.

  See Also:
    Constant Field Values

### PARSER_IN_DOCUMENT

    private static final int PARSER_IN_DOCUMENT

  Currently the RTF document content is being parsed.

  See Also:
    Constant Field Values

### rtfDoc

    private RtfDocument rtfDoc

  The RtfDocument to add the RTF document or fragment to.

### tokeniser

    private RtfTokeniser tokeniser

  The RtfTokeniser to use for tokenising the RTF document or fragment.

### importHeader

    private RtfImportHeader importHeader

  The RtfImportHeader to store imported font and color mappings in.

### fontTableParser

    private RtfFontTableParser fontTableParser

  The RtfFontTableParser to use for parsing the font table.

### colorTableParser

    private RtfColorTableParser colorTableParser

  The RtfColorTableParser to use for parsing the color table.

### state

    private int state

  The current parser state.

Constructor Detail

### RtfParser

    public RtfParser()

Method Detail

### importRtfDocument

    public void importRtfDocument(Reader reader,
                                  RtfDocument rtfDoc)
                           throws IOException

  Imports a complete RTF document.

  Parameters:
    `reader` - The Reader to read the RTF document from.
    `rtfDoc` - The RtfDocument to add the imported document to.
  Throws:
    `IOException` - On I/O errors.

### importRtfFragment

    public void importRtfFragment(Reader reader,
                                  RtfDocument rtfDoc,
                                  RtfImportMappings importMappings)
                           throws IOException

  Imports an RTF fragment.

  Parameters:
    `reader` - 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.

### handleImportMappings

    private void handleImportMappings(RtfImportMappings importMappings)

  Imports the mappings defined in the RtfImportMappings into the RtfImportHeader of this RtfParser.

  Parameters:
    `importMappings` - The RtfImportMappings to import.

### handleOpenGroup

    public void handleOpenGroup(int groupLevel)

  Handles open group tokens.

  Parameters:
    `groupLevel` - The current group nesting level.

### handleCloseGroup

    public void handleCloseGroup(int groupLevel)

  Handles close group tokens. Depending on what is currently being parsed the parse state may change.

  Parameters:
    `groupLevel` - The current group nesting level.

### handleCtrlCharacter

    public void handleCtrlCharacter(String ctrlCharacter,
                                    int groupLevel)

  Handles single control character tokens.

  Parameters:
    `ctrlCharacter` - The control character to handle.
    `groupLevel` - The current group nesting level.

### handleCtrlWord

    public void handleCtrlWord(String ctrlWord,
                               int groupLevel)

  Handles control word tokens. Depending on the current state a control word can lead to a state change. When parsing the actual document contents, The font number, color number and background color number are remapped.

  Parameters:
    `ctrlWord` - The control word to handle.
    `groupLevel` - The current group nesting level.

### handleText

    public void handleText(String text,
                           int groupLevel)

  Handles text tokens. These are either handed on to the RtfColorTableParser or RtfFontTableParser or added directly to the document.

  Parameters:
    `text` - The text token to handle.
    `groupLevel` - The current group nesting level.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD