JSPTemplates

org.tp23.jasper.compiler
Class JspReader

java.lang.Object
  |
  +--org.tp23.jasper.compiler.JspReader

public class JspReader
extends java.lang.Object

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.

Author:
Anil K. Vijendran, Anselm Baird-Smith, Harish Prabandham, Rajiv Mordani, Mandar Raje, Paul Hinds

Field Summary
protected  Mark current
           
 
Constructor Summary
protected JspReader(java.lang.String file, JspCompilationContext ctx, java.lang.String encoding)
           
 
Method Summary
 void advance(int n)
           
static JspReader createJspReader(java.lang.String file, JspCompilationContext ctx, java.lang.String encoding)
           
 java.lang.String getFile(int fileid)
           
 boolean hasMoreInput()
           
 Mark mark()
           
 boolean matches(java.lang.String string)
           
 boolean matchesIgnoreCase(java.lang.String string)
           
 int nextChar()
           
 void parseParamTag(java.util.Hashtable into)
          Parse PARAM tag attributes into the given hashtable.
 void parsePluginParamTag(java.util.Hashtable into)
          Parse jsp:param tag attributes into the given hashtable.
 java.util.Hashtable parseTagAttributes()
          Parse some tag attributes.
 java.util.Hashtable parseTagAttributesBean()
          Parse some tag attributes for Beans.
 java.lang.String parseToken(boolean quoted)
          Parse a space delimited token.
 int peekChar()
           
 boolean popFile()
           
 void pushFile(java.lang.String name, java.lang.String encoding)
          Push a new file onto the stack.
protected  int registerSourceFile(java.lang.String file)
          Register a new source file.
 void reset(Mark mark)
           
 int skipSpaces()
           
 Mark skipUntil(java.lang.String limit)
          Skip until the given string is matched in the stream.
protected  int unregisterSourceFile(java.lang.String file)
          Unregister the source file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

current

protected Mark current
Constructor Detail

JspReader

protected JspReader(java.lang.String file,
                    JspCompilationContext ctx,
                    java.lang.String encoding)
             throws ParseException,
                    java.io.FileNotFoundException
Method Detail

getFile

public java.lang.String getFile(int fileid)

registerSourceFile

protected int registerSourceFile(java.lang.String file)
Register a new 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.

unregisterSourceFile

protected 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

public void pushFile(java.lang.String name,
                     java.lang.String encoding)
              throws ParseException,
                     java.io.FileNotFoundException
Push a new file onto the stack. The name of the file is resolved to a fully qualified filename.
Parameters:
name - The name of the file.
encoding - The optional encoding for the file.

popFile

public boolean popFile()
                throws ParseException

createJspReader

public static JspReader createJspReader(java.lang.String file,
                                        JspCompilationContext ctx,
                                        java.lang.String encoding)
                                 throws ParseException,
                                        java.io.FileNotFoundException

hasMoreInput

public boolean hasMoreInput()
                     throws ParseException

nextChar

public int nextChar()
             throws ParseException

peekChar

public int peekChar()

mark

public Mark mark()

reset

public void reset(Mark mark)

matchesIgnoreCase

public boolean matchesIgnoreCase(java.lang.String string)
                          throws ParseException

matches

public boolean matches(java.lang.String string)
                throws ParseException

advance

public void advance(int n)
             throws ParseException

skipSpaces

public int skipSpaces()
               throws ParseException

skipUntil

public Mark skipUntil(java.lang.String limit)
               throws ParseException
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 if found, null otherwise.

parseToken

public java.lang.String parseToken(boolean quoted)
                            throws ParseException
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.

parseTagAttributesBean

public java.util.Hashtable parseTagAttributesBean()
                                           throws ParseException
Parse some tag attributes for Beans. The stream is assumed to be positioned right after the tag name. The syntax recognized is:
 tag-attrs := empty | attr-list (">" | "-->" | %>)
 attr-list := empty | av spaces attr-list
 empty     := spaces
 
Where av is defined by parseAttributeValue.
Returns:
A Hashtable mapping String instances (variable names) into String instances (variable values).

parseTagAttributes

public java.util.Hashtable parseTagAttributes()
                                       throws ParseException
Parse some tag attributes. The stream is assumed to be positioned right after the tag name. The syntax recognized is:
 tag-attrs := empty | attr-list (">" | "-->" | %>)
 attr-list := empty | av spaces attr-list
 empty     := spaces
 
Where av is defined by parseAttributeValue.
Returns:
A Hashtable mapping String instances (variable names) into String instances (variable values).

parseParamTag

public void parseParamTag(java.util.Hashtable into)
                   throws ParseException
Parse PARAM tag attributes into the given hashtable. Parses the PARAM tag as defined by:
 <PARAM tag-attributes %gt;
 
Two special tag attributes are recognized here:
  1. The name attribute,
  2. The value attribute.
The resulting name, value pair is stored in the provided hash table.
Parameters:
into - Storage for parameter values.

parsePluginParamTag

public void parsePluginParamTag(java.util.Hashtable into)
                         throws ParseException
Parse jsp:param tag attributes into the given hashtable. Parses the jsp:param tag as defined by:
 <jsp:param tag-attributes %gt;
 
Two special tag attributes are recognized here:
  1. The name attribute,
  2. The value attribute.
The resulting name, value pair is stored in the provided hash table.
Parameters:
into - Storage for parameter values.

JSPTemplates