|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.Reader
java.io.FilterReader
org.apache.sling.scripting.javascript.io.EspReader
public class EspReader
The 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.
| Field Summary | |
|---|---|
static String |
DEFAULT_OUT_INIT_STATEMENT
Javascript statement that sets the "out" variable that's used to output data. |
| Fields inherited from class java.io.FilterReader |
|---|
in |
| Fields inherited from class java.io.Reader |
|---|
lock |
| Constructor Summary | |
|---|---|
EspReader(Reader baseReader)
Create an EspReader on top of the given baseReader. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.io.Reader |
|---|
read |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_OUT_INIT_STATEMENT
| Constructor Detail |
|---|
public EspReader(Reader baseReader)
baseReader. The
constructor wraps the input reader with a PushbackReader,
so that input stream modifications may be handled transparently by our
doRead() method.
| Method Detail |
|---|
public void setOutInitStatement(String statement)
public boolean ready()
throws IOException
ready in class FilterReadertrue if a character is available on the
PushbackReader.
IOException - if the reader is not open
public int read()
throws IOException
read in class FilterReaderIOException - if the reader is not open
public int read(char[] cbuf)
throws IOException
read(cbuf, 0, cbuf.length).
read in class Readercbuf - The character buffer to fill with (filtered) characters
IOException - if the reader is not open
public 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 buffer
IOException - if the reader is not open
IndexOutOfBoundsException - 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 skip
IllegalArgumentException - if n is negative
IOException - if the reading the characters throws
public void close()
throws IOException
close in interface Closeableclose in class FilterReaderIOException
public void mark(int readAheadLimit)
throws IOException
mark for
class EspReader always throws an throwable.
mark in class FilterReaderreadAheadLimit - The number of characters to read ahead
IOException - Always, since mark is not supportedpublic boolean markSupported()
markSupported in class FilterReader
public void reset()
throws IOException
reset method of
EspReader always throws an throwable.
reset in class FilterReaderIOException - Always, since reset is not supported
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||