Top Description Fields Constructors Methods
com.sun.jfx.incubator.scene.control.richtext.rtf

pack-priv abstract Class RTFParser

extends AbstractFilter
Class Inheritance
Known Direct Subclasses
com.sun.jfx.incubator.scene.control.richtext.rtf.RTFReader
Imports
java.io.ByteArrayOutputStream, .IOException

RTFParser is a subclass of AbstractFilter which understands basic RTF syntax and passes a stream of control words, text, and begin/end group indications to its subclass. Normally programmers will only use RTFReader, a subclass of this class that knows what to do with the tokens this class parses.
See Also
AbstractFilter, RTFReader

Field Summary

Modifier and TypeField and Description
pack-priv ByteArrayOutputStream
private long
private StringBuffer
public int
level

The current RTF group nesting level.

private int
private String
pack-priv static final boolean[]
private final int
private final int
private final int
private final int
private final int
private final int
private final int
private boolean[]
private int
Inherited from com.sun.jfx.incubator.scene.control.richtext.rtf.AbstractFilter:
allSpecialsTablelatin1TranslationTablenoSpecialsTablespecialsTabletranslationTable

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract void
begingroup()

Implemented by subclasses to react to an increase in the nesting level.

public void
close()

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Closes the parser.

public abstract void
endgroup()

Implemented by subclasses to react to the end of a group.

public void
flush()

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Flushes any buffered but not yet written characters.

public abstract void
handleBinaryBlob(byte[] data)

Implemented by subclasses to handle the contents of the \bin keyword.

public abstract boolean
handleKeyword(String keyword)

Implemented by subclasses to interpret a parameter-less RTF keyword.

public abstract boolean
handleKeyword(String
The keyword, as with handleKeyword(String).
keyword
,
int
The parameter following the keyword.
parameter
)

Implemented by subclasses to interpret a keyword with a parameter.

public abstract void
handleText(String text)

Implemented by subclasses to interpret text from the RTF stream.

public void
handleText(char ch)

public void
write(String
The string of non-special characters written to the OutputStream.
s
)

Overrides com.sun.jfx.incubator.scene.control.richtext.rtf.AbstractFilter.write.

Hopefully, all subclasses will override this method to accept strings of text, but if they don't, AbstractFilter's implementation will spoon-feed them via write(char).

public void
write(char
The character written to the OutputStream.
ch
)

Implements abstract com.sun.jfx.incubator.scene.control.richtext.rtf.AbstractFilter.write.

Subclasses must provide an implementation of this method which accepts a single (non-special) character.

public void
writeSpecial(int
The byte written to the OutputStream.
b
)

Implements abstract com.sun.jfx.incubator.scene.control.richtext.rtf.AbstractFilter.writeSpecial.

Subclasses must provide an implementation of this method which accepts a single special byte.

Inherited from com.sun.jfx.incubator.scene.control.richtext.rtf.AbstractFilter:
readFromReaderreadFromStreamwritewrite

Field Detail

binaryBufback to summary
pack-priv ByteArrayOutputStream binaryBuf
binaryBytesLeftback to summary
private long binaryBytesLeft
currentCharactersback to summary
private StringBuffer currentCharacters
levelback to summary
public int level

The current RTF group nesting level.

pendingCharacterback to summary
private int pendingCharacter
pendingKeywordback to summary
private String pendingKeyword
rtfSpecialsTableback to summary
pack-priv static final boolean[] rtfSpecialsTable
S_aftertickback to summary
private final int S_aftertick
S_aftertickcback to summary
private final int S_aftertickc
S_backslashedback to summary
private final int S_backslashed
S_inblobback to summary
private final int S_inblob
S_parameterback to summary
private final int S_parameter
S_textback to summary
private final int S_text
S_tokenback to summary
private final int S_token
savedSpecialsback to summary
private boolean[] savedSpecials
stateback to summary
private int state

Constructor Detail

RTFParserback to summary
public RTFParser()

Method Detail

begingroupback to summary
public abstract void begingroup()

Implemented by subclasses to react to an increase in the nesting level.

closeback to summary
public void close() throws IOException

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Closes the parser. Currently, this simply does a flush(), followed by some minimal consistency checks.

Annotations
@Override
Exceptions
IOException:

Doc from java.io.OutputStream.close.

if an I/O error occurs.

endgroupback to summary
public abstract void endgroup()

Implemented by subclasses to react to the end of a group.

flushback to summary
public void flush() throws IOException

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Flushes any buffered but not yet written characters. Subclasses which override this method should call this method before flushing any of their own buffers.

Annotations
@Override
Exceptions
IOException:

Doc from java.io.OutputStream.flush.

if an I/O error occurs.

handleBinaryBlobback to summary
public abstract void handleBinaryBlob(byte[] data)

Implemented by subclasses to handle the contents of the \bin keyword.

handleKeywordback to summary
public abstract boolean handleKeyword(String keyword)

Implemented by subclasses to interpret a parameter-less RTF keyword. The keyword is passed without the leading '/' or any delimiting whitespace.

handleKeywordback to summary
public abstract boolean handleKeyword(String keyword, int parameter)

Implemented by subclasses to interpret a keyword with a parameter.

Parameters
keyword:String

The keyword, as with handleKeyword(String).

parameter:int

The parameter following the keyword.

handleTextback to summary
public abstract void handleText(String text)

Implemented by subclasses to interpret text from the RTF stream.

handleTextback to summary
public void handleText(char ch)
writeback to summary
public void write(String s) throws IOException

Overrides com.sun.jfx.incubator.scene.control.richtext.rtf.AbstractFilter.write.

Doc from com.sun.jfx.incubator.scene.control.richtext.rtf.AbstractFilter.write.

Hopefully, all subclasses will override this method to accept strings of text, but if they don't, AbstractFilter's implementation will spoon-feed them via write(char).

Parameters
s:String

The string of non-special characters written to the OutputStream.

Annotations
@Override
writeback to summary
public void write(char ch) throws IOException

Implements abstract com.sun.jfx.incubator.scene.control.richtext.rtf.AbstractFilter.write.

Doc from com.sun.jfx.incubator.scene.control.richtext.rtf.AbstractFilter.write.

Subclasses must provide an implementation of this method which accepts a single (non-special) character.

Parameters
ch:char

The character written to the OutputStream.

Annotations
@Override
@SuppressWarnings:fallthrough
writeSpecialback to summary
public void writeSpecial(int b) throws IOException

Implements abstract com.sun.jfx.incubator.scene.control.richtext.rtf.AbstractFilter.writeSpecial.

Doc from com.sun.jfx.incubator.scene.control.richtext.rtf.AbstractFilter.writeSpecial.

Subclasses must provide an implementation of this method which accepts a single special byte. No translation is performed on specials.

Parameters
b:int

The byte written to the OutputStream.

Annotations
@Override