Package org.apache.jasper.runtime
Class JspRuntimeLibrary
- java.lang.Object
-
- org.apache.jasper.runtime.JspRuntimeLibrary
-
public class JspRuntimeLibrary extends Object
Bunch of util methods that are used by code generated for useBean, getProperty and setProperty. The __begin, __end stuff is there so that the JSP engine can actually parse this file and inline them if people don't want runtime dependencies on this class. However, I'm not sure if that works so well right now. It got forgotten at some point. -akv- Author:
- Mandar Raje, Shawn Bayern
-
-
Constructor Summary
Constructors Constructor Description JspRuntimeLibrary()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Tcoerce(String s, Class<T> target)static booleancoerceToBoolean(String s)static bytecoerceToByte(String s)static charcoerceToChar(String s)static doublecoerceToDouble(String s)static floatcoerceToFloat(String s)static intcoerceToInt(String s)static longcoerceToLong(String s)static shortcoerceToShort(String s)static Objectconvert(String propertyName, String s, Class t, Class propertyEditorClass)static voidcreateTypedArray(String propertyName, Object bean, Method method, String[] values, Class t, Class propertyEditorClass)Create a typed array.static StringescapeQueryString(String unescString)Escape special shell characters.static StringgetContextRelativePath(javax.servlet.ServletRequest request, String relativePath)Convert a possibly relative resource path into a context-relative resource path that starts with a '/'.static MethodgetReadMethod(Class beanClass, String prop)static ThrowablegetThrowable(javax.servlet.ServletRequest request)Returns the value of the javax.servlet.error.exception request attribute value, if present, otherwise the value of the javax.servlet.jsp.jspException request attribute value.static ObjectgetValueFromBeanInfoPropertyEditor(Class attrClass, String attrName, String attrValue, Class propertyEditorClass)static ObjectgetValueFromPropertyEditorManager(Class attrClass, String attrName, String attrValue)static MethodgetWriteMethod(Class beanClass, String prop)static ObjecthandleGetProperty(Object o, String prop)static voidhandleSetProperty(Object bean, String prop, boolean value)static voidhandleSetProperty(Object bean, String prop, byte value)static voidhandleSetProperty(Object bean, String prop, char value)static voidhandleSetProperty(Object bean, String prop, double value)static voidhandleSetProperty(Object bean, String prop, float value)static voidhandleSetProperty(Object bean, String prop, int value)static voidhandleSetProperty(Object bean, String prop, long value)static voidhandleSetProperty(Object bean, String prop, short value)static voidhandleSetProperty(Object bean, String prop, Object value)static voidhandleSetPropertyExpression(Object bean, String prop, String expression, javax.servlet.jsp.PageContext pageContext, ProtectedFunctionMapper functionMapper)Use proprietaryEvaluate public static void handleSetPropertyExpression(Object bean, String prop, String expression, PageContext pageContext, VariableResolver variableResolver, FunctionMapper functionMapper ) throws JasperException { try { Method method = getWriteMethod(bean.getClass(), prop); method.invoke(bean, new Object[] { pageContext.getExpressionEvaluator().evaluate( expression, method.getParameterTypes()[0], variableResolver, functionMapper, null ) }); } catch (Exception ex) { throw new JasperException(ex); } }static voidinclude(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, String relativePath, javax.servlet.jsp.JspWriter out, boolean flush)Perform a RequestDispatcher.include() operation, with optional flushing of the response beforehand.static voidintrospect(Object bean, javax.servlet.ServletRequest request)static voidintrospecthelper(Object bean, String prop, String value, javax.servlet.ServletRequest request, String param, boolean ignoreMethodNF)static StringtoString(boolean b)static StringtoString(byte b)static StringtoString(char c)static StringtoString(double d)static StringtoString(float f)static StringtoString(int i)static StringtoString(long l)static StringtoString(short s)static StringtoString(Object o)static StringURLEncode(String s, String enc)
-
-
-
Method Detail
-
getThrowable
public static Throwable getThrowable(javax.servlet.ServletRequest request)
Returns the value of the javax.servlet.error.exception request attribute value, if present, otherwise the value of the javax.servlet.jsp.jspException request attribute value. This method is called at the beginning of the generated servlet code for a JSP error page, when the "exception" implicit scripting language variable is initialized.
-
coerceToBoolean
public static boolean coerceToBoolean(String s)
-
coerceToByte
public static byte coerceToByte(String s)
-
coerceToChar
public static char coerceToChar(String s)
-
coerceToDouble
public static double coerceToDouble(String s)
-
coerceToFloat
public static float coerceToFloat(String s)
-
coerceToInt
public static int coerceToInt(String s)
-
coerceToShort
public static short coerceToShort(String s)
-
coerceToLong
public static long coerceToLong(String s)
-
convert
public static Object convert(String propertyName, String s, Class t, Class propertyEditorClass) throws JasperException
- Throws:
JasperException
-
introspect
public static void introspect(Object bean, javax.servlet.ServletRequest request) throws JasperException
- Throws:
JasperException
-
introspecthelper
public static void introspecthelper(Object bean, String prop, String value, javax.servlet.ServletRequest request, String param, boolean ignoreMethodNF) throws JasperException
- Throws:
JasperException
-
toString
public static String toString(byte b)
-
toString
public static String toString(boolean b)
-
toString
public static String toString(short s)
-
toString
public static String toString(int i)
-
toString
public static String toString(float f)
-
toString
public static String toString(long l)
-
toString
public static String toString(double d)
-
toString
public static String toString(char c)
-
createTypedArray
public static void createTypedArray(String propertyName, Object bean, Method method, String[] values, Class t, Class propertyEditorClass) throws JasperException
Create a typed array. This is a special case where params are passed through the request and the property is indexed.- Throws:
JasperException
-
escapeQueryString
public static String escapeQueryString(String unescString)
Escape special shell characters.- Parameters:
unescString- The string to shell-escape- Returns:
- The escaped shell string.
-
handleGetProperty
public static Object handleGetProperty(Object o, String prop) throws JasperException
- Throws:
JasperException
-
handleSetPropertyExpression
public static void handleSetPropertyExpression(Object bean, String prop, String expression, javax.servlet.jsp.PageContext pageContext, ProtectedFunctionMapper functionMapper) throws JasperException
Use proprietaryEvaluate public static void handleSetPropertyExpression(Object bean, String prop, String expression, PageContext pageContext, VariableResolver variableResolver, FunctionMapper functionMapper ) throws JasperException { try { Method method = getWriteMethod(bean.getClass(), prop); method.invoke(bean, new Object[] { pageContext.getExpressionEvaluator().evaluate( expression, method.getParameterTypes()[0], variableResolver, functionMapper, null ) }); } catch (Exception ex) { throw new JasperException(ex); } }- Throws:
JasperException
-
handleSetProperty
public static void handleSetProperty(Object bean, String prop, Object value) throws JasperException
- Throws:
JasperException
-
handleSetProperty
public static void handleSetProperty(Object bean, String prop, int value) throws JasperException
- Throws:
JasperException
-
handleSetProperty
public static void handleSetProperty(Object bean, String prop, short value) throws JasperException
- Throws:
JasperException
-
handleSetProperty
public static void handleSetProperty(Object bean, String prop, long value) throws JasperException
- Throws:
JasperException
-
handleSetProperty
public static void handleSetProperty(Object bean, String prop, double value) throws JasperException
- Throws:
JasperException
-
handleSetProperty
public static void handleSetProperty(Object bean, String prop, float value) throws JasperException
- Throws:
JasperException
-
handleSetProperty
public static void handleSetProperty(Object bean, String prop, char value) throws JasperException
- Throws:
JasperException
-
handleSetProperty
public static void handleSetProperty(Object bean, String prop, byte value) throws JasperException
- Throws:
JasperException
-
handleSetProperty
public static void handleSetProperty(Object bean, String prop, boolean value) throws JasperException
- Throws:
JasperException
-
getWriteMethod
public static Method getWriteMethod(Class beanClass, String prop) throws JasperException
- Throws:
JasperException
-
getReadMethod
public static Method getReadMethod(Class beanClass, String prop) throws JasperException
- Throws:
JasperException
-
getValueFromBeanInfoPropertyEditor
public static Object getValueFromBeanInfoPropertyEditor(Class attrClass, String attrName, String attrValue, Class propertyEditorClass) throws JasperException
- Throws:
JasperException
-
getValueFromPropertyEditorManager
public static Object getValueFromPropertyEditorManager(Class attrClass, String attrName, String attrValue) throws JasperException
- Throws:
JasperException
-
getContextRelativePath
public static String getContextRelativePath(javax.servlet.ServletRequest request, String relativePath)
Convert a possibly relative resource path into a context-relative resource path that starts with a '/'.- Parameters:
request- The servlet request we are processingrelativePath- The possibly relative resource path
-
include
public static void include(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, String relativePath, javax.servlet.jsp.JspWriter out, boolean flush) throws IOException, javax.servlet.ServletExceptionPerform a RequestDispatcher.include() operation, with optional flushing of the response beforehand.- Parameters:
request- The servlet request we are processingresponse- The servlet response we are processingrelativePath- The relative path of the resource to be includedout- The Writer to whom we are currently writingflush- Should we flush before the include is processed?- Throws:
IOException- if thrown by the included servletjavax.servlet.ServletException- if thrown by the included servlet
-
-