|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.io.Writer
|
+--com.stevesoft.pat.RegexWriter
A basic extension of FilterWriter that uses Transformer to make replacements in data as it is written out. It attempts to transform a string whenever the End-of-Line (EOL) character is written (which is, by default, the carriage return '\n'). Only the transformed portion of the line is written out, allowing the RegexWriter to wait until a complete pattern is present before attempting to write out info. Until a pattern completes, data is stored in a StringBuffer -- which can be accessed through the length() and charAt() methods of this class.
Note a subtlety here -- while a Transformer normally matches at higher priority against the pattern added to it first, this will not necessarily be true when a multi-line match is in progress because one of the complete multi-line patterns may not be completely loaded in RegexWriter's buffer. For this reason, the Transformer class is equipped with a way to add a pattern and replacement rule in three pieces -- a beginning (once this matches, nothing else in the Transformer can match until the whole pattern matches), an ending (the whole pattern is a String formed by adding the beginning and ending), and a ReplaceRule.
An illustration of this is given in the this example.
| Fields inherited from class java.io.Writer |
lock |
| Constructor Summary | |
RegexWriter(Regex r,
java.io.Writer w)
|
|
RegexWriter(Transformer t,
java.io.Writer w)
|
|
| Method Summary | |
char |
charAt(int i)
The character at location i in the StringBuffer. |
void |
close()
|
void |
flush()
|
int |
getBufferSize()
Get the buffer size. |
char |
getEOLchar()
Deprecated. |
int |
getInterval()
Get the interval at which regex matches are checked. |
int |
getMaxLines()
Deprecated. |
int |
length()
The current size of the StringBuffer in use by RegexWriter. |
static void |
main(java.lang.String[] args)
|
void |
setBufferSize(int i)
Set the buffer size. |
void |
setEOLchar(char c)
Deprecated. |
void |
setInterval(int i)
Set the interval at which regex patterns are checked. |
void |
setMaxLines(int ml)
Deprecated. |
void |
write(char[] ca,
int b,
int n)
|
| Methods inherited from class java.io.Writer |
write,
write,
write,
write |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public RegexWriter(Transformer t,
java.io.Writer w)
public RegexWriter(Regex r,
java.io.Writer w)
| Method Detail |
public char getEOLchar()
public void setEOLchar(char c)
public int getMaxLines()
public void setMaxLines(int ml)
public void write(char[] ca,
int b,
int n)
throws java.io.IOException
public void flush()
throws java.io.IOException
public void close()
throws java.io.IOException
public int length()
public char charAt(int i)
public void setInterval(int i)
public int getInterval()
public int getBufferSize()
public void setBufferSize(int i)
public static void main(java.lang.String[] args)
throws java.lang.Exception
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||