APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.jfx.incubator.scene.control.richtext.rtf

public Class RTFReader

extends RTFParser
Class Inheritance
Imports
java.io.BufferedReader, .IOException, .InputStream, .InputStreamReader, .StreamTokenizer, .StringReader, java.nio.charset.Charset, .CodingErrorAction, .StandardCharsets, java.util.ArrayList, .HashMap, .HashSet, .Map, .Set, javafx.scene.paint.Color, javafx.scene.text.TextAlignment, com.sun.jfx.incubator.scene.control.richtext.SegmentStyledInput, jfx.incubator.scene.control.richtext.model.StyleAttributeMap, .StyledInput, .StyledSegment

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.

Nested and Inner Type Summary

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

An abstract RTF destination which simply tracks the attributes specified by the RTF control words in internal form and can produce acceptable attribute sets for the current character, paragraph, and section attributes.

pack-priv class
RTFReader.ColortblDestination

Reads the colortbl group.

pack-priv static class
RTFReader.Destination

The base class for an RTF destination.

pack-priv class
RTFReader.DocumentDestination

This Destination accumulates the styled segments within this reader.

pack-priv class
RTFReader.FonttblDestination

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

pack-priv class
RTFReader.StylesheetDestination

Handles the stylesheet keyword.

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int
private static final HashMap<String, char[]>
private HashMap<Integer, Style>
characterStyles

This Map maps character style numbers to Style objects.

private static final int
private Color[]
colorTable

This array maps color indices to Color objects.

private static final int
private static final String
private AttrSet
documentAttributes

This holds the current document attributes.

private static final int
private HashMap<Integer, Charset>
fcharsetTable

maps Integer font numbers to Charset font charset.

private static HashMap<String, String>
fcharsetToCP

maps String font charset to String code page.

private HashMap<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
private final AttrSet.Holder
private 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 static final int
private HashMap<Integer, Style>
paragraphStyles

This Map maps paragraph style numbers to Style objects.

private HashMap<Object, Object>
parserState

Miscellaneous information about the parser's state.

private static final String
private RTFReader.Destination
rtfDestination

This is the "dst" item from parserState.

private static final int
private HashMap<Integer, Style>
sectionStyles

This Map maps section style numbers to Style objects.

private ArrayList<StyledSegment>
private static final int
private int
skippingCharacters

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

private static final HashMap<String, RTFAttribute>
private static final Object
STYLE_ADDITIVE

Whether the style is additive

private static final Object
STYLE_CHARACTER

Value for StyleType indicating a character style

private static final Object
STYLE_HIDDEN

Whether the style is hidden from the user

private static final Object
STYLE_NEXT

The style of the text following this style

private static final Object
STYLE_PARAGRAPH

Value for StyleType indicating a paragraph style

private static final Object
STYLE_SECTION

Value for StyleType indicating a section style

private static final Object
STYLE_TYPE

Indicates the domain of a Style

private final HashMap<String, Style>
private static final int
private final String
private static final HashMap<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
private static final int
Inherited from com.sun.jfx.incubator.scene.control.richtext.rtf.RTFParser:
binaryBufdecoderdecoderBBlevelrtfSpecialsTable

Constructor Summary

AccessConstructor and Description
public
RTFReader(String
the RTF input string
text
)

Creates a new RTFReader instance.

Method Summary

Modifier and TypeMethod and Description
private Style
addStyle(String nm, Style parent)

public void
begingroup()

Implements abstract com.sun.jfx.incubator.scene.control.richtext.rtf.RTFParser.begingroup.

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

public void
close()

Overrides com.sun.jfx.incubator.scene.control.richtext.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.)

private 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 com.sun.jfx.incubator.scene.control.richtext.rtf.RTFParser.endgroup.

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

public StyledInput

Returns:

the StyledInput
generateStyledInput
()

Processes the RTF input and generates a StyledInput instance.

public static Object

Returns:

the character set
getCharacterSet
(final String name)

Looks up a named character set.

private Style
public void
handleBinaryBlob(byte[] data)

Implements abstract com.sun.jfx.incubator.scene.control.richtext.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 com.sun.jfx.incubator.scene.control.richtext.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 com.sun.jfx.incubator.scene.control.richtext.rtf.RTFParser.handleKeyword.

Handles an RTF keyword and its integer parameter.

public void
handleText(String text)

Implements abstract com.sun.jfx.incubator.scene.control.richtext.rtf.RTFParser.handleText.

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

private static HashMap<String, char[]>
private static HashMap<String, String>
private HashMap<String, Style>
private static HashMap<String, String>
pack-priv static char[]

Returns:

the newly read character set
readCharset
(InputStream strm)

Parses a character set from an InputStream.

public void
setCharacterSet(String name)

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

protected void
Inherited from com.sun.jfx.incubator.scene.control.richtext.rtf.RTFParser:
flushhandleTextwritewritewriteSpecial