|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.InputStream
de.fhg.igd.io.StringSubstitutionInputStream
public class StringSubstitutionInputStream
This is an InputStream wrapper that provides simple
String substitution while reading from it.
After a substitution took place (by performing a look-ahead), the
replacement String will not be processed again, which
means that recursive substitution is not supported. To achieve this,
two nested StringSubstitutionInputStream objects may be used.
| Field Summary | |
|---|---|
protected StringBuffer |
back_
A buffer for chars that need to be checked again |
protected boolean |
closed_
This flag indicates that this stream has been closed |
protected StringBuffer |
done_
A buffer for chars that have been already processed and therefore can be safely returned |
protected InputStream |
is_
The wrapped input stream |
private Object |
lock_
The local lock object |
protected StringBuffer |
read_
A temporary read buffer |
protected Map |
subst_
The substitution map |
| Constructor Summary | |
|---|---|
StringSubstitutionInputStream(InputStream is,
Map subst)
Creates a StringSubstitutionInputStream
wrapping the given InputStream. |
|
| Method Summary | |
|---|---|
int |
available()
|
void |
close()
|
static void |
main(String[] args)
Just for testing purposes... |
protected boolean |
maybeLater()
Check whether or not the internal buffer may become a substitution candidate on further extension. |
int |
read()
|
| Methods inherited from class java.io.InputStream |
|---|
mark, markSupported, read, read, reset, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private Object lock_
protected InputStream is_
protected Map subst_
protected StringBuffer read_
protected StringBuffer back_
protected StringBuffer done_
protected boolean closed_
| Constructor Detail |
|---|
public StringSubstitutionInputStream(InputStream is,
Map subst)
StringSubstitutionInputStream
wrapping the given InputStream.
is - The InputStream to be wrappedsubst - The map of substitutions, each entry contains
a substitutable as key and the corresponding replacement as value
NullPointerException - if the wrapped input stream is
null or if the substitution map contains
null keys/values| Method Detail |
|---|
public int read()
throws IOException
read in class InputStreamIOExceptionprotected boolean maybeLater()
true if the content of the internal buffer may fit
to a substitution key later, if extended appropriatelypublic int available()
available in class InputStream
public void close()
throws IOException
close in interface Closeableclose in class InputStreamIOExceptionpublic static void main(String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||