public final class VelocityWriter extends java.io.Writer implements Filter
Modifier and Type | Field and Description |
---|---|
private boolean |
autoFlush |
private int |
bufferSize |
private char[] |
cb |
static int |
DEFAULT_BUFFER
constant indicating that the Writer is buffered and is using the
implementation default buffer size
|
private static int |
defaultCharBufferSize |
private int |
nextChar |
static int |
NO_BUFFER
constant indicating that the Writer is not buffering output
|
static int |
UNBOUNDED_BUFFER
constant indicating that the Writer is buffered and is unbounded;
this is used in BodyContent
|
private java.io.Writer |
writer |
Modifier | Constructor and Description |
---|---|
private |
VelocityWriter(int bufferSize,
boolean autoFlush)
private constructor.
|
|
VelocityWriter(java.io.Writer writer)
Create a buffered character-output stream that uses a default-sized
output buffer.
|
|
VelocityWriter(java.io.Writer writer,
int sz,
boolean autoFlush)
Create a new buffered character-output stream that uses an output
buffer of the given size.
|
Modifier and Type | Method and Description |
---|---|
private void |
bufferOverflow() |
void |
clear()
Discard the output buffer.
|
void |
close()
Close the stream.
|
void |
flush()
Flush the stream.
|
private void |
flushBuffer()
Flush the output buffer to the underlying character stream, without
flushing the stream itself.
|
int |
getBufferSize()
This method returns the size of the buffer used by the JspWriter.
|
int |
getRemaining() |
boolean |
isAutoFlush()
This method indicates whether the JspWriter is autoFlushing.
|
private int |
min(int a,
int b)
Our own little min method, to avoid loading
java.lang.Math if we've run out of file
descriptors and we're trying to print a stack trace. |
void |
recycle(java.io.Writer writer)
resets this class so that it can be reused
|
void |
write(char[] buf)
Write an array of characters.
|
void |
write(char[] cbuf,
int off,
int len)
Write a portion of an array of characters.
|
void |
write(int c)
Write a single character.
|
void |
write(java.lang.String s)
Write a string.
|
void |
write(java.lang.String s,
int off,
int len)
Write a portion of a String.
|
void |
writeReference(java.lang.String ref)
Send the content of a reference, e.g.; $foo, to the writer.
|
public static final int NO_BUFFER
public static final int DEFAULT_BUFFER
public static final int UNBOUNDED_BUFFER
private java.io.Writer writer
private int bufferSize
private boolean autoFlush
private char[] cb
private int nextChar
private static int defaultCharBufferSize
public VelocityWriter(java.io.Writer writer)
writer
- Writer to wrap aroundprivate VelocityWriter(int bufferSize, boolean autoFlush)
public VelocityWriter(java.io.Writer writer, int sz, boolean autoFlush)
writer
- Writer to wrap aroundsz
- Output-buffer size, a positive integerautoFlush
- java.lang.IllegalArgumentException
- If sz is <= 0public int getBufferSize()
public boolean isAutoFlush()
private void flushBuffer() throws java.io.IOException
java.io.IOException
public final void clear()
private void bufferOverflow() throws java.io.IOException
java.io.IOException
public final void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.Writer
java.io.IOException
public final void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.Writer
java.io.IOException
public final int getRemaining()
public final void write(int c) throws java.io.IOException
write
in class java.io.Writer
c
- java.io.IOException
private int min(int a, int b)
java.lang.Math
if we've run out of file
descriptors and we're trying to print a stack trace.public final void write(char[] cbuf, int off, int len) throws java.io.IOException
Ordinarily this method stores characters from the given array into
this stream's buffer, flushing the buffer to the underlying stream as
needed. If the requested length is at least as large as the buffer,
however, then this method will flush the buffer and write the characters
directly to the underlying stream. Thus redundant
DiscardableBufferedWriter
s will not copy data unnecessarily.
write
in class java.io.Writer
cbuf
- A character arrayoff
- Offset from which to start reading characterslen
- Number of characters to writejava.io.IOException
public final void write(char[] buf) throws java.io.IOException
write
in class java.io.Writer
buf
- java.io.IOException
public final void write(java.lang.String s, int off, int len) throws java.io.IOException
write
in class java.io.Writer
s
- String to be writtenoff
- Offset from which to start reading characterslen
- Number of characters to be writtenjava.io.IOException
public final void write(java.lang.String s) throws java.io.IOException
write
in class java.io.Writer
s
- java.io.IOException
public final void recycle(java.io.Writer writer)
writer
- public void writeReference(java.lang.String ref) throws java.io.IOException
writeReference
in interface Filter
java.io.IOException