Package com.volantis.xml.pipeline.sax

Examples of com.volantis.xml.pipeline.sax.XMLProcess


    }

    // javadoc inherited
    public void testEndDocument() throws Exception {
        // create an instance of the class that is to be tested
        XMLProcess process = createTestableProcess();
       
        // create a locator
        LocatorImpl locator = new LocatorImpl();
       
        // create a "base" URI
        URL baseURI = null;
        try {
            baseURI = new URL("http://foo.com");
        } catch (MalformedURLException e) {
            fail("Could not construct a java.net.URL instance");
        }
       
        // update the locator with the location
        locator.setSystemId(baseURI.toExternalForm());
       
        // set the next process
        XMLProcessTestable next = new XMLProcessTestable();
        process.setNextProcess(next);
               
        // call setDocumentLocator()
        process.setDocumentLocator(locator);
        process.startDocument();
       
        // get hold of the pipeline context
        XMLPipelineContext context
                = process.getPipeline().getPipelineContext();
       
        // ensure that the XMLPipelineContext has a current locator and
        // base uri
        assertNotNull(
                "XMLPipelineContext should have a non null current locator",
                context.getCurrentLocator());

        assertNotNull(
                "XMLPipelineContext should have a non null current base URI",
                context.getCurrentBaseURI());
       
        // invoke the method that is being tested
        process.endDocument();
       
        // ensure that the pipeline context has had both the current locator
        // and base uri popped off.
        assertNull("endDocument should pop the current locator",
                   context.getCurrentLocator());
View Full Code Here


    }

    //javadoc inherited
    public void testStartPrefixMapping() throws Exception {
        // create an instance of the class that is to be tested
        XMLProcess process = createTestableProcess();

        String prefix = "prefix";
        String namespace = "namespace";

        // set the next process
        XMLProcessTestable next = new XMLProcessTestable();
        process.setNextProcess(next);
       
        // invoke the method that is being tested
        process.startPrefixMapping(prefix, namespace);

        // get hold of the pipeline context
        XMLPipelineContext context
                = process.getPipeline().getPipelineContext();
       
        // ensure that the pipeline contexts NamespacePrefixTracker has
        // been updated       
        NamespacePrefixTracker tracker = context.getNamespacePrefixTracker();
View Full Code Here

    }

    // javadoc inherited
    public void testEndPrefixMapping() throws Exception {
        // create an instance of the class that is to be tested
        XMLProcess process = createTestableProcess();

        String prefix = "prefix";
        String namespace = "namespace";

        // set the next process
        XMLProcessTestable next = new XMLProcessTestable();
        process.setNextProcess(next);

        // get hold of the pipeline context
        XMLPipelineContext context
                = process.getPipeline().getPipelineContext();
       
        // Update pipeline contexts NamespacePrefixTracker with a prefix
        // and namespace pair
        NamespacePrefixTracker tracker = context.getNamespacePrefixTracker();
        tracker.startPrefixMapping(prefix, namespace);

        assertEquals("NamespacePrefixTracker was not updated with the " +
                     "startPrefixMapping event",
                     namespace,
                     tracker.getNamespaceURI(prefix));      
                     
        // invoke the method that is being tested
        process.endPrefixMapping(prefix);
       
        // ensure that the NamespacePrefixTracker has been updated
        assertNull("NamespacePrefixTracker was not updated with the " +
                   "endPrefixMapping event",                   
                     tracker.getNamespaceURI(prefix));
View Full Code Here

                XMLPipelineFactory factory = context.getPipelineFactory();
                final PipelineRecorder recorder =
                        factory.createPipelineRecorder();
                recorder.startRecording(dynamicProcess.getPipeline());

                final XMLProcess process = recorder.getRecordingProcess();

                dynamicProcess.addProcess(process);

                // Create an action to wrap the iterator and remove the
                // recording process once the body has been evaluated.
View Full Code Here

        HTMLResponseConditioner conditioner = new HTMLResponseConditioner(xmlFilter);


        XMLProcessImpl xmlProcess = new XMLProcessImpl() {
            public void setDocumentLocator(Locator locator) {
                XMLProcess consumer = getConsumerProcess();
                if (null != consumer) {
                    consumer.setDocumentLocator(locator);
                }
            }

            public void startDocument() throws SAXException {
                XMLProcess consumer = getConsumerProcess();
                if (null != consumer) {
                    consumer.startDocument();
                }
            }

            public void endDocument() throws SAXException {
                XMLProcess consumer = getConsumerProcess();
                if (null != consumer) {
                    consumer.endDocument();
                }
            }

            // Javadoc inherited
            public void startPrefixMapping(String prefix, String uri)
                    throws SAXException {
                XMLProcess consumer = getConsumerProcess();
                if (null != consumer) {
                    consumer.startPrefixMapping(prefix, uri);
                }
            }

            // Javadoc inherited
            public void endPrefixMapping(String prefix) throws SAXException {
                XMLProcess consumer = getConsumerProcess();
                if (null != consumer) {
                    consumer.endPrefixMapping(prefix);
                }
            }
        };
        xmlProcess.setNextProcess(adapter);
View Full Code Here

     *
     * @param pipeline The pipeline whose target process is requested.
     * @return Target process.
     */
    public static XMLProcess getTargetProcess(XMLPipeline pipeline) {
        XMLProcess target = pipeline.getHeadProcess();
        if (target == null) {
            target = pipeline.getPipelineProcess().getNextProcess();
        }
        if (target == null) {
            throw new IllegalStateException("Cannot find target process");
View Full Code Here

        XMLPipelineFactory factory = context.getPipelineFactory();

        // create a new pipeline.
        XMLPipeline pipeline = factory.createDynamicPipeline(context);

        XMLProcess cup = factory.createContextUpdatingProcess();
        cup.setPipeline(target.getPipeline());
        XMLProcess pipelineProcess = pipeline.getPipelineProcess();
        cup.setNextProcess(pipelineProcess);

        // set up the XMLReader so that the inclusion can be read.
        XMLReader reader = createXMLReader();
        reader.setErrorHandler(cup);
        reader.setContentHandler(cup);

        // Chain the new pipeline process to the target process
        pipelineProcess.setNextProcess(target);

        URLContentManager manager = PipelineURLContentManager.retrieve(
                context);

        try {
View Full Code Here

           
        // invoke startElement on the rule
        Object returned = rule.startElement(dynamicProcess, eName, atts);

        // ask the rule to create a process
        XMLProcess process = rule.createProcess(dynamicProcess,
                                                eName,
                                                createStartElementAttributes());

        // ensure the process was added to the pipeline is the same type as
        // the one that the rule creates
        assertSame("Process was not added to the pipeline",
                   process.getClass(),
                   pipeline.getHeadProcess().getClass());

    }
View Full Code Here

        // create an expanded name
        ExpandedName eName = new ImmutableExpandedName("testNamespace",
                                                       "testLocalName");

        // ask the rule to create a process
        XMLProcess process = rule.createProcess(dynamicProcess,
                                                eName,
                                                createStartElementAttributes());

        // add a process to the head of the pipeline
        pipeline.addHeadProcess(process);
View Full Code Here

        booleanValue = value;
    }

    //javadoc inherited
    public void stopProcess() throws SAXException {
        final XMLProcess nextProcess = getNextProcess();
        nextProcess.characters(text.toCharArray(), 0, text.length());
        final String intStr = " i: " + Integer.toString(intValue);
        nextProcess.characters(intStr.toCharArray(), 0, intStr.length());
        final String doubleStr = " d: " + Double.toString(doubleValue);
        nextProcess.characters(doubleStr.toCharArray(), 0, doubleStr.length());
        final String booleanStr = " b: " + Boolean.toString(booleanValue);
        nextProcess.characters(booleanStr.toCharArray(), 0, booleanStr.length());
        final ParametersConfiguration configuration = (ParametersConfiguration)
            getPipelineContext().getPipelineConfiguration().
                retrieveConfiguration(getClass());
        if (configuration != null) {
            Iterator iter = configuration.getParameterNames();
            if (iter.hasNext()) {
                nextProcess.characters(CONFIG_PARAMETERS_TITLE.toCharArray(), 0,
                    CONFIG_PARAMETERS_TITLE.length());
                while (iter.hasNext()) {
                    final String name = (String) iter.next();
                    final String value = configuration.getParameterValue(name);
                    final String line = name + " - " + value;
                    nextProcess.characters(
                        line.toCharArray(), 0, line.length());
                    if (iter.hasNext()) {
                        nextProcess.characters(
                            ", ".toCharArray(), 0, ", ".length());
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of com.volantis.xml.pipeline.sax.XMLProcess

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.