Methods Summary |
---|
public void | readFromReader(java.io.Reader in)
char buf[];
int count;
buf = new char[2048];
while(true) {
count = in.read(buf);
if (count < 0)
break;
for (int i = 0; i < count; i++) {
this.write(buf[i]);
}
}
|
public void | readFromStream(java.io.InputStream in)A convenience method that reads text from a FileInputStream
and writes it to the receiver.
The format in which the file
is read is determined by the concrete subclass of
AbstractFilter to which this method is sent.
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.
int i;
noSpecialsTable = new boolean[256];
for (i = 0; i < 256; i++)
noSpecialsTable[i] = false;
allSpecialsTable = new boolean[256];
for (i = 0; i < 256; i++)
allSpecialsTable[i] = true;
latin1TranslationTable = new char[256];
for (i = 0; i < 256; i++)
latin1TranslationTable[i] = (char)i;
byte buf[];
int count;
buf = new byte[16384];
while(true) {
count = in.read(buf);
if (count < 0)
break;
this.write(buf, 0, count);
}
|
public void | write(int b)Implements the abstract method of OutputStream, of which this class
is a subclass.
if (b < 0)
b += 256;
if (specialsTable[b])
writeSpecial(b);
else {
char ch = translationTable[b];
if (ch != (char)0)
write(ch);
}
|
public void | write(byte[] buf, int off, int len)Implements the buffer-at-a-time write method for greater
efficiency.
PENDING: Does write(byte[])
call write(byte[], int, int) or is it the other way
around?
StringBuffer accumulator = null;
while (len > 0) {
short b = (short)buf[off];
// stupid signed bytes
if (b < 0)
b += 256;
if (specialsTable[b]) {
if (accumulator != null) {
write(accumulator.toString());
accumulator = null;
}
writeSpecial(b);
} else {
char ch = translationTable[b];
if (ch != (char)0) {
if (accumulator == null)
accumulator = new StringBuffer();
accumulator.append(ch);
}
}
len --;
off ++;
}
if (accumulator != null)
write(accumulator.toString());
|
public void | write(java.lang.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) .
int index, length;
length = s.length();
for(index = 0; index < length; index ++) {
write(s.charAt(index));
}
|
protected abstract void | write(char ch)Subclasses must provide an implementation of this method which
accepts a single (non-special) character.
|
protected abstract void | writeSpecial(int b)Subclasses must provide an implementation of this method which
accepts a single special byte. No translation is performed
on specials.
|