Package org.apache.jasper.compiler
Class JspUtil
java.lang.Object
org.apache.jasper.compiler.JspUtil
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 SummaryNested Classes
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic booleanConvert a String value to 'boolean'.static voidcheckAttributes(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(String scope, org.apache.jasper.compiler.Node n, ErrorDispatcher err) Checks to see if the given scope is valid.static StringcoerceToBoolean(String s, boolean isNamedAttribute) static StringcoerceToByte(String s, boolean isNamedAttribute) static StringcoerceToChar(String s, boolean isNamedAttribute) static StringcoerceToCharacter(String s, boolean isNamedAttribute) static StringcoerceToDouble(String s, boolean isNamedAttribute) static StringcoerceToFloat(String s, boolean isNamedAttribute) static StringcoerceToInt(String s, boolean isNamedAttribute) static StringcoerceToInteger(String s, boolean isNamedAttribute) static StringcoerceToLong(String s, boolean isNamedAttribute) static StringcoerceToPrimitiveBoolean(String s, boolean isNamedAttribute) static StringcoerceToPrimitiveByte(String s, boolean isNamedAttribute) static StringcoerceToPrimitiveDouble(String s, boolean isNamedAttribute) static StringcoerceToPrimitiveFloat(String s, boolean isNamedAttribute) static StringcoerceToPrimitiveLong(String s, boolean isNamedAttribute) static StringcoerceToPrimitiveShort(String s, boolean isNamedAttribute) static StringcoerceToShort(String s, boolean isNamedAttribute) static StringgetExprInXml(String expression) Takes a potential expression and converts it into XML form.static InputSourcegetInputSource(String fname, Jar jar, JspCompilationContext ctxt) static BufferedInputStreamgetInputStream(String fname, Jar jar, JspCompilationContext ctxt) static StringgetTagHandlerClassName(String path, String packageName, String urn, ErrorDispatcher err) Gets the fully-qualified class name of the tag handler corresponding to the given tag file path.static StringinterpreterCall(boolean isTagFile, String expression, Class<?> expectedType, String fnmapvar) Produces a String representing a call to the EL interpreter.static booleanisJavaKeyword(String key) Test whether the argument is a Java keyword.static final StringmakeJavaIdentifier(String identifier) Converts the given identifier to a legal Java identifierstatic final StringmakeJavaIdentifierForAttribute(String identifier) Converts the given identifier to a legal Java identifier to be used for JSP Tag file attribute names.static final StringmakeJavaPackage(String path) Converts the given path to a Java package or fully-qualified class namestatic final StringmangleChar(char ch) Mangle the specified character to create a legal Java class name.static Class<?>toClass(String type, ClassLoader loader) Returns theClassobject associated with the class or interface with the given string name.static StringtoJavaSourceType(String type) Class.getName() return arrays in the form "[[[<et>", where et, the element type can be one of ZBCDFIJS or L<classname>;.static StringHandles taking input from TLDs 'java.lang.Object' -> 'java.lang.Object.class' 'int' -> 'int.class' 'void' -> 'Void.TYPE' 'int[]' -> 'int[].class'
- 
Field Details- 
CHUNKSIZEpublic static final int CHUNKSIZE- See Also:
 
 
- 
- 
Constructor Details- 
JspUtilpublic JspUtil()
 
- 
- 
Method Details- 
getExprInXmlTakes a potential expression and converts it into XML form.- Parameters:
- expression- The expression to convert
- Returns:
- XML view
 
- 
checkScopepublic static void checkScope(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"
 
- 
checkAttributespublic static void checkAttributes(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.- 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
 
- 
booleanValueConvert 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
 
- 
toClassReturns 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:
- ClassNotFoundException- Loading class failed
 
- 
interpreterCallpublic static String interpreterCall(boolean isTagFile, String expression, Class<?> expectedType, 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.
 
- 
coerceToPrimitiveBoolean
- 
coerceToBoolean
- 
coerceToPrimitiveByte
- 
coerceToByte
- 
coerceToChar
- 
coerceToCharacter
- 
coerceToPrimitiveDouble
- 
coerceToDouble
- 
coerceToPrimitiveFloat
- 
coerceToFloat
- 
coerceToInt
- 
coerceToInteger
- 
coerceToPrimitiveShort
- 
coerceToShort
- 
coerceToPrimitiveLong
- 
coerceToLong
- 
getInputStreampublic static BufferedInputStream getInputStream(String fname, Jar jar, JspCompilationContext ctxt) throws IOException - Throws:
- IOException
 
- 
getInputSourcepublic static InputSource getInputSource(String fname, Jar jar, JspCompilationContext ctxt) throws IOException - Throws:
- IOException
 
- 
getTagHandlerClassNamepublic static String getTagHandlerClassName(String path, String packageName, 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
- packageName- The package name
- 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
 
- 
makeJavaPackageConverts 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
 
- 
makeJavaIdentifierConverts the given identifier to a legal Java identifier- Parameters:
- identifier- Identifier to convert
- Returns:
- Legal Java identifier corresponding to the given identifier
 
- 
makeJavaIdentifierForAttributeConverts 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
 
- 
mangleCharMangle the specified character to create a legal Java class name.- Parameters:
- ch- The character
- Returns:
- the replacement character as a string
 
- 
isJavaKeywordTest whether the argument is a Java keyword.- Parameters:
- key- The name
- Returns:
- trueif the name is a java identifier
 
- 
toJavaSourceTypeFromTldHandles 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
 
- 
toJavaSourceTypeClass.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
 
 
-