org.apache.jasper.compiler
Class JspUtil

java.lang.Object
  |
  +--org.apache.jasper.compiler.JspUtil

public class JspUtil
extends java.lang.Object

This class has all the utility method(s). Ideally should move all the bean containers here.

Author:
Mandar Raje., Rajiv Mordani., Danno Ferrin, Pierre Delisle, Shawn Bayern, Mark Roth

Nested Class Summary
static class JspUtil.FunctionSignature
          Parses and encapsulates a function signature, as would appear in a TLD.
static class JspUtil.ValidAttribute
           
 
Constructor Summary
JspUtil()
           
 
Method Summary
static boolean booleanValue(java.lang.String s)
          Convert a String value to 'boolean'.
static void checkAttributes(java.lang.String typeOfTag, Node n, JspUtil.ValidAttribute[] validAttributes, ErrorDispatcher err)
          Checks if all mandatory attributes are present and if all attributes present have valid names.
static java.lang.String escapeQueryString(java.lang.String unescString)
           
static char[] escapeQuotes(char[] chars)
           
static java.lang.String escapeXml(java.lang.String s)
          Escape the 5 entities defined by XML.
static java.lang.String getExpr(java.lang.String expression, boolean isXml)
           
static java.lang.String getExprInXml(java.lang.String expression)
          Takes a potential expression and converts it into XML form
static java.lang.String interpreterCall(boolean isTagFile, java.lang.String expression, java.lang.Class expectedType, java.lang.String defaultPrefix, java.lang.String fnmapvar)
          Produces a String representing a call to the EL interpreter.
static boolean isExpression(java.lang.String token, boolean isXml)
          Checks if the token is a runtime expression.
static java.lang.String nextTemporaryVariableName()
          Generates a new temporary variable name.
static char[] removeQuotes(char[] chars)
           
static java.lang.String replace(java.lang.String name, char replace, java.lang.String with)
          Replaces any occurrences of the character replace with the string with.
static void resetTemporaryVariableName()
          Resets the temporary variable name.
static java.lang.Class toClass(java.lang.String type, java.lang.ClassLoader loader)
          Returns the Class object associated with the class or interface with the given string name.
static void validateExpressions(Mark where, java.lang.String expressions, java.lang.Class expectedType, javax.servlet.jsp.el.FunctionMapper functionMapper, java.lang.String defaultPrefix, ErrorDispatcher err)
          Validates the syntax of all ${} expressions within the given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JspUtil

public JspUtil()
Method Detail

removeQuotes

public static char[] removeQuotes(char[] chars)

escapeQuotes

public static char[] escapeQuotes(char[] chars)

isExpression

public static boolean isExpression(java.lang.String token,
                                   boolean isXml)
Checks if the token is a runtime expression. In standard JSP syntax, a runtime expression starts with '<%' and ends with '%>'. When the JSP document is in XML syntax, a runtime expression starts with '%=' and ends with '%'.

Parameters:
token - The token to be checked return whether the token is a runtime expression or not.

getExpr

public static java.lang.String getExpr(java.lang.String expression,
                                       boolean isXml)
Returns:
the "expression" part of a runtime expression, taking the delimiters out.

getExprInXml

public static java.lang.String getExprInXml(java.lang.String expression)
Takes a potential expression and converts it into XML form


checkAttributes

public static void checkAttributes(java.lang.String typeOfTag,
                                   Node n,
                                   JspUtil.ValidAttribute[] validAttributes,
                                   ErrorDispatcher err)
                            throws JasperException
Checks if all mandatory attributes are present and if all attributes present have valid names. Checks attributes specified as XML-style attributes as well as attributes specified using the jsp:attribute standard action.

JasperException

escapeQueryString

public static java.lang.String escapeQueryString(java.lang.String unescString)

escapeXml

public static java.lang.String escapeXml(java.lang.String s)
Escape the 5 entities defined by XML.


replace

public static java.lang.String replace(java.lang.String name,
                                       char replace,
                                       java.lang.String with)
Replaces any occurrences of the character replace with the string with.


booleanValue

public static boolean booleanValue(java.lang.String s)
Convert a String value to 'boolean'. Besides the standard conversions done by Boolean.valueOf(s).booleanValue(), the value "yes" (ignore case) is also converted to 'true'. If 's' is null, then 'false' is returned.

Parameters:
s - the string to be converted
Returns:
the boolean value associated with the string s

toClass

public static java.lang.Class toClass(java.lang.String type,
                                      java.lang.ClassLoader loader)
                               throws java.lang.ClassNotFoundException
Returns the Class object associated with the class or interface with the given string name.

The Class object is determined by passing the given string name to the Class.forName() method, unless the given string name represents a primitive type, in which case it is converted to a Class object by appending ".class" to it (e.g., "int.class").

java.lang.ClassNotFoundException

interpreterCall

public static java.lang.String interpreterCall(boolean isTagFile,
                                               java.lang.String expression,
                                               java.lang.Class expectedType,
                                               java.lang.String defaultPrefix,
                                               java.lang.String fnmapvar)
Produces a String representing a call to the EL interpreter.

Parameters:
expression - a String containing zero or more "${}" expressions
expectedType - the expected type of the interpreted result
defaultPrefix - Default prefix, or literal "null"
fnmapvar - Variable pointing to a function map.
Returns:
a String representing a call to the EL interpreter.

validateExpressions

public static void validateExpressions(Mark where,
                                       java.lang.String expressions,
                                       java.lang.Class expectedType,
                                       javax.servlet.jsp.el.FunctionMapper functionMapper,
                                       java.lang.String defaultPrefix,
                                       ErrorDispatcher err)
                                throws JasperException
Validates the syntax of all ${} expressions within the given string.

Parameters:
where - the approximate location of the expressions in the JSP page
expressions - a string containing zero or more "${}" expressions
err - an error dispatcher to use
JasperException

resetTemporaryVariableName

public static void resetTemporaryVariableName()
Resets the temporary variable name. (not thread-safe)


nextTemporaryVariableName

public static java.lang.String nextTemporaryVariableName()
Generates a new temporary variable name. (not thread-safe)



Copyright © 2000 Apache Software Foundation. All Rights Reserved.