Apache Tomcat 7.0.26

org.apache.jasper.compiler
Class JspUtil

java.lang.Object
  extended by 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.ValidAttribute
           
 
Field Summary
static int CHUNKSIZE
           
 
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, org.apache.jasper.compiler.Node n, JspUtil.ValidAttribute[] validAttributes, ErrorDispatcher err)
          Checks if all mandatory attributes are present and if all attributes present have valid names.
static void checkScope(java.lang.String scope, org.apache.jasper.compiler.Node n, ErrorDispatcher err)
          Checks to see if the given scope is valid.
static java.lang.String coerceToBoolean(java.lang.String s, boolean isNamedAttribute)
           
static java.lang.String coerceToByte(java.lang.String s, boolean isNamedAttribute)
           
static java.lang.String coerceToChar(java.lang.String s, boolean isNamedAttribute)
           
static java.lang.String coerceToCharacter(java.lang.String s, boolean isNamedAttribute)
           
static java.lang.String coerceToDouble(java.lang.String s, boolean isNamedAttribute)
           
static java.lang.String coerceToFloat(java.lang.String s, boolean isNamedAttribute)
           
static java.lang.String coerceToInt(java.lang.String s, boolean isNamedAttribute)
           
static java.lang.String coerceToInteger(java.lang.String s, boolean isNamedAttribute)
           
static java.lang.String coerceToLong(java.lang.String s, boolean isNamedAttribute)
           
static java.lang.String coerceToPrimitiveBoolean(java.lang.String s, boolean isNamedAttribute)
           
static java.lang.String coerceToPrimitiveByte(java.lang.String s, boolean isNamedAttribute)
           
static java.lang.String coerceToPrimitiveDouble(java.lang.String s, boolean isNamedAttribute)
           
static java.lang.String coerceToPrimitiveFloat(java.lang.String s, boolean isNamedAttribute)
           
static java.lang.String coerceToPrimitiveLong(java.lang.String s, boolean isNamedAttribute)
           
static java.lang.String coerceToPrimitiveShort(java.lang.String s, boolean isNamedAttribute)
           
static java.lang.String coerceToShort(java.lang.String s, boolean isNamedAttribute)
           
static java.lang.String escapeXml(java.lang.String s)
          Escape the 5 entities defined by XML.
static java.lang.String getExprInXml(java.lang.String expression)
          Takes a potential expression and converts it into XML form
static java.io.InputStream getInputStream(java.lang.String fname, java.util.jar.JarFile jarFile, JspCompilationContext ctxt, ErrorDispatcher err)
           
static java.lang.String getTagHandlerClassName(java.lang.String path, java.lang.String urn, ErrorDispatcher err)
          Gets the fully-qualified class name of the tag handler corresponding to the given tag file path.
static java.lang.String interpreterCall(boolean isTagFile, java.lang.String expression, java.lang.Class<?> expectedType, java.lang.String fnmapvar, boolean XmlEscape)
          Produces a String representing a call to the EL interpreter.
static boolean isJavaIdentifier(java.lang.String key)
           
static boolean isJavaKeyword(java.lang.String key)
          Test whether the argument is a Java keyword
static java.lang.String makeJavaIdentifier(java.lang.String identifier)
          Converts the given identifier to a legal Java identifier
static java.lang.String makeJavaIdentifierForAttribute(java.lang.String identifier)
          Converts the given identifier to a legal Java identifier to be used for JSP Tag file attribute names.
static java.lang.String makeJavaPackage(java.lang.String path)
          Converts the given path to a Java package or fully-qualified class name
static java.lang.String mangleChar(char ch)
          Mangle the specified character to create a legal Java class name.
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 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 java.lang.String toJavaSourceType(java.lang.String type)
          Class.getName() return arrays in the form "[[[", where et, the element type can be one of ZBCDFIJS or L; It is converted into forms that can be understood by javac.
static java.lang.String toJavaSourceTypeFromTld(java.lang.String type)
          Handles taking input from TLDs 'java.lang.Object' -> 'java.lang.Object.class' 'int' -> 'int.class' 'void' -> 'Void.TYPE' 'int[]' -> 'int[].class'
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHUNKSIZE

public static final int CHUNKSIZE
See Also:
Constant Field Values
Constructor Detail

JspUtil

public JspUtil()
Method Detail

getExprInXml

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


checkScope

public static void checkScope(java.lang.String scope,
                              org.apache.jasper.compiler.Node n,
                              ErrorDispatcher err)
                       throws JasperException
Checks to see if the given scope is valid.

Parameters:
scope - The scope to be checked
n - The Node containing the 'scope' attribute whose value is to be checked
err - error dispatcher
Throws:
JasperException - if scope is not null and different from "page", "request", "session", and "application"

checkAttributes

public static void checkAttributes(java.lang.String typeOfTag,
                                   org.apache.jasper.compiler.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.

Throws:
JasperException

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").

Throws:
java.lang.ClassNotFoundException

interpreterCall

public static java.lang.String interpreterCall(boolean isTagFile,
                                               java.lang.String expression,
                                               java.lang.Class<?> expectedType,
                                               java.lang.String fnmapvar,
                                               boolean XmlEscape)
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
fnmapvar - Variable pointing to a function map.
XmlEscape - True if the result should do XML escaping
Returns:
a String representing a call to the EL interpreter.

coerceToPrimitiveBoolean

public static java.lang.String coerceToPrimitiveBoolean(java.lang.String s,
                                                        boolean isNamedAttribute)

coerceToBoolean

public static java.lang.String coerceToBoolean(java.lang.String s,
                                               boolean isNamedAttribute)

coerceToPrimitiveByte

public static java.lang.String coerceToPrimitiveByte(java.lang.String s,
                                                     boolean isNamedAttribute)

coerceToByte

public static java.lang.String coerceToByte(java.lang.String s,
                                            boolean isNamedAttribute)

coerceToChar

public static java.lang.String coerceToChar(java.lang.String s,
                                            boolean isNamedAttribute)

coerceToCharacter

public static java.lang.String coerceToCharacter(java.lang.String s,
                                                 boolean isNamedAttribute)

coerceToPrimitiveDouble

public static java.lang.String coerceToPrimitiveDouble(java.lang.String s,
                                                       boolean isNamedAttribute)

coerceToDouble

public static java.lang.String coerceToDouble(java.lang.String s,
                                              boolean isNamedAttribute)

coerceToPrimitiveFloat

public static java.lang.String coerceToPrimitiveFloat(java.lang.String s,
                                                      boolean isNamedAttribute)

coerceToFloat

public static java.lang.String coerceToFloat(java.lang.String s,
                                             boolean isNamedAttribute)

coerceToInt

public static java.lang.String coerceToInt(java.lang.String s,
                                           boolean isNamedAttribute)

coerceToInteger

public static java.lang.String coerceToInteger(java.lang.String s,
                                               boolean isNamedAttribute)

coerceToPrimitiveShort

public static java.lang.String coerceToPrimitiveShort(java.lang.String s,
                                                      boolean isNamedAttribute)

coerceToShort

public static java.lang.String coerceToShort(java.lang.String s,
                                             boolean isNamedAttribute)

coerceToPrimitiveLong

public static java.lang.String coerceToPrimitiveLong(java.lang.String s,
                                                     boolean isNamedAttribute)

coerceToLong

public static java.lang.String coerceToLong(java.lang.String s,
                                            boolean isNamedAttribute)

getInputStream

public static java.io.InputStream getInputStream(java.lang.String fname,
                                                 java.util.jar.JarFile jarFile,
                                                 JspCompilationContext ctxt,
                                                 ErrorDispatcher err)
                                          throws JasperException,
                                                 java.io.IOException
Throws:
JasperException
java.io.IOException

getTagHandlerClassName

public static java.lang.String getTagHandlerClassName(java.lang.String path,
                                                      java.lang.String urn,
                                                      ErrorDispatcher err)
                                               throws JasperException
Gets the fully-qualified class name of the tag handler corresponding to the given tag file path.

Parameters:
path - Tag file path
err - Error dispatcher
Returns:
Fully-qualified class name of the tag handler corresponding to the given tag file path
Throws:
JasperException

makeJavaPackage

public static final java.lang.String makeJavaPackage(java.lang.String path)
Converts the given path to a Java package or fully-qualified class name

Parameters:
path - Path to convert
Returns:
Java package corresponding to the given path

makeJavaIdentifier

public static final java.lang.String makeJavaIdentifier(java.lang.String identifier)
Converts the given identifier to a legal Java identifier

Parameters:
identifier - Identifier to convert
Returns:
Legal Java identifier corresponding to the given identifier

makeJavaIdentifierForAttribute

public static final java.lang.String makeJavaIdentifierForAttribute(java.lang.String identifier)
Converts the given identifier to a legal Java identifier to be used for JSP Tag file attribute names.

Parameters:
identifier - Identifier to convert
Returns:
Legal Java identifier corresponding to the given identifier

mangleChar

public static final java.lang.String mangleChar(char ch)
Mangle the specified character to create a legal Java class name.


isJavaKeyword

public static boolean isJavaKeyword(java.lang.String key)
Test whether the argument is a Java keyword


isJavaIdentifier

public static boolean isJavaIdentifier(java.lang.String key)

toJavaSourceTypeFromTld

public static java.lang.String toJavaSourceTypeFromTld(java.lang.String type)
Handles taking input from TLDs 'java.lang.Object' -> 'java.lang.Object.class' 'int' -> 'int.class' 'void' -> 'Void.TYPE' 'int[]' -> 'int[].class'

Parameters:
type -

toJavaSourceType

public static java.lang.String toJavaSourceType(java.lang.String type)
Class.getName() return arrays in the form "[[[", where et, the element type can be one of ZBCDFIJS or L; It is converted into forms that can be understood by javac.


Apache Tomcat 7.0.26

Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.