Search in sources :

Example 26 with JasperException

use of org.apache.sling.scripting.jsp.jasper.JasperException in project sling by apache.

the class JspRuntimeLibrary method handleSetProperty.

public static void handleSetProperty(Object bean, String prop, char value) throws JasperException {
    try {
        Method method = getWriteMethod(bean.getClass(), prop);
        method.invoke(bean, new Object[] { new Character(value) });
    } catch (Exception ex) {
        throw new JasperException(ex);
    }
}
Also used : JasperException(org.apache.sling.scripting.jsp.jasper.JasperException) Method(java.lang.reflect.Method) PrivilegedActionException(java.security.PrivilegedActionException) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) JasperException(org.apache.sling.scripting.jsp.jasper.JasperException)

Example 27 with JasperException

use of org.apache.sling.scripting.jsp.jasper.JasperException in project sling by apache.

the class JspRuntimeLibrary method handleSetProperty.

public static void handleSetProperty(Object bean, String prop, boolean value) throws JasperException {
    try {
        Method method = getWriteMethod(bean.getClass(), prop);
        method.invoke(bean, new Object[] { new Boolean(value) });
    } catch (Exception ex) {
        throw new JasperException(ex);
    }
}
Also used : JasperException(org.apache.sling.scripting.jsp.jasper.JasperException) Method(java.lang.reflect.Method) PrivilegedActionException(java.security.PrivilegedActionException) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) JasperException(org.apache.sling.scripting.jsp.jasper.JasperException)

Example 28 with JasperException

use of org.apache.sling.scripting.jsp.jasper.JasperException in project sling by apache.

the class JspRuntimeLibrary method convert.

// __begin convertMethod
public static Object convert(String propertyName, String s, Class t, Class propertyEditorClass) throws JasperException {
    try {
        if (s == null) {
            if (t.equals(Boolean.class) || t.equals(Boolean.TYPE))
                s = "false";
            else
                return null;
        }
        if (propertyEditorClass != null) {
            return getValueFromBeanInfoPropertyEditor(t, propertyName, s, propertyEditorClass);
        } else if (t.equals(Boolean.class) || t.equals(Boolean.TYPE)) {
            if (s.equalsIgnoreCase("on") || s.equalsIgnoreCase("true"))
                s = "true";
            else
                s = "false";
            return new Boolean(s);
        } else if (t.equals(Byte.class) || t.equals(Byte.TYPE)) {
            return new Byte(s);
        } else if (t.equals(Character.class) || t.equals(Character.TYPE)) {
            return s.length() > 0 ? new Character(s.charAt(0)) : null;
        } else if (t.equals(Short.class) || t.equals(Short.TYPE)) {
            return new Short(s);
        } else if (t.equals(Integer.class) || t.equals(Integer.TYPE)) {
            return new Integer(s);
        } else if (t.equals(Float.class) || t.equals(Float.TYPE)) {
            return new Float(s);
        } else if (t.equals(Long.class) || t.equals(Long.TYPE)) {
            return new Long(s);
        } else if (t.equals(Double.class) || t.equals(Double.TYPE)) {
            return new Double(s);
        } else if (t.equals(String.class)) {
            return s;
        } else if (t.equals(java.io.File.class)) {
            return new java.io.File(s);
        } else if (t.getName().equals("java.lang.Object")) {
            return new Object[] { s };
        } else {
            return getValueFromPropertyEditorManager(t, propertyName, s);
        }
    } catch (Exception ex) {
        throw new JasperException(ex);
    }
}
Also used : PrivilegedActionException(java.security.PrivilegedActionException) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) JasperException(org.apache.sling.scripting.jsp.jasper.JasperException) JasperException(org.apache.sling.scripting.jsp.jasper.JasperException)

Example 29 with JasperException

use of org.apache.sling.scripting.jsp.jasper.JasperException in project sling by apache.

the class JspRuntimeLibrary method getValueFromBeanInfoPropertyEditor.

//*********************************************************************
// PropertyEditor Support
public static Object getValueFromBeanInfoPropertyEditor(Class attrClass, String attrName, String attrValue, Class propertyEditorClass) throws JasperException {
    try {
        PropertyEditor pe = (PropertyEditor) propertyEditorClass.newInstance();
        pe.setAsText(attrValue);
        return pe.getValue();
    } catch (Exception ex) {
        throw new JasperException(Localizer.getMessage("jsp.error.beans.property.conversion", attrValue, attrClass.getName(), attrName, ex.getMessage()));
    }
}
Also used : JasperException(org.apache.sling.scripting.jsp.jasper.JasperException) PropertyEditor(java.beans.PropertyEditor) PrivilegedActionException(java.security.PrivilegedActionException) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) JasperException(org.apache.sling.scripting.jsp.jasper.JasperException)

Example 30 with JasperException

use of org.apache.sling.scripting.jsp.jasper.JasperException in project sling by apache.

the class JspRuntimeLibrary method handleSetProperty.

public static void handleSetProperty(Object bean, String prop, Object value) throws JasperException {
    try {
        Method method = getWriteMethod(bean.getClass(), prop);
        method.invoke(bean, new Object[] { value });
    } catch (Exception ex) {
        throw new JasperException(ex);
    }
}
Also used : JasperException(org.apache.sling.scripting.jsp.jasper.JasperException) Method(java.lang.reflect.Method) PrivilegedActionException(java.security.PrivilegedActionException) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) JasperException(org.apache.sling.scripting.jsp.jasper.JasperException)

Aggregations

JasperException (org.apache.sling.scripting.jsp.jasper.JasperException)42 IOException (java.io.IOException)31 ServletException (javax.servlet.ServletException)19 PrivilegedActionException (java.security.PrivilegedActionException)17 Method (java.lang.reflect.Method)14 FileNotFoundException (java.io.FileNotFoundException)9 MalformedURLException (java.net.MalformedURLException)6 Iterator (java.util.Iterator)6 InputStream (java.io.InputStream)5 JarFile (java.util.jar.JarFile)5 TagInfo (javax.servlet.jsp.tagext.TagInfo)4 TreeNode (org.apache.sling.scripting.jsp.jasper.xmlparser.TreeNode)4 DependencyResolutionRequiredException (org.apache.maven.artifact.DependencyResolutionRequiredException)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 SAXException (org.xml.sax.SAXException)3 File (java.io.File)2 InputStreamReader (java.io.InputStreamReader)2 URL (java.net.URL)2 Enumeration (java.util.Enumeration)2 HashMap (java.util.HashMap)2