Package org.apache.jasper.compiler
Class JspUtil
- java.lang.Object
- 
- org.apache.jasper.compiler.JspUtil
 
- 
 public class JspUtil extends java.lang.ObjectThis 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 SummaryNested Classes Modifier and Type Class Description static classJspUtil.ValidAttribute
 - 
Field SummaryFields Modifier and Type Field Description static intCHUNKSIZE
 - 
Constructor SummaryConstructors Constructor Description JspUtil()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanbooleanValue(java.lang.String s)Convert a String value to 'boolean'.static voidcheckAttributes(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 voidcheckScope(java.lang.String scope, org.apache.jasper.compiler.Node n, ErrorDispatcher err)Checks to see if the given scope is valid.static java.lang.StringcoerceToBoolean(java.lang.String s, boolean isNamedAttribute)static java.lang.StringcoerceToByte(java.lang.String s, boolean isNamedAttribute)static java.lang.StringcoerceToChar(java.lang.String s, boolean isNamedAttribute)static java.lang.StringcoerceToCharacter(java.lang.String s, boolean isNamedAttribute)static java.lang.StringcoerceToDouble(java.lang.String s, boolean isNamedAttribute)static java.lang.StringcoerceToFloat(java.lang.String s, boolean isNamedAttribute)static java.lang.StringcoerceToInt(java.lang.String s, boolean isNamedAttribute)static java.lang.StringcoerceToInteger(java.lang.String s, boolean isNamedAttribute)static java.lang.StringcoerceToLong(java.lang.String s, boolean isNamedAttribute)static java.lang.StringcoerceToPrimitiveBoolean(java.lang.String s, boolean isNamedAttribute)static java.lang.StringcoerceToPrimitiveByte(java.lang.String s, boolean isNamedAttribute)static java.lang.StringcoerceToPrimitiveDouble(java.lang.String s, boolean isNamedAttribute)static java.lang.StringcoerceToPrimitiveFloat(java.lang.String s, boolean isNamedAttribute)static java.lang.StringcoerceToPrimitiveLong(java.lang.String s, boolean isNamedAttribute)static java.lang.StringcoerceToPrimitiveShort(java.lang.String s, boolean isNamedAttribute)static java.lang.StringcoerceToShort(java.lang.String s, boolean isNamedAttribute)static java.lang.StringgetExprInXml(java.lang.String expression)Takes a potential expression and converts it into XML form.static org.xml.sax.InputSourcegetInputSource(java.lang.String fname, Jar jar, JspCompilationContext ctxt)static java.io.BufferedInputStreamgetInputStream(java.lang.String fname, Jar jar, JspCompilationContext ctxt)static java.lang.StringgetTagHandlerClassName(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.StringinterpreterCall(boolean isTagFile, java.lang.String expression, java.lang.Class<?> expectedType, java.lang.String fnmapvar)Produces a String representing a call to the EL interpreter.static booleanisJavaKeyword(java.lang.String key)Test whether the argument is a Java keyword.static java.lang.StringmakeJavaIdentifier(java.lang.String identifier)Converts the given identifier to a legal Java identifierstatic java.lang.StringmakeJavaIdentifierForAttribute(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.StringmakeJavaPackage(java.lang.String path)Converts the given path to a Java package or fully-qualified class namestatic java.lang.StringmangleChar(char ch)Mangle the specified character to create a legal Java class name.static java.lang.Class<?>toClass(java.lang.String type, java.lang.ClassLoader loader)Returns theClassobject associated with the class or interface with the given string name.static java.lang.StringtoJavaSourceType(java.lang.String type)Class.getName() return arrays in the form "[[[<et>", where et, the element type can be one of ZBCDFIJS or L<classname>;.static java.lang.StringtoJavaSourceTypeFromTld(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'
 
- 
- 
- 
Field Detail- 
CHUNKSIZEpublic static final int CHUNKSIZE - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getExprInXmlpublic static java.lang.String getExprInXml(java.lang.String expression) Takes a potential expression and converts it into XML form.- Parameters:
- expression- The expression to convert
- Returns:
- XML view
 
 - 
checkScopepublic static void checkScope(java.lang.String scope, org.apache.jasper.compiler.Node n, ErrorDispatcher err) throws JasperExceptionChecks 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"
 
 - 
checkAttributespublic static void checkAttributes(java.lang.String typeOfTag, org.apache.jasper.compiler.Node n, JspUtil.ValidAttribute[] validAttributes, ErrorDispatcher err) throws JasperExceptionChecks 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.- Parameters:
- typeOfTag- The tag type
- n- The corresponding node
- validAttributes- The array with the valid attributes
- err- Dispatcher for errors
- Throws:
- JasperException- An error occurred
 
 - 
booleanValuepublic static boolean booleanValue(java.lang.String s) Convert a String value to 'boolean'. Besides the standard conversions done by Boolean.parseBoolean(s), 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
 
 - 
toClasspublic static java.lang.Class<?> toClass(java.lang.String type, java.lang.ClassLoader loader) throws java.lang.ClassNotFoundExceptionReturns theClassobject associated with the class or interface with the given string name.The Classobject is determined by passing the given string name to theClass.forName()method, unless the given string name represents a primitive type, in which case it is converted to aClassobject by appending ".class" to it (e.g., "int.class").- Parameters:
- type- The class name, array or primitive type
- loader- The class loader
- Returns:
- the loaded class
- Throws:
- java.lang.ClassNotFoundException- Loading class failed
 
 - 
interpreterCallpublic static java.lang.String interpreterCall(boolean isTagFile, java.lang.String expression, java.lang.Class<?> expectedType, java.lang.String fnmapvar)Produces a String representing a call to the EL interpreter.- Parameters:
- isTagFile-- trueif the file is a tag file rather than a JSP
- expression- a String containing zero or more "${}" expressions
- expectedType- the expected type of the interpreted result
- fnmapvar- Variable pointing to a function map.
- Returns:
- a String representing a call to the EL interpreter.
 
 - 
coerceToPrimitiveBooleanpublic static java.lang.String coerceToPrimitiveBoolean(java.lang.String s, boolean isNamedAttribute)
 - 
coerceToBooleanpublic static java.lang.String coerceToBoolean(java.lang.String s, boolean isNamedAttribute)
 - 
coerceToPrimitiveBytepublic static java.lang.String coerceToPrimitiveByte(java.lang.String s, boolean isNamedAttribute)
 - 
coerceToBytepublic static java.lang.String coerceToByte(java.lang.String s, boolean isNamedAttribute)
 - 
coerceToCharpublic static java.lang.String coerceToChar(java.lang.String s, boolean isNamedAttribute)
 - 
coerceToCharacterpublic static java.lang.String coerceToCharacter(java.lang.String s, boolean isNamedAttribute)
 - 
coerceToPrimitiveDoublepublic static java.lang.String coerceToPrimitiveDouble(java.lang.String s, boolean isNamedAttribute)
 - 
coerceToDoublepublic static java.lang.String coerceToDouble(java.lang.String s, boolean isNamedAttribute)
 - 
coerceToPrimitiveFloatpublic static java.lang.String coerceToPrimitiveFloat(java.lang.String s, boolean isNamedAttribute)
 - 
coerceToFloatpublic static java.lang.String coerceToFloat(java.lang.String s, boolean isNamedAttribute)
 - 
coerceToIntpublic static java.lang.String coerceToInt(java.lang.String s, boolean isNamedAttribute)
 - 
coerceToIntegerpublic static java.lang.String coerceToInteger(java.lang.String s, boolean isNamedAttribute)
 - 
coerceToPrimitiveShortpublic static java.lang.String coerceToPrimitiveShort(java.lang.String s, boolean isNamedAttribute)
 - 
coerceToShortpublic static java.lang.String coerceToShort(java.lang.String s, boolean isNamedAttribute)
 - 
coerceToPrimitiveLongpublic static java.lang.String coerceToPrimitiveLong(java.lang.String s, boolean isNamedAttribute)
 - 
coerceToLongpublic static java.lang.String coerceToLong(java.lang.String s, boolean isNamedAttribute)
 - 
getInputStreampublic static java.io.BufferedInputStream getInputStream(java.lang.String fname, Jar jar, JspCompilationContext ctxt) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
getInputSourcepublic static org.xml.sax.InputSource getInputSource(java.lang.String fname, Jar jar, JspCompilationContext ctxt) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
getTagHandlerClassNamepublic static java.lang.String getTagHandlerClassName(java.lang.String path, java.lang.String urn, ErrorDispatcher err) throws JasperExceptionGets the fully-qualified class name of the tag handler corresponding to the given tag file path.- Parameters:
- path- Tag file path
- urn- The tag identifier
- err- Error dispatcher
- Returns:
- Fully-qualified class name of the tag handler corresponding to the given tag file path
- Throws:
- JasperException- Failed to generate a class name for the tag
 
 - 
makeJavaPackagepublic 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
 
 - 
makeJavaIdentifierpublic 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
 
 - 
makeJavaIdentifierForAttributepublic 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
 
 - 
mangleCharpublic static final java.lang.String mangleChar(char ch) Mangle the specified character to create a legal Java class name.- Parameters:
- ch- The character
- Returns:
- the replacement character as a string
 
 - 
isJavaKeywordpublic static boolean isJavaKeyword(java.lang.String key) Test whether the argument is a Java keyword.- Parameters:
- key- The name
- Returns:
- trueif the name is a java identifier
 
 - 
toJavaSourceTypeFromTldpublic 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- The type from the TLD
- Returns:
- the Java type
 
 - 
toJavaSourceTypepublic static java.lang.String toJavaSourceType(java.lang.String type) Class.getName() return arrays in the form "[[[<et>", where et, the element type can be one of ZBCDFIJS or L<classname>;. It is converted into forms that can be understood by javac.- Parameters:
- type- the type to convert
- Returns:
- the equivalent type in Java sources
 
 
- 
 
-