APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.text.rtf

pack-priv Class RTFReader

extends RTFParser
Class Inheritance
Imports
java.awt.Color, java.io.BufferedReader, .IOException, .InputStream, .InputStreamReader, .OutputStream, .StreamTokenizer, java.nio.ByteBuffer, .CharBuffer, java.nio.charset.Charset, .CharsetDecoder, .CodingErrorAction, java.util.Dictionary, .Enumeration, .HashMap, .HashSet, .Hashtable, .Map, .Set, .Vector, javax.swing.text.AttributeSet, .BadLocationException, .MutableAttributeSet, .SimpleAttributeSet, .Style, .StyleConstants, .StyleContext, .StyledDocument, .TabStop

Takes a sequence of RTF tokens and text and appends the text described by the RTF to a StyledDocument (the target). The RTF is lexed from the character stream by the RTFParser which is this class's superclass. This class is an indirect subclass of OutputStream. It must be closed in order to guarantee that all of the text has been sent to the text acceptor.
See Also
RTFParser, java.io.OutputStream

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv abstract class
RTFReader.AttributeTrackingDestination

RTFReader.TextHandlingDestination is an abstract RTF destination which simply tracks the attributes specified by the RTF control words in internal form and can produce acceptable AttributeSets for the current character, paragraph, and section attributes.

pack-priv class
RTFReader.ColortblDestination

Reads the colortbl group.

pack-priv static interface
RTFReader.Destination

An interface (could be an entirely abstract class) describing a destination.

pack-priv static class
RTFReader.DiscardingDestination

This data-sink class is used to implement ignored destinations (e.g. {\*\blegga blah blah blah} ) It accepts all keywords and text but does nothing with them.

pack-priv class
RTFReader.DocumentDestination

RTFReader.DocumentDestination is a concrete subclass of TextHandlingDestination which appends the text to the StyledDocument given by the target ivar of the containing RTFReader.

pack-priv class
RTFReader.FonttblDestination

Reads the fonttbl group, inserting fonts into the RTFReader's fontTable dictionary.

pack-priv static class
RTFReader.InfoDestination

Handles the info group.

pack-priv class
RTFReader.StylesheetDestination

Handles the stylesheet keyword.

pack-priv abstract class
RTFReader.TextHandlingDestination

RTFReader.TextHandlingDestination provides basic text handling functionality.

Field Summary

Modifier and TypeField and Description
private static final int
ANSI_CHARSET

Windows font charset

private static final int
private static final int
pack-priv static Dictionary<String, char[]>
pack-priv Map<Integer, Style>
characterStyles

This Map maps character style numbers to Style objects.

private static final int
pack-priv Color[]
colorTable

This array maps color indices to Color objects.

private static final int
pack-priv MutableAttributeSet
documentAttributes

This holds the current document attributes.

private static final int
pack-priv Dictionary<Integer, Charset>
fcharsetTable

This Dictionary maps Integer font numbers to Charset font charset.

pack-priv static Dictionary<String, String>
fcharsetToCP

This Dictionary maps String font charset to String code page.

pack-priv Dictionary<Integer, String>
fontTable

This Dictionary maps Integer font numbers to String font names.

private static final int
private static final int
private static final int
private static final int
pack-priv boolean
ignoreGroupIfUnknownKeyword

true to indicate that if the next keyword is unknown, the containing group should be ignored.

private static final int
private static final int
private MockAttributeSet
private static final int
pack-priv Map<Integer, Style>
paragraphStyles

This Map maps paragraph style numbers to Style objects.

pack-priv Dictionary<Object, Object>
parserState

Miscellaneous information about the parser's state.

private static final String
pack-priv RTFReader.Destination
rtfDestination

This is the "dst" item from parserState.

pack-priv int
rtfversion

This is the RTF version number, extracted from the \rtf keyword.

private static final int
pack-priv Map<Integer, Style>
sectionStyles

This Map maps section style numbers to Style objects.

private static final int
pack-priv int
skippingCharacters

The parameter of the most recently parsed \\ucN keyword, used for skipping alternative representations after a Unicode character.

private static Dictionary<String, RTFAttribute>
private static final int
pack-priv static final String
pack-priv static final String
pack-priv StyledDocument
target

The object to which the parsed text is sent.

pack-priv static Dictionary<String, String>
textKeywords

textKeywords maps RTF keywords to single-character strings, for those keywords which simply insert some text.

private static final int
private static final int
pack-priv static boolean
private static final int
Inherited from javax.swing.text.rtf.RTFParser:
binaryBufdecoderdecoderBBlevelrtfSpecialsTablewarnings

Constructor Summary

AccessConstructor and Description
public
RTFReader(StyledDocument
The TextAcceptor which is to receive the text.
destination
)

Creates a new RTFReader instance.

Method Summary

Modifier and TypeMethod and Description
public void
begingroup()

Implements abstract javax.swing.text.rtf.RTFParser.begingroup.

Called by the superclass when a new RTF group is begun.

public void
close()

Overrides javax.swing.text.rtf.RTFParser.close.

Implements java.io.Closeable.close.

Called by the user when there is no more input (i.e., at the end of the RTF file.)

pack-priv Color
defaultColor()

The default color for text which has no specified color.

public static void
defineCharacterSet(String name, char[] table)

Adds a character set to the RTFReader's list of known character sets

public void
endgroup()

Implements abstract javax.swing.text.rtf.RTFParser.endgroup.

Called by the superclass when the current RTF group is closed.

public static Object

Returns:

the character set
getCharacterSet
(final String name)

Looks up a named character set.

public void
handleBinaryBlob(byte[] data)

Implements abstract javax.swing.text.rtf.RTFParser.handleBinaryBlob.

Called when the RTFParser encounters a bin keyword in the RTF stream.

public boolean

Returns:

true if the keyword is recognized and handled; false otherwise
handleKeyword
(String keyword)

Implements abstract javax.swing.text.rtf.RTFParser.handleKeyword.

Handles a parameterless RTF keyword.

public boolean

Returns:

true if the keyword is recognized and handled; false otherwise
handleKeyword
(String keyword, int parameter)

Implements abstract javax.swing.text.rtf.RTFParser.handleKeyword.

Handles an RTF keyword and its integer parameter.

public void
handleText(String text)

Implements abstract javax.swing.text.rtf.RTFParser.handleText.

Handles any pure text (containing no control characters) in the input stream.

pack-priv static char[]

Returns:

the newly read character set
readCharset
(InputStream strm)

Parses a character set from an InputStream.

pack-priv static char[]
public void
setCharacterSet(String name)

setCharacterSet sets the current translation table to correspond with the named character set.

protected void
private void
Inherited from javax.swing.text.rtf.RTFParser:
flushhandleTextwarningwritewritewriteSpecial