Search in sources :

Example 1 with CreationException

use of org.eclipse.wst.xsl.jaxp.debug.invoker.internal.CreationException in project webtools.sourceediting by eclipse.

the class TypedValue method createValue.

/**
 * Create the type of object defined by this.
 *
 * @return the value
 * @throws CreationException
 *             if a problem occurred
 */
public Object createValue() throws CreationException {
    Object o = null;
    if (TYPE_STRING.equals(type)) {
        o = value;
    } else if (TYPE_BOOLEAN.equals(type)) {
        // $NON-NLS-1$ //$NON-NLS-2$
        boolean b = "yes".equalsIgnoreCase(value) || "true".equalsIgnoreCase(value);
        o = Boolean.valueOf(b);
    } else if (TYPE_INT.equals(type)) {
        try {
            o = new Integer(value);
        } catch (NumberFormatException e) {
            throw new CreationException(Messages.getString("TypedValue.9") + value + Messages.getString("TypedValue.10"), // $NON-NLS-1$ //$NON-NLS-2$
            e);
        }
    } else if (TYPE_DOUBLE.equals(type)) {
        try {
            o = new Double(value);
        } catch (NumberFormatException e) {
            throw new CreationException(Messages.getString("TypedValue.11") + value + Messages.getString("TypedValue.12"), // $NON-NLS-1$ //$NON-NLS-2$
            e);
        }
    } else if (TYPE_FLOAT.equals(type)) {
        try {
            o = new Float(value);
        } catch (NumberFormatException e) {
            throw new CreationException(Messages.getString("TypedValue.13") + value + Messages.getString("TypedValue.14"), // $NON-NLS-1$ //$NON-NLS-2$
            e);
        }
    } else if (TYPE_CLASS.equals(type)) {
        try {
            o = Class.forName(value);
        } catch (ClassNotFoundException e) {
            throw new CreationException(Messages.getString("TypedValue.15") + value + Messages.getString("TypedValue.16"), // $NON-NLS-1$ //$NON-NLS-2$
            e);
        }
    } else if (TYPE_OBJECT.equals(type)) {
        try {
            Class<?> c = Class.forName(value);
            o = c.newInstance();
        } catch (ClassNotFoundException e) {
            throw new CreationException(Messages.getString("TypedValue.17") + value + Messages.getString("TypedValue.18"), // $NON-NLS-1$ //$NON-NLS-2$
            e);
        } catch (InstantiationException e) {
            throw new CreationException(Messages.getString("TypedValue.19") + value + Messages.getString("TypedValue.20"), // $NON-NLS-1$ //$NON-NLS-2$
            e);
        } catch (IllegalAccessException e) {
            throw new CreationException(Messages.getString("TypedValue.21") + value + Messages.getString("TypedValue.22"), // $NON-NLS-1$ //$NON-NLS-2$
            e);
        }
    } else {
        throw new CreationException(// $NON-NLS-1$ //$NON-NLS-2$
        Messages.getString("TypedValue.23") + type + Messages.getString("TypedValue.24"));
    }
    return o;
}
Also used : CreationException(org.eclipse.wst.xsl.jaxp.debug.invoker.internal.CreationException)

Example 2 with CreationException

use of org.eclipse.wst.xsl.jaxp.debug.invoker.internal.CreationException in project webtools.sourceediting by eclipse.

the class PipelineDefinition method configure.

/**
 * Configure the invoker from this.
 *
 * @param invoker
 *            the invoker to configure
 * @throws ConfigurationException
 *             if an exception occurs during configuration
 */
public void configure(IProcessorInvoker invoker) throws ConfigurationException {
    Map<String, Object> attVals = new ConcurrentHashMap<String, Object>();
    for (Iterator<TypedValue> iter = attributes.iterator(); iter.hasNext(); ) {
        TypedValue att = iter.next();
        Object value;
        try {
            value = att.createValue();
        } catch (CreationException e) {
            throw new ConfigurationException(e.getMessage(), e);
        }
        attVals.put(att.name, value);
    }
    invoker.setAttributes(attVals);
    for (Iterator<TransformDefinition> iter = transformDefs.iterator(); iter.hasNext(); ) {
        TransformDefinition tdef = iter.next();
        Map<String, Object> params = setParams(tdef);
        URL url = getStyleSheetURL(tdef);
        Properties properties = tdef.getOutputProperties();
        URIResolver resolver = getResolver(tdef);
        addStyleSheet(invoker, tdef, params, url, properties, resolver);
    }
}
Also used : URIResolver(javax.xml.transform.URIResolver) CreationException(org.eclipse.wst.xsl.jaxp.debug.invoker.internal.CreationException) Properties(java.util.Properties) URL(java.net.URL) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) ConfigurationException(org.eclipse.wst.xsl.jaxp.debug.invoker.internal.ConfigurationException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

CreationException (org.eclipse.wst.xsl.jaxp.debug.invoker.internal.CreationException)2 URL (java.net.URL)1 Properties (java.util.Properties)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)1 URIResolver (javax.xml.transform.URIResolver)1 ConfigurationException (org.eclipse.wst.xsl.jaxp.debug.invoker.internal.ConfigurationException)1