Package org.apache.jasper.compiler
Class JspReader
java.lang.Object
org.apache.jasper.compiler.JspReader
JspReader 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
FieldsModifier and TypeFieldDescriptionprivate JspCompilationContext
private Mark
private int
private ErrorDispatcher
private static Logger
private String
private boolean
private int
-
Constructor Summary
ConstructorsConstructorDescriptionJspReader
(JspCompilationContext ctxt, String fname, String encoding, InputStreamReader reader, ErrorDispatcher err) JspReader
(JspCompilationContext ctxt, String fname, String encoding, JarFile jarFile, ErrorDispatcher err) -
Method Summary
Modifier and TypeMethodDescription(package private) String
getFile
(int fileid) (package private) JspCompilationContext
(package private) URL
getResource
(String path) Gets the URL for the given path name.(package private) String
(package private) boolean
private boolean
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) final boolean
isSpace()
(package private) Mark
mark()
(package private) boolean
search the stream for a match to a string(package private) boolean
matchesETag
(String tagName) (package private) boolean
matchesETagWithoutLessThan
(String tagName) (package private) boolean
matchesIgnoreCase
(String string) (package private) boolean
Looks ahead to see if there are optional spaces followed by the given String.(package private) int
nextChar()
(package private) String
parseToken
(boolean quoted) Parse a space delimited token.(package private) int
peekChar()
private boolean
popFile()
Pop a file from the file stack.(package private) 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'.private void
pushFile
(String file, String encoding, InputStreamReader reader) Push a file (and its associated Stream) on the file stack.private int
registerSourceFile
(String file) Register a new source file.(package private) void
(package private) void
setSingleFile
(boolean val) (package private) int
(package private) Mark
Skip until the given string is matched in the stream.(package private) Mark
skipUntilETag
(String tag) Skip until the given end tag is matched in the stream.(package private) Mark
skipUntilIgnoreEsc
(String limit) Skip until the given string is matched in the stream, but ignoring chars initially escaped by a '\'.private int
unregisterSourceFile
(String file) Unregister the source file.
-
Field Details
-
log
-
current
-
master
-
sourceFiles
-
currFileId
private int currFileId -
size
private int size -
context
-
err
-
singleFile
private boolean singleFile
-
-
Constructor Details
-
JspReader
public JspReader(JspCompilationContext ctxt, String fname, String encoding, JarFile jarFile, ErrorDispatcher err) throws JasperException, FileNotFoundException, IOException -
JspReader
public JspReader(JspCompilationContext ctxt, String fname, String encoding, InputStreamReader reader, ErrorDispatcher err) throws JasperException, FileNotFoundException - Throws:
JasperException
FileNotFoundException
-
-
Method Details
-
getJspCompilationContext
JspCompilationContext getJspCompilationContext() -
getFile
-
hasMoreInput
- Throws:
JasperException
-
nextChar
- 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
- Throws:
JasperException
-
peekChar
- Throws:
JasperException
-
mark
Mark mark() -
reset
-
matchesIgnoreCase
- Throws:
JasperException
-
matches
search 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
- Throws:
JasperException
-
matchesETagWithoutLessThan
- Throws:
JasperException
-
matchesOptionalSpacesFollowedBy
Looks 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
- Throws:
JasperException
-
skipUntil
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
Mark
instance (positioned immediately before the search string) if found, null otherwise. - Throws:
JasperException
-
skipUntilIgnoreEsc
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
Mark
instance (positioned immediately before the search string) if found, null otherwise. - Throws:
JasperException
-
skipUntilETag
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
Mark
instance (positioned immediately before the ETag) if found, null otherwise. - Throws:
JasperException
-
isSpace
- Throws:
JasperException
-
parseToken
Parse 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
Gets the URL for the given path name.- Parameters:
path
- Path name- Returns:
- URL for the given path name.
- Throws:
MalformedURLException
- if the path name is not given in the correct form
-
isDelimiter
Parse 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
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
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(String file, String encoding, InputStreamReader reader) throws JasperException, FileNotFoundException Push a file (and its associated Stream) on the file stack. THe current position in the current file is remembered.- Throws:
JasperException
FileNotFoundException
-
popFile
Pop 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
-