Class JspRuntimeLibrary


  • public class JspRuntimeLibrary
    extends java.lang.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
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object coerce​(java.lang.String s, java.lang.Class target)  
      static boolean coerceToBoolean​(java.lang.String s)  
      static byte coerceToByte​(java.lang.String s)  
      static char coerceToChar​(java.lang.String s)  
      static double coerceToDouble​(java.lang.String s)  
      static float coerceToFloat​(java.lang.String s)  
      static int coerceToInt​(java.lang.String s)  
      static long coerceToLong​(java.lang.String s)  
      static short coerceToShort​(java.lang.String s)  
      static java.lang.Object convert​(java.lang.String propertyName, java.lang.String s, java.lang.Class t, java.lang.Class propertyEditorClass)  
      static void createTypedArray​(java.lang.String propertyName, java.lang.Object bean, java.lang.reflect.Method method, java.lang.String[] values, java.lang.Class t, java.lang.Class propertyEditorClass)
      Create a typed array.
      static java.lang.String decode​(java.lang.String encoded)
      Decode an URL formatted string.
      static java.lang.String escapeQueryString​(java.lang.String unescString)
      Escape special shell characters.
      static java.lang.String getContextRelativePath​(ServletRequest request, java.lang.String relativePath)
      Convert a possibly relative resource path into a context-relative resource path that starts with a '/'.
      static java.lang.reflect.Method getReadMethod​(java.lang.Class beanClass, java.lang.String prop)  
      static java.lang.Throwable getThrowable​(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 java.lang.Object getValueFromBeanInfoPropertyEditor​(java.lang.Class attrClass, java.lang.String attrName, java.lang.String attrValue, java.lang.Class propertyEditorClass)  
      static java.lang.Object getValueFromPropertyEditorManager​(java.lang.Class attrClass, java.lang.String attrName, java.lang.String attrValue)  
      static java.lang.reflect.Method getWriteMethod​(java.lang.Class beanClass, java.lang.String prop)  
      static java.lang.Object handleGetProperty​(java.lang.Object o, java.lang.String prop)  
      static void handleSetProperty​(java.lang.Object bean, java.lang.String prop, boolean value)  
      static void handleSetProperty​(java.lang.Object bean, java.lang.String prop, byte value)  
      static void handleSetProperty​(java.lang.Object bean, java.lang.String prop, char value)  
      static void handleSetProperty​(java.lang.Object bean, java.lang.String prop, double value)  
      static void handleSetProperty​(java.lang.Object bean, java.lang.String prop, float value)  
      static void handleSetProperty​(java.lang.Object bean, java.lang.String prop, int value)  
      static void handleSetProperty​(java.lang.Object bean, java.lang.String prop, long value)  
      static void handleSetProperty​(java.lang.Object bean, java.lang.String prop, short value)  
      static void handleSetProperty​(java.lang.Object bean, java.lang.String prop, java.lang.Object value)  
      static void handleSetPropertyExpression​(java.lang.Object bean, java.lang.String prop, java.lang.String expression, 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 void include​(ServletRequest request, ServletResponse response, java.lang.String relativePath, JspWriter out, boolean flush)
      Perform a RequestDispatcher.include() operation, with optional flushing of the response beforehand.
      static void introspect​(java.lang.Object bean, ServletRequest request)  
      static void introspecthelper​(java.lang.Object bean, java.lang.String prop, java.lang.String value, ServletRequest request, java.lang.String param, boolean ignoreMethodNF)  
      static java.lang.String toString​(boolean b)  
      static java.lang.String toString​(byte b)  
      static java.lang.String toString​(char c)  
      static java.lang.String toString​(double d)  
      static java.lang.String toString​(float f)  
      static java.lang.String toString​(int i)  
      static java.lang.String toString​(long l)  
      static java.lang.String toString​(short s)  
      static java.lang.String toString​(java.lang.Object o)  
      static java.lang.String URLEncode​(java.lang.String s, java.lang.String enc)
      URL encodes a string, based on the supplied character encoding.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JspRuntimeLibrary

        public JspRuntimeLibrary()
    • Method Detail

      • getThrowable

        public static java.lang.Throwable getThrowable​(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​(java.lang.String s)
      • coerceToByte

        public static byte coerceToByte​(java.lang.String s)
      • coerceToChar

        public static char coerceToChar​(java.lang.String s)
      • coerceToDouble

        public static double coerceToDouble​(java.lang.String s)
      • coerceToFloat

        public static float coerceToFloat​(java.lang.String s)
      • coerceToInt

        public static int coerceToInt​(java.lang.String s)
      • coerceToShort

        public static short coerceToShort​(java.lang.String s)
      • coerceToLong

        public static long coerceToLong​(java.lang.String s)
      • coerce

        public static java.lang.Object coerce​(java.lang.String s,
                                              java.lang.Class target)
      • convert

        public static java.lang.Object convert​(java.lang.String propertyName,
                                               java.lang.String s,
                                               java.lang.Class t,
                                               java.lang.Class propertyEditorClass)
                                        throws org.apache.sling.scripting.jsp.jasper.JasperException
        Throws:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • introspect

        public static void introspect​(java.lang.Object bean,
                                      ServletRequest request)
                               throws org.apache.sling.scripting.jsp.jasper.JasperException
        Throws:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • introspecthelper

        public static void introspecthelper​(java.lang.Object bean,
                                            java.lang.String prop,
                                            java.lang.String value,
                                            ServletRequest request,
                                            java.lang.String param,
                                            boolean ignoreMethodNF)
                                     throws org.apache.sling.scripting.jsp.jasper.JasperException
        Throws:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • toString

        public static java.lang.String toString​(java.lang.Object o)
      • toString

        public static java.lang.String toString​(byte b)
      • toString

        public static java.lang.String toString​(boolean b)
      • toString

        public static java.lang.String toString​(short s)
      • toString

        public static java.lang.String toString​(int i)
      • toString

        public static java.lang.String toString​(float f)
      • toString

        public static java.lang.String toString​(long l)
      • toString

        public static java.lang.String toString​(double d)
      • toString

        public static java.lang.String toString​(char c)
      • createTypedArray

        public static void createTypedArray​(java.lang.String propertyName,
                                            java.lang.Object bean,
                                            java.lang.reflect.Method method,
                                            java.lang.String[] values,
                                            java.lang.Class t,
                                            java.lang.Class propertyEditorClass)
                                     throws org.apache.sling.scripting.jsp.jasper.JasperException
        Create a typed array. This is a special case where params are passed through the request and the property is indexed.
        Throws:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • escapeQueryString

        public static java.lang.String escapeQueryString​(java.lang.String unescString)
        Escape special shell characters.
        Parameters:
        unescString - The string to shell-escape
        Returns:
        The escaped shell string.
      • decode

        public static java.lang.String decode​(java.lang.String encoded)
        Decode an URL formatted string.
        Parameters:
        encoded - The string to decode.
        Returns:
        The decoded string.
      • handleGetProperty

        public static java.lang.Object handleGetProperty​(java.lang.Object o,
                                                         java.lang.String prop)
                                                  throws org.apache.sling.scripting.jsp.jasper.JasperException
        Throws:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • handleSetPropertyExpression

        public static void handleSetPropertyExpression​(java.lang.Object bean,
                                                       java.lang.String prop,
                                                       java.lang.String expression,
                                                       PageContext pageContext,
                                                       ProtectedFunctionMapper functionMapper)
                                                throws org.apache.sling.scripting.jsp.jasper.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:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • handleSetProperty

        public static void handleSetProperty​(java.lang.Object bean,
                                             java.lang.String prop,
                                             java.lang.Object value)
                                      throws org.apache.sling.scripting.jsp.jasper.JasperException
        Throws:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • handleSetProperty

        public static void handleSetProperty​(java.lang.Object bean,
                                             java.lang.String prop,
                                             int value)
                                      throws org.apache.sling.scripting.jsp.jasper.JasperException
        Throws:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • handleSetProperty

        public static void handleSetProperty​(java.lang.Object bean,
                                             java.lang.String prop,
                                             short value)
                                      throws org.apache.sling.scripting.jsp.jasper.JasperException
        Throws:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • handleSetProperty

        public static void handleSetProperty​(java.lang.Object bean,
                                             java.lang.String prop,
                                             long value)
                                      throws org.apache.sling.scripting.jsp.jasper.JasperException
        Throws:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • handleSetProperty

        public static void handleSetProperty​(java.lang.Object bean,
                                             java.lang.String prop,
                                             double value)
                                      throws org.apache.sling.scripting.jsp.jasper.JasperException
        Throws:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • handleSetProperty

        public static void handleSetProperty​(java.lang.Object bean,
                                             java.lang.String prop,
                                             float value)
                                      throws org.apache.sling.scripting.jsp.jasper.JasperException
        Throws:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • handleSetProperty

        public static void handleSetProperty​(java.lang.Object bean,
                                             java.lang.String prop,
                                             char value)
                                      throws org.apache.sling.scripting.jsp.jasper.JasperException
        Throws:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • handleSetProperty

        public static void handleSetProperty​(java.lang.Object bean,
                                             java.lang.String prop,
                                             byte value)
                                      throws org.apache.sling.scripting.jsp.jasper.JasperException
        Throws:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • handleSetProperty

        public static void handleSetProperty​(java.lang.Object bean,
                                             java.lang.String prop,
                                             boolean value)
                                      throws org.apache.sling.scripting.jsp.jasper.JasperException
        Throws:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • getWriteMethod

        public static java.lang.reflect.Method getWriteMethod​(java.lang.Class beanClass,
                                                              java.lang.String prop)
                                                       throws org.apache.sling.scripting.jsp.jasper.JasperException
        Throws:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • getReadMethod

        public static java.lang.reflect.Method getReadMethod​(java.lang.Class beanClass,
                                                             java.lang.String prop)
                                                      throws org.apache.sling.scripting.jsp.jasper.JasperException
        Throws:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • getValueFromBeanInfoPropertyEditor

        public static java.lang.Object getValueFromBeanInfoPropertyEditor​(java.lang.Class attrClass,
                                                                          java.lang.String attrName,
                                                                          java.lang.String attrValue,
                                                                          java.lang.Class propertyEditorClass)
                                                                   throws org.apache.sling.scripting.jsp.jasper.JasperException
        Throws:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • getValueFromPropertyEditorManager

        public static java.lang.Object getValueFromPropertyEditorManager​(java.lang.Class attrClass,
                                                                         java.lang.String attrName,
                                                                         java.lang.String attrValue)
                                                                  throws org.apache.sling.scripting.jsp.jasper.JasperException
        Throws:
        org.apache.sling.scripting.jsp.jasper.JasperException
      • getContextRelativePath

        public static java.lang.String getContextRelativePath​(ServletRequest request,
                                                              java.lang.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 processing
        relativePath - The possibly relative resource path
      • include

        public static void include​(ServletRequest request,
                                   ServletResponse response,
                                   java.lang.String relativePath,
                                   JspWriter out,
                                   boolean flush)
                            throws java.io.IOException,
                                   ServletException
        Perform a RequestDispatcher.include() operation, with optional flushing of the response beforehand.
        Parameters:
        request - The servlet request we are processing
        response - The servlet response we are processing
        relativePath - The relative path of the resource to be included
        out - The Writer to whom we are currently writing
        flush - Should we flush before the include is processed?
        Throws:
        java.io.IOException - if thrown by the included servlet
        ServletException - if thrown by the included servlet
      • URLEncode

        public static java.lang.String URLEncode​(java.lang.String s,
                                                 java.lang.String enc)
        URL encodes a string, based on the supplied character encoding. This performs the same function as java.next.URLEncode.encode in J2SDK1.4, and should be removed if the only platform supported is 1.4 or higher.
        Parameters:
        s - The String to be URL encoded.
        enc - The character encoding
        Returns:
        The URL encoded String