|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream javax.swing.text.rtf.AbstractFilter javax.swing.text.rtf.RTFParser
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 RTFFilter, a subclass of this class that knows what to do with the tokens this class parses.
AbstractFilter
,
RTFFilter
Field Summary | |
(package private) static boolean[] |
allSpecialsTable
A specials table which indicates that all characters are special |
(package private) ByteArrayOutputStream |
binaryBuf
|
private long |
binaryBytesLeft
|
private StringBuffer |
currentCharacters
|
(package private) static char[] |
latin1TranslationTable
A translation table which does ISO Latin-1 (trivial) |
int |
level
The current RTF group nesting level. |
(package private) static boolean[] |
noSpecialsTable
A specials table which indicates that no characters are special |
private int |
pendingCharacter
|
private String |
pendingKeyword
|
(package private) static boolean[] |
rtfSpecialsTable
|
private int |
S_aftertick
|
private int |
S_aftertickc
|
private int |
S_backslashed
|
private int |
S_inblob
|
private int |
S_parameter
|
private int |
S_text
|
private int |
S_token
|
private boolean[] |
savedSpecials
|
protected boolean[] |
specialsTable
A table indicating which byte values should be interpreted as characters and which should be treated as formatting codes |
private int |
state
|
protected char[] |
translationTable
A table mapping bytes to characters |
protected PrintStream |
warnings
A stream to which to write warnings and debugging information while parsing. |
Constructor Summary | |
RTFParser()
|
Method Summary | |
abstract void |
begingroup()
Implemented by subclasses to react to an increase in the nesting level. |
void |
close()
Closes the parser. |
abstract void |
endgroup()
Implemented by subclasses to react to the end of a group. |
void |
flush()
Flushes any buffered but not yet written characters. |
abstract void |
handleBinaryBlob(byte[] data)
Implemented by subclasses to handle the contents of the \bin keyword. |
abstract boolean |
handleKeyword(String keyword)
Implemented by subclasses to interpret a parameter-less RTF keyword. |
abstract boolean |
handleKeyword(String keyword,
int parameter)
Implemented by subclasses to interpret a keyword with a parameter. |
void |
handleText(char ch)
|
abstract void |
handleText(String text)
Implemented by subclasses to interpret text from the RTF stream. |
void |
readFromReader(Reader in)
|
void |
readFromStream(InputStream in)
A convenience method that reads text from a FileInputStream and writes it to the receiver. |
protected void |
warning(String s)
|
void |
write(byte[] buf,
int off,
int len)
Implements the buffer-at-a-time write method for greater efficiency. |
void |
write(char ch)
Subclasses must provide an implementation of this method which accepts a single (non-special) character. |
void |
write(int b)
Implements the abstract method of OutputStream, of which this class is a subclass. |
void |
write(String s)
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) . |
void |
writeSpecial(int b)
Subclasses must provide an implementation of this method which accepts a single special byte. |
Methods inherited from class java.io.OutputStream |
write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public int level
private int state
private StringBuffer currentCharacters
private String pendingKeyword
private int pendingCharacter
private long binaryBytesLeft
ByteArrayOutputStream binaryBuf
private boolean[] savedSpecials
protected PrintStream warnings
System.out
to log
any anomalous information to stdout.
private final int S_text
private final int S_backslashed
private final int S_token
private final int S_parameter
private final int S_aftertick
private final int S_aftertickc
private final int S_inblob
static final boolean[] rtfSpecialsTable
protected char[] translationTable
protected boolean[] specialsTable
static final char[] latin1TranslationTable
static final boolean[] noSpecialsTable
static final boolean[] allSpecialsTable
Constructor Detail |
public RTFParser()
Method Detail |
public abstract boolean handleKeyword(String keyword)
public abstract boolean handleKeyword(String keyword, int parameter)
keyword
- The keyword, as with handleKeyword(String)
.parameter
- The parameter following the keyword.public abstract void handleText(String text)
public void handleText(char ch)
public abstract void handleBinaryBlob(byte[] data)
public abstract void begingroup()
public abstract void endgroup()
public void writeSpecial(int b) throws IOException
AbstractFilter
writeSpecial
in class AbstractFilter
b
- The byte written to the OutputStream.
IOException
protected void warning(String s)
public void write(String s) throws IOException
AbstractFilter
write(char)
.
write
in class AbstractFilter
s
- The string of non-special characters written to the
OutputStream.
IOException
public void write(char ch) throws IOException
AbstractFilter
write
in class AbstractFilter
ch
- The character written to the OutputStream.
IOException
public void flush() throws IOException
flush
in class OutputStream
IOException
- if an I/O error occurs.public void close() throws IOException
flush()
,
followed by some minimal consistency checks.
close
in class OutputStream
IOException
- if an I/O error occurs.public void readFromStream(InputStream in) throws IOException
This method does not close the receiver after reaching EOF on
the input stream.
The user must call close()
to ensure that all
data are processed.
in
- An InputStream providing text.
IOException
public void readFromReader(Reader in) throws IOException
IOException
public void write(int b) throws IOException
write
in class OutputStream
b
- the byte
.
IOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
output stream has been closed.public void write(byte[] buf, int off, int len) throws IOException
PENDING: Does write(byte[])
call write(byte[], int, int)
or is it the other way
around?
write
in class OutputStream
buf
- the data.off
- the start offset in the data.len
- the number of bytes to write.
IOException
- if an I/O error occurs. In particular,
an IOException
is thrown if the output
stream is closed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |