Package org.apache.jasper.compiler
Class JspReader
- java.lang.Object
-
- org.apache.jasper.compiler.JspReader
-
class JspReader extends java.lang.ObjectJspReader is an input buffer for the JSP parser. It should allow unlimited lookahead and pushback. It also has a bunch of parsing utility methods for understanding htmlesque thingies.
-
-
Field Summary
Fields Modifier and Type Field Description private JspCompilationContextcontextprivate Markcurrentprivate intcurrFileIdprivate ErrorDispatchererrprivate static java.util.logging.Loggerlogprivate java.lang.Stringmasterprivate booleansingleFileprivate intsizeprivate java.util.ArrayList<java.lang.String>sourceFiles
-
Constructor Summary
Constructors Constructor Description JspReader(JspCompilationContext ctxt, java.lang.String fname, java.lang.String encoding, java.io.InputStreamReader reader, ErrorDispatcher err)JspReader(JspCompilationContext ctxt, java.lang.String fname, java.lang.String encoding, java.util.jar.JarFile jarFile, ErrorDispatcher err)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) java.lang.StringgetFile(int fileid)(package private) JspCompilationContextgetJspCompilationContext()(package private) java.net.URLgetResource(java.lang.String path)Gets the URL for the given path name.(package private) java.lang.StringgetText(Mark start, Mark stop)(package private) booleanhasMoreInput()private booleanisDelimiter()Parse utils - Is current character a token delimiter ? Delimiters are currently defined to be =, >, <, ", and ' or any any space character as defined byisSpace.(package private) booleanisSpace()(package private) Markmark()(package private) booleanmatches(java.lang.String string)search the stream for a match to a string(package private) booleanmatchesETag(java.lang.String tagName)(package private) booleanmatchesETagWithoutLessThan(java.lang.String tagName)(package private) booleanmatchesIgnoreCase(java.lang.String string)(package private) booleanmatchesOptionalSpacesFollowedBy(java.lang.String s)Looks ahead to see if there are optional spaces followed by the given String.(package private) intnextChar()(package private) java.lang.StringparseToken(boolean quoted)Parse a space delimited token.(package private) intpeekChar()private booleanpopFile()Pop a file from the file stack.(package private) voidpushChar()Back up the current cursor by one char, assumes current.cursor > 0, and that the char to be pushed back is not '\n'.private voidpushFile(java.lang.String file, java.lang.String encoding, java.io.InputStreamReader reader)Push a file (and its associated Stream) on the file stack.private intregisterSourceFile(java.lang.String file)Register a new source file.(package private) voidreset(Mark mark)(package private) voidsetSingleFile(boolean val)(package private) intskipSpaces()(package private) MarkskipUntil(java.lang.String limit)Skip until the given string is matched in the stream.(package private) MarkskipUntilETag(java.lang.String tag)Skip until the given end tag is matched in the stream.(package private) MarkskipUntilIgnoreEsc(java.lang.String limit)Skip until the given string is matched in the stream, but ignoring chars initially escaped by a '\'.private intunregisterSourceFile(java.lang.String file)Unregister the source file.
-
-
-
Field Detail
-
log
private static java.util.logging.Logger log
-
current
private Mark current
-
master
private java.lang.String master
-
sourceFiles
private java.util.ArrayList<java.lang.String> sourceFiles
-
currFileId
private int currFileId
-
size
private int size
-
context
private JspCompilationContext context
-
err
private ErrorDispatcher err
-
singleFile
private boolean singleFile
-
-
Constructor Detail
-
JspReader
public JspReader(JspCompilationContext ctxt, java.lang.String fname, java.lang.String encoding, java.util.jar.JarFile jarFile, ErrorDispatcher err) throws JasperException, java.io.FileNotFoundException, java.io.IOException
- Throws:
JasperExceptionjava.io.FileNotFoundExceptionjava.io.IOException
-
JspReader
public JspReader(JspCompilationContext ctxt, java.lang.String fname, java.lang.String encoding, java.io.InputStreamReader reader, ErrorDispatcher err) throws JasperException, java.io.FileNotFoundException
- Throws:
JasperExceptionjava.io.FileNotFoundException
-
-
Method Detail
-
getJspCompilationContext
JspCompilationContext getJspCompilationContext()
-
getFile
java.lang.String getFile(int fileid)
-
hasMoreInput
boolean hasMoreInput() throws JasperException- Throws:
JasperException
-
nextChar
int nextChar() throws JasperException- Throws:
JasperException
-
pushChar
void pushChar()
Back up the current cursor by one char, assumes current.cursor > 0, and that the char to be pushed back is not '\n'.
-
getText
java.lang.String getText(Mark start, Mark stop) throws JasperException
- Throws:
JasperException
-
peekChar
int peekChar() throws JasperException- Throws:
JasperException
-
mark
Mark mark()
-
reset
void reset(Mark mark)
-
matchesIgnoreCase
boolean matchesIgnoreCase(java.lang.String string) throws JasperException- Throws:
JasperException
-
matches
boolean matches(java.lang.String string) throws JasperExceptionsearch the stream for a match to a string- Parameters:
string- The string to match- Returns:
- true is one is found, the current position in stream is positioned after the search string, false otherwise, position in stream unchanged.
- Throws:
JasperException
-
matchesETag
boolean matchesETag(java.lang.String tagName) throws JasperException- Throws:
JasperException
-
matchesETagWithoutLessThan
boolean matchesETagWithoutLessThan(java.lang.String tagName) throws JasperException- Throws:
JasperException
-
matchesOptionalSpacesFollowedBy
boolean matchesOptionalSpacesFollowedBy(java.lang.String s) throws JasperExceptionLooks ahead to see if there are optional spaces followed by the given String. If so, true is returned and those spaces and characters are skipped. If not, false is returned and the position is restored to where we were before.- Throws:
JasperException
-
skipSpaces
int skipSpaces() throws JasperException- Throws:
JasperException
-
skipUntil
Mark skipUntil(java.lang.String limit) throws JasperException
Skip until the given string is matched in the stream. When returned, the context is positioned past the end of the match.- Parameters:
s- The String to match.- Returns:
- A non-null
Markinstance (positioned immediately before the search string) if found, null otherwise. - Throws:
JasperException
-
skipUntilIgnoreEsc
Mark skipUntilIgnoreEsc(java.lang.String limit) throws JasperException
Skip until the given string is matched in the stream, but ignoring chars initially escaped by a '\'. When returned, the context is positioned past the end of the match.- Parameters:
s- The String to match.- Returns:
- A non-null
Markinstance (positioned immediately before the search string) if found, null otherwise. - Throws:
JasperException
-
skipUntilETag
Mark skipUntilETag(java.lang.String tag) throws JasperException
Skip until the given end tag is matched in the stream. When returned, the context is positioned past the end of the tag.- Parameters:
tag- The name of the tag whose ETag () to match.- Returns:
- A non-null
Markinstance (positioned immediately before the ETag) if found, null otherwise. - Throws:
JasperException
-
isSpace
final boolean isSpace() throws JasperException- Throws:
JasperException
-
parseToken
java.lang.String parseToken(boolean quoted) throws JasperExceptionParse a space delimited token. If quoted the token will consume all characters up to a matching quote, otherwise, it consumes up to the first delimiter character.- Parameters:
quoted- If true accept quoted strings.- Throws:
JasperException
-
setSingleFile
void setSingleFile(boolean val)
-
getResource
java.net.URL getResource(java.lang.String path) throws java.net.MalformedURLExceptionGets the URL for the given path name.- Parameters:
path- Path name- Returns:
- URL for the given path name.
- Throws:
java.net.MalformedURLException- if the path name is not given in the correct form
-
isDelimiter
private boolean isDelimiter() throws JasperExceptionParse utils - Is current character a token delimiter ? Delimiters are currently defined to be =, >, <, ", and ' or any any space character as defined byisSpace.- Returns:
- A boolean.
- Throws:
JasperException
-
registerSourceFile
private int registerSourceFile(java.lang.String file)
Register a new source file. This method is used to implement file inclusion. Each included file gets a unique identifier (which is the index in the array of source files).- Returns:
- The index of the now registered file.
-
unregisterSourceFile
private int unregisterSourceFile(java.lang.String file)
Unregister the source file. This method is used to implement file inclusion. Each included file gets a uniq identifier (which is the index in the array of source files).- Returns:
- The index of the now registered file.
-
pushFile
private void pushFile(java.lang.String file, java.lang.String encoding, java.io.InputStreamReader reader) throws JasperException, java.io.FileNotFoundExceptionPush a file (and its associated Stream) on the file stack. THe current position in the current file is remembered.- Throws:
JasperExceptionjava.io.FileNotFoundException
-
popFile
private boolean popFile() throws JasperExceptionPop a file from the file stack. The field "current" is retored to the value to point to the previous files, if any, and is set to null otherwise.- Returns:
- true is there is a previous file on the stck. false otherwise.
- Throws:
JasperException
-
-