Search in sources :

Example 1 with TypedValue

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

the class LaunchHelper method save.

public void save(File file) throws CoreException {
    BufferedWriter writer = null;
    try {
        // ensure it exists
        file.createNewFile();
        writer = new BufferedWriter(new FileWriter(file));
        PipelineDefinition pdef = new PipelineDefinition();
        for (Iterator<?> iter = attributes.getAttributes().iterator(); iter.hasNext(); ) {
            LaunchAttribute att = (LaunchAttribute) iter.next();
            pdef.addAttribute(new TypedValue(att.uri, TypedValue.TYPE_STRING, att.value));
        }
        for (Iterator<?> iter = pipeline.getTransformDefs().iterator(); iter.hasNext(); ) {
            LaunchTransform lt = (LaunchTransform) iter.next();
            TransformDefinition tdef = new TransformDefinition();
            URL url = pathToURL(lt.getLocation());
            tdef.setStylesheetURL(url.toExternalForm());
            tdef.setResolverClass(lt.getResolver());
            for (Iterator<?> iterator = lt.getParameters().iterator(); iterator.hasNext(); ) {
                LaunchAttribute att = (LaunchAttribute) iterator.next();
                tdef.addParameter(new TypedValue(att.uri, TypedValue.TYPE_STRING, att.getResolvedValue()));
            }
            // set the output props for the LAST transform only
            if (!iter.hasNext()) {
                for (Map.Entry<String, String> entry : outputProperties.getProperties().entrySet()) {
                    String name = entry.getKey();
                    String value = entry.getValue();
                    if (name != null && value != null)
                        tdef.setOutputProperty(name, value);
                }
            }
            pdef.addTransformDef(tdef);
        }
        Document doc = pdef.toXML();
        String s = PreferenceUtil.serializeDocument(doc);
        writer.write(s);
    } catch (FileNotFoundException e) {
        throw new CoreException(new Status(IStatus.ERROR, JAXPLaunchingPlugin.PLUGIN_ID, IStatus.ERROR, Messages.LaunchHelper_0, e));
    } catch (IOException e) {
        throw new CoreException(new Status(IStatus.ERROR, JAXPLaunchingPlugin.PLUGIN_ID, IStatus.ERROR, Messages.LaunchHelper_1, e));
    } catch (ParserConfigurationException e) {
        throw new CoreException(new Status(IStatus.ERROR, JAXPLaunchingPlugin.PLUGIN_ID, IStatus.ERROR, "ParserConfigurationException", // $NON-NLS-1$
        e));
    } catch (TransformerException e) {
        throw new CoreException(new Status(IStatus.ERROR, JAXPLaunchingPlugin.PLUGIN_ID, IStatus.ERROR, "TransformerException", // $NON-NLS-1$
        e));
    } finally {
        if (writer != null) {
            try {
                writer.close();
            } catch (IOException e) {
                JAXPLaunchingPlugin.log(e);
            }
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) TransformDefinition(org.eclipse.wst.xsl.jaxp.debug.invoker.TransformDefinition) LaunchTransform(org.eclipse.wst.xsl.launching.config.LaunchTransform) FileWriter(java.io.FileWriter) FileNotFoundException(java.io.FileNotFoundException) PipelineDefinition(org.eclipse.wst.xsl.jaxp.debug.invoker.PipelineDefinition) IOException(java.io.IOException) Document(org.w3c.dom.Document) LaunchAttribute(org.eclipse.wst.xsl.launching.config.LaunchAttribute) URL(java.net.URL) BufferedWriter(java.io.BufferedWriter) CoreException(org.eclipse.core.runtime.CoreException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Map(java.util.Map) TransformerException(javax.xml.transform.TransformerException) TypedValue(org.eclipse.wst.xsl.jaxp.debug.invoker.TypedValue)

Example 2 with TypedValue

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

the class PipelineDefintionTest method testRemoveAttribute.

@Test
public void testRemoveAttribute() throws Exception {
    TypedValue attr = setupAttribute();
    pldef.addAttribute(attr);
    assertEquals(1, pldef.getAttributes().size());
    pldef.removeAttribute(attr);
    assertEquals(0, pldef.getAttributes().size());
}
Also used : TypedValue(org.eclipse.wst.xsl.jaxp.debug.invoker.TypedValue) Test(org.junit.Test)

Example 3 with TypedValue

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

the class TransformDefinitonTest method setupParameters.

private TypedValue setupParameters() {
    TypedValue param = new TypedValue("param", TypedValue.TYPE_STRING, "test");
    tdef.addParameter(param);
    return param;
}
Also used : TypedValue(org.eclipse.wst.xsl.jaxp.debug.invoker.TypedValue)

Example 4 with TypedValue

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

the class TransformDefinitonTest method testRemoveParameter.

@Test
public void testRemoveParameter() throws Exception {
    TypedValue param = setupParameters();
    assertTrue(tdef.getParameters().size() > 0);
    tdef.removeParameter(param);
    assertTrue("Found parameters when there should be zero.", tdef.getParameters().size() == 0);
}
Also used : TypedValue(org.eclipse.wst.xsl.jaxp.debug.invoker.TypedValue) Test(org.junit.Test)

Example 5 with TypedValue

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

the class PipelineDefintionTest method setupAttribute.

private TypedValue setupAttribute() {
    TypedValue attr = new TypedValue("attr", TypedValue.TYPE_STRING, "1");
    pldef.addAttribute(attr);
    return attr;
}
Also used : TypedValue(org.eclipse.wst.xsl.jaxp.debug.invoker.TypedValue)

Aggregations

TypedValue (org.eclipse.wst.xsl.jaxp.debug.invoker.TypedValue)5 Test (org.junit.Test)2 BufferedWriter (java.io.BufferedWriter)1 FileNotFoundException (java.io.FileNotFoundException)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 URL (java.net.URL)1 Map (java.util.Map)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 PipelineDefinition (org.eclipse.wst.xsl.jaxp.debug.invoker.PipelineDefinition)1 TransformDefinition (org.eclipse.wst.xsl.jaxp.debug.invoker.TransformDefinition)1 LaunchAttribute (org.eclipse.wst.xsl.launching.config.LaunchAttribute)1 LaunchTransform (org.eclipse.wst.xsl.launching.config.LaunchTransform)1 Document (org.w3c.dom.Document)1