public class JspUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
JspUtil.ValidAttribute |
Modifier and Type | Field and Description |
---|---|
static int |
CHUNKSIZE |
Constructor and Description |
---|
JspUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
booleanValue(String s)
Convert a String value to 'boolean'.
|
static void |
checkAttributes(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(String scope,
org.apache.jasper.compiler.Node n,
ErrorDispatcher err)
Checks to see if the given scope is valid.
|
static String |
coerceToBoolean(String s,
boolean isNamedAttribute) |
static String |
coerceToByte(String s,
boolean isNamedAttribute) |
static String |
coerceToChar(String s,
boolean isNamedAttribute) |
static String |
coerceToCharacter(String s,
boolean isNamedAttribute) |
static String |
coerceToDouble(String s,
boolean isNamedAttribute) |
static String |
coerceToFloat(String s,
boolean isNamedAttribute) |
static String |
coerceToInt(String s,
boolean isNamedAttribute) |
static String |
coerceToInteger(String s,
boolean isNamedAttribute) |
static String |
coerceToLong(String s,
boolean isNamedAttribute) |
static String |
coerceToPrimitiveBoolean(String s,
boolean isNamedAttribute) |
static String |
coerceToPrimitiveByte(String s,
boolean isNamedAttribute) |
static String |
coerceToPrimitiveDouble(String s,
boolean isNamedAttribute) |
static String |
coerceToPrimitiveFloat(String s,
boolean isNamedAttribute) |
static String |
coerceToPrimitiveLong(String s,
boolean isNamedAttribute) |
static String |
coerceToPrimitiveShort(String s,
boolean isNamedAttribute) |
static String |
coerceToShort(String s,
boolean isNamedAttribute) |
static String |
escapeXml(String s)
Escape the 5 entities defined by XML.
|
static String |
getExprInXml(String expression)
Takes a potential expression and converts it into XML form.
|
static InputStream |
getInputStream(String fname,
JarFile jarFile,
JspCompilationContext ctxt,
ErrorDispatcher err) |
static String |
getTagHandlerClassName(String path,
String urn,
ErrorDispatcher err)
Gets the fully-qualified class name of the tag handler corresponding to
the given tag file path.
|
static String |
interpreterCall(boolean isTagFile,
String expression,
Class<?> expectedType,
String fnmapvar,
boolean XmlEscape)
Produces a String representing a call to the EL interpreter.
|
static boolean |
isJavaIdentifier(String key) |
static boolean |
isJavaKeyword(String key)
Test whether the argument is a Java keyword.
|
static String |
makeJavaIdentifier(String identifier)
Converts the given identifier to a legal Java identifier
|
static String |
makeJavaIdentifierForAttribute(String identifier)
Converts the given identifier to a legal Java identifier
to be used for JSP Tag file attribute names.
|
static String |
makeJavaPackage(String path)
Converts the given path to a Java package or fully-qualified class name
|
static String |
mangleChar(char ch)
Mangle the specified character to create a legal Java class name.
|
static String |
replace(String name,
char replace,
String with)
Replaces any occurrences of the character
replace with the
string with . |
static Class<?> |
toClass(String type,
ClassLoader loader)
Returns the
Class object associated with the class or
interface with the given string name. |
static String |
toJavaSourceType(String type)
Class.getName() return arrays in the form "[[[<et>", where et, the
element type can be one of ZBCDFIJS or L<classname>;.
|
static String |
toJavaSourceTypeFromTld(String type)
Handles taking input from TLDs 'java.lang.Object' ->
'java.lang.Object.class' 'int' -> 'int.class' 'void' -> 'Void.TYPE'
'int[]' -> 'int[].class'
|
public static final int CHUNKSIZE
public static String getExprInXml(String expression)
expression
- The expression to convertpublic static void checkScope(String scope, org.apache.jasper.compiler.Node n, ErrorDispatcher err) throws JasperException
scope
- The scope to be checkedn
- The Node containing the 'scope' attribute whose value is to be
checkederr
- error dispatcherJasperException
- if scope is not null and different from "page",
"request", "session", and
"application"public static void checkAttributes(String typeOfTag, org.apache.jasper.compiler.Node n, JspUtil.ValidAttribute[] validAttributes, ErrorDispatcher err) throws JasperException
typeOfTag
- The tag typen
- The corresponding nodevalidAttributes
- The array with the valid attributeserr
- Dispatcher for errorsJasperException
- An error occurredpublic static String escapeXml(String s)
s
- String to escapepublic static String replace(String name, char replace, String with)
replace
with the
string with
.name
- String in which character is to be replacedreplace
- The character to replacewith
- The string with which the character is to be replacedreplace
replaced with with
public static boolean booleanValue(String s)
s
- the string to be convertedpublic static Class<?> toClass(String type, ClassLoader loader) throws ClassNotFoundException
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").
type
- The class name, array or primitive typeloader
- The class loaderClassNotFoundException
- Loading class failedpublic static String interpreterCall(boolean isTagFile, String expression, Class<?> expectedType, String fnmapvar, boolean XmlEscape)
isTagFile
- true
if the file is a tag file
rather than a JSPexpression
- 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 escapingpublic static String coerceToPrimitiveBoolean(String s, boolean isNamedAttribute)
public static String coerceToPrimitiveByte(String s, boolean isNamedAttribute)
public static String coerceToPrimitiveDouble(String s, boolean isNamedAttribute)
public static String coerceToPrimitiveFloat(String s, boolean isNamedAttribute)
public static String coerceToPrimitiveShort(String s, boolean isNamedAttribute)
public static String coerceToPrimitiveLong(String s, boolean isNamedAttribute)
public static InputStream getInputStream(String fname, JarFile jarFile, JspCompilationContext ctxt, ErrorDispatcher err) throws JasperException, IOException
JasperException
IOException
public static String getTagHandlerClassName(String path, String urn, ErrorDispatcher err) throws JasperException
path
- Tag file pathurn
- The tag identifiererr
- Error dispatcherJasperException
- Failed to generate a class name for the tagpublic static final String makeJavaPackage(String path)
path
- Path to convertpublic static final String makeJavaIdentifier(String identifier)
identifier
- Identifier to convertpublic static final String makeJavaIdentifierForAttribute(String identifier)
identifier
- Identifier to convertpublic static final String mangleChar(char ch)
ch
- The characterpublic static boolean isJavaKeyword(String key)
key
- The nametrue
if the name is a java identifierpublic static boolean isJavaIdentifier(String key)
public static String toJavaSourceTypeFromTld(String type)
type
- The type from the TLDpublic static String toJavaSourceType(String type)
type
- the type to convertCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.