| 
 | ||||||||||
| 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 java.lang.String | DEFAULT_OUT_INIT_STATEMENTJavascript 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(java.io.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(java.lang.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 java.lang.String DEFAULT_OUT_INIT_STATEMENT
| Constructor Detail | 
|---|
public EspReader(java.io.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(java.lang.String statement)
public boolean ready()
              throws java.io.IOException
ready in class java.io.FilterReadertrue if a character is available on the
         PushbackReader.
java.io.IOException - if the reader is not open
public int read()
         throws java.io.IOException
read in class java.io.FilterReaderjava.io.IOException - if the reader is not open
public int read(char[] cbuf)
         throws java.io.IOException
read(cbuf, 0, cbuf.length).
read in class java.io.Readercbuf - The character buffer to fill with (filtered) characters
java.io.IOException - if the reader is not open
public int read(char[] cbuf,
                int off,
                int len)
         throws java.io.IOException
read in class java.io.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
java.io.IOException - if the reader is not open
java.lang.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 java.io.IOException
skip in class java.io.FilterReadern - the number of (filtered) characters to skip
java.lang.IllegalArgumentException - if n is negative
java.io.IOException - if the reading the characters throws
public void close()
           throws java.io.IOException
close in interface java.io.Closeableclose in class java.io.FilterReaderjava.io.IOException
public void mark(int readAheadLimit)
          throws java.io.IOException
mark for
 class EspReader always throws an throwable.
mark in class java.io.FilterReaderreadAheadLimit - The number of characters to read ahead
java.io.IOException - Always, since mark is not supportedpublic boolean markSupported()
markSupported in class java.io.FilterReader
public void reset()
           throws java.io.IOException
reset method of
 EspReader always throws an throwable.
reset in class java.io.FilterReaderjava.io.IOException - Always, since reset is not supported| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||