This class has all the utility method(s).
Ideally should move all the bean containers here.
booleanValue
public static boolean booleanValue(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.
s
- the string to be converted
- the boolean value associated with the string s
checkAttributes
public 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.
checkScope
public static void checkScope(String scope,
org.apache.jasper.compiler.Node n,
ErrorDispatcher err)
throws JasperException
Checks to see if the given scope is valid.
scope
- The scope to be checkedn
- The Node containing the 'scope' attribute whose value is to be
checkederr
- error dispatcher
JasperException
- if scope is not null and different from
"page", "request", "session", and
"application"
coerceToBoolean
public static String coerceToBoolean(String s,
boolean isNamedAttribute)
coerceToByte
public static String coerceToByte(String s,
boolean isNamedAttribute)
coerceToChar
public static String coerceToChar(String s,
boolean isNamedAttribute)
coerceToCharacter
public static String coerceToCharacter(String s,
boolean isNamedAttribute)
coerceToDouble
public static String coerceToDouble(String s,
boolean isNamedAttribute)
coerceToFloat
public static String coerceToFloat(String s,
boolean isNamedAttribute)
coerceToInt
public static String coerceToInt(String s,
boolean isNamedAttribute)
coerceToInteger
public static String coerceToInteger(String s,
boolean isNamedAttribute)
coerceToLong
public static String coerceToLong(String s,
boolean isNamedAttribute)
coerceToPrimitiveBoolean
public static String coerceToPrimitiveBoolean(String s,
boolean isNamedAttribute)
coerceToPrimitiveByte
public static String coerceToPrimitiveByte(String s,
boolean isNamedAttribute)
coerceToPrimitiveDouble
public static String coerceToPrimitiveDouble(String s,
boolean isNamedAttribute)
coerceToPrimitiveFloat
public static String coerceToPrimitiveFloat(String s,
boolean isNamedAttribute)
coerceToPrimitiveLong
public static String coerceToPrimitiveLong(String s,
boolean isNamedAttribute)
coerceToPrimitiveShort
public static String coerceToPrimitiveShort(String s,
boolean isNamedAttribute)
coerceToShort
public static String coerceToShort(String s,
boolean isNamedAttribute)
escapeQueryString
public static String escapeQueryString(String unescString)
escapeQuotes
public static char[] escapeQuotes(char[] chars)
escapeXml
public static String escapeXml(String s)
Escape the 5 entities defined by XML.
getCanonicalName
public static String getCanonicalName(Class c)
Compute the canonical name from a Class instance. Note that a
simple replacment of '$' with '.' of a binary name would not work,
as '$' is a legal Java Identifier character.
c
- A instance of java.lang.Class
- The canonical name of c.
getExpr
public static String getExpr(String expression,
boolean isXml)
- the "expression" part of a runtime expression,
taking the delimiters out.
getExprInXml
public static String getExprInXml(String expression)
Takes a potential expression and converts it into XML form
getTagHandlerClassName
public static String getTagHandlerClassName(String path,
ErrorDispatcher err)
throws JasperException
Gets the fully-qualified class name of the tag handler corresponding to
the given tag file path.
path
- Tag file patherr
- Error dispatcher
- Fully-qualified class name of the tag handler corresponding to
the given tag file path
interpreterCall
public static String interpreterCall(boolean isTagFile,
String expression,
Class expectedType,
String fnmapvar,
boolean XmlEscape)
Produces a String representing a call to the EL interpreter.
expression
- a String containing zero or more "${}" expressionsexpectedType
- the expected type of the interpreted resultfnmapvar
- Variable pointing to a function map.XmlEscape
- True if the result should do XML escaping
- a String representing a call to the EL interpreter.
isExpression
public static boolean isExpression(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 '%'.
token
- The token to be checked
return whether the token is a runtime expression or not.
isJavaKeyword
public static boolean isJavaKeyword(String key)
Test whether the argument is a Java keyword
makeJavaIdentifier
public static final String makeJavaIdentifier(String identifier)
Converts the given identifier to a legal Java identifier
identifier
- Identifier to convert
- Legal Java identifier corresponding to the given identifier
makeJavaPackage
public static final String makeJavaPackage(String path)
Converts the given path to a Java package or fully-qualified class name
path
- Path to convert
- Java package corresponding to the given path
makeXmlJavaIdentifier
public static final String makeXmlJavaIdentifier(String name)
Converts the given Xml name to a legal Java identifier. This is
slightly more efficient than makeJavaIdentifier in that we only need
to worry about '.', '-', and ':' in the string. We also assume that
the resultant string is further concatenated with some prefix string
so that we don't have to worry about it being a Java key word.
name
- Identifier to convert
- Legal Java identifier corresponding to the given identifier
mangleChar
public static final String mangleChar(char ch)
Mangle the specified character to create a legal Java class name.
nextTemporaryVariableName
public static String nextTemporaryVariableName()
Generates a new temporary variable name.
(not thread-safe)
removeQuotes
public static char[] removeQuotes(char[] chars)
replace
public static String replace(String name,
char replace,
String with)
Replaces any occurrences of the character replace with the
string with.
resetTemporaryVariableName
public static void resetTemporaryVariableName()
Resets the temporary variable name.
(not thread-safe)
toClass
public static Class toClass(String type,
ClassLoader loader)
throws 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").
toJavaSourceType
public static String toJavaSourceType(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.
validateExpressions
public static void validateExpressions(org.apache.jasper.compiler.Mark where,
String expressions,
Class expectedType,
FunctionMapper functionMapper,
ErrorDispatcher err)
throws JasperException
Validates the syntax of all ${} expressions within the given string.
where
- the approximate location of the expressions in the JSP pageexpressions
- a string containing zero or more "${}" expressionserr
- an error dispatcher to use