|
||||||||||
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
A generic superclass for streams which read and parse text consisting of runs of characters interspersed with occasional ``specials'' (formatting characters).
Most of the functionality
of this class would be redundant except that the
ByteToChar
converters
are suddenly private API. Presumably this class will disappear
when the API is made public again. (sigh) That will also let us handle
multibyte character sets...
A subclass should override at least write(char)
and writeSpecial(int)
. For efficiency's sake it's a
good idea to override write(String)
as well. The subclass'
initializer may also install appropriate translation and specials tables.
OutputStream
Field Summary | |
(package private) static boolean[] |
allSpecialsTable
A specials table which indicates that all characters are special |
(package private) static char[] |
latin1TranslationTable
A translation table which does ISO Latin-1 (trivial) |
(package private) static boolean[] |
noSpecialsTable
A specials table which indicates that no characters are special |
protected boolean[] |
specialsTable
A table indicating which byte values should be interpreted as characters and which should be treated as formatting codes |
protected char[] |
translationTable
A table mapping bytes to characters |
Constructor Summary | |
AbstractFilter()
|
Method Summary | |
void |
readFromReader(Reader in)
|
void |
readFromStream(InputStream in)
A convenience method that reads text from a FileInputStream and writes it to the receiver. |
void |
write(byte[] buf,
int off,
int len)
Implements the buffer-at-a-time write method for greater efficiency. |
protected abstract 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) . |
protected abstract 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 |
close, flush, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected char[] translationTable
protected boolean[] specialsTable
static final char[] latin1TranslationTable
static final boolean[] noSpecialsTable
static final boolean[] allSpecialsTable
Constructor Detail |
public AbstractFilter()
Method Detail |
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.public void write(String s) throws IOException
write(char)
.
s
- The string of non-special characters written to the
OutputStream.
IOException
protected abstract void write(char ch) throws IOException
ch
- The character written to the OutputStream.
IOException
protected abstract void writeSpecial(int b) throws IOException
b
- The byte written to the OutputStream.
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |