public class EspReader extends FilterReader
EspReader is a FilterReader which takes
JSP like input and produces plain ECMA script output. The filtering
modifications done on the input comprise the following :
The nice thing about this reader is, that the line numbers of the resulting stream match the line numbers of the matching contents of the input stream. Due to the insertion of write() calls, column numbers will not necessarily match, though. This is especially true if you mix ECMA code tags (<% %>) with template text on the same line.
For maximum performance it is advisable to not create the EspReader with a plain FileReader or InputStreamReader but rather with a BufferedReader based on one of the simpler Readers. The reasons for this is, that we call the base reader character by character. This in turn is not too performing if the base reader does not buffer its input.
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_OUT_INIT_STATEMENT
Javascript statement that sets the "out" variable that's used
to output data.
|
in| Constructor and Description |
|---|
EspReader(Reader baseReader)
Create an EspReader on top of the given
baseReader. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the EspReader.
|
void |
mark(int readAheadLimit)
Mark the present position in the stream.
|
boolean |
markSupported()
Tell whether this stream supports the mark() operation, which it does
not.
|
int |
read()
Return the next filtered character.
|
int |
read(char[] cbuf)
Fill the given buffer with filtered or injected characters.
|
int |
read(char[] cbuf,
int off,
int len)
Fill the buffer from the offset with the number of characters given.
|
boolean |
ready()
Check whether we may block at the next read() operation.
|
void |
reset()
Reset the stream.
|
void |
setOutInitStatement(String statement)
Set the code fragment used to initialize the "out" variable
|
long |
skip(long n)
Skip the number of filtered characters.
|
public static final String DEFAULT_OUT_INIT_STATEMENT
public void setOutInitStatement(String statement)
statement - the statement used for initializationpublic boolean ready()
throws IOException
ready in class FilterReadertrue if a character is available on the
PushbackReader.IOException - if the reader is not openpublic int read()
throws IOException
read in class FilterReaderIOException - if the reader is not openpublic int read(char[] cbuf)
throws IOException
read(cbuf, 0, cbuf.length).read in class Readercbuf - The character buffer to fill with (filtered) charactersIOException - if the reader is not openpublic int read(char[] cbuf,
int off,
int len)
throws IOException
read in class FilterReadercbuf - The character buffer to fill with (filtered) charactersoff - Offset from where to start in the bufferlen - The number of characters to fill into the bufferIOException - if the reader is not openIndexOutOfBoundsException - if len is negative, off is negative or
higher than the buffer length or off+len is negative or
beyond the buffer size.public long skip(long n)
throws IOException
skip in class FilterReadern - the number of (filtered) characters to skipIllegalArgumentException - if n is negativeIOException - if the reading the characters throwspublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class FilterReaderIOExceptionpublic void mark(int readAheadLimit)
throws IOException
mark for
class EspReader always throws an throwable.mark in class FilterReaderreadAheadLimit - The number of characters to read aheadIOException - Always, since mark is not supportedpublic boolean markSupported()
markSupported in class FilterReaderpublic void reset()
throws IOException
reset method of
EspReader always throws an throwable.reset in class FilterReaderIOException - Always, since reset is not supportedCopyright © 2017 The Apache Software Foundation. All rights reserved.