public class RegexWriter extends Writer
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.
Constructor and Description |
---|
RegexWriter(Regex r,
Writer w) |
RegexWriter(Transformer t,
Writer w) |
Modifier and Type | Method and Description |
---|---|
char |
charAt(int i)
The character at location i in the StringBuffer.
|
void |
close()
This method closes the stream.
|
void |
flush()
This method forces any data that may have been buffered to be written
to the underlying output device.
|
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(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)
This method writes
len char from the specified array
buf starting at index offset into the array. |
public RegexWriter(Transformer t, Writer w)
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 IOException
Writer
len
char from the specified array
buf
starting at index offset
into the array.
Subclasses must provide an implementation of this abstract method.
write
in class Writer
ca
- The array of char to write fromb
- The index into the array to start writing fromn
- The number of char to writeIOException
- If an error occurspublic void flush() throws IOException
Writer
flush
in class Writer
IOException
- If an error occurspublic void close() throws IOException
Writer
This method in this class does nothing.
close
in class Writer
IOException
- If an error occurspublic int length()
public char charAt(int i)
public void setInterval(int i)
public int getInterval()
public int getBufferSize()
public void setBufferSize(int i)