Package com.volantis.mcs.wbsax

Examples of com.volantis.mcs.wbsax.WBSAXContentHandler


    }

    public void testContentOpaqueAccesskeyOpaqueRemoval()
            throws WBSAXException {
        StringWriter out = new StringWriter();
        WBSAXContentHandler handler = new TestDebugProducer(out);
        AccesskeyWBSAXFilter filter = new AccesskeyWBSAXFilter(codec,
                handler, attributes);

        // Check 10 elements with an opaque value accesskey element
        // Do the first 9, they will work normally
View Full Code Here


    protected WBSAXContentHandler createWBXMLProducer(OutputStream output) {

        // We create WBXML by parsing the events into a DOM and then
        // serialising the DOM back to WBXML.

        WBSAXContentHandler producer = super.createWBXMLProducer(output);

        // This will serialise the DOM to WBSAX events.
        SerialisationConfiguration configuration = createConfiguration();
        WBSAXSerialiser serialiser = new WBSAXSerialiser(producer,
                configuration, urlListener);
View Full Code Here

    protected WBSAXContentHandler createXMLProducer(Writer output) {

        // We create XML by parsing the events into a DOM and then
        // serialising the DOM back to XML.

        WBSAXContentHandler producer = super.createXMLProducer(output);

        // This will serialise the DOM to WBSAX events.
        SerialisationConfiguration configuration = createConfiguration();
        WBSAXSerialiser serialiser = new WBSAXSerialiser(producer,
                configuration, urlListener);
View Full Code Here

    protected DissectedContentHandler createDissectedContentHandler(
            OutputDocument output)
            throws Exception {

        // Create either a binary or text producer.
        WBSAXContentHandler producer = createProducer(output);

        if (logger.isDebugEnabled()) {
            // Wrap it with a debug filter.
            producer = new WBSAXDisassembler(producer);
        }
View Full Code Here

            // Create a producer for XML.
            CharArrayWriter textBuffer = new CharArrayWriter();
            CharacterEncoder pce = new DebugCharacterEncoder();
            EncodingWriter enc = new EncodingWriter(textBuffer, pce);
            WBSAXContentHandler textProducer = new WMLProducer(textBuffer, enc);

            if (logger.isDebugEnabled()) {
                textProducer = new WBSAXDisassembler(textProducer);
            }
           
            // Create a producer for WBXML.
            ByteArrayOutputStream binaryBuffer = new ByteArrayOutputStream();
            WBXMLProducer binaryProducer = new WBXMLProducer(binaryBuffer);
            // Create a "tee" producer which will generate the XML and WBXML
            // simultaneously.
            WBSAXContentHandler producer = new WBSAXTeeHandler(
                    textProducer, binaryProducer);
            // Create content handler used by the dissector to serialise with.
            WBDOMDissectedContentHandler dissectedContentHandler =
                    new WBDOMDissectedContentHandler(producer, conf, urlListener);
           
View Full Code Here

       
        String name = element.getName();
        boolean attributes = element.getAttributes() != null;
        // If we have a registered code for this element
        ElementNameCode nameCode = context.getElementNames().create(name);
        WBSAXContentHandler contentHandler = context.getContentHandler();
        if (nameCode != null) {
            // Start the element with the name code
            contentHandler.startElement(nameCode, attributes, content);
        } else {
            // There was no code for the element in the token table.
            // So, we fall back to starting the element with a literal
            // name, and hope the device understands it.
            StringReference nameRef =
                    context.getReferences().createReference(name);
            contentHandler.startElement(nameRef, attributes, content);
        }
        if (attributes) {
            contentHandler.startAttributes();
   
            for (Attribute attribute = element.getAttributes();
                 attribute != null;
                 attribute = attribute.getNext()) {

                String attrName = attribute.getName();
                String attrValue = attribute.getValue();

                // NOTE: code below is a kind of generic attribute value
                // processor - it searches all attribute names rather than
                // the more specific kind we have already implemented. Then
                // we could register it externally if finalOutput was true.
                   
                // If we are generating the final output (no WBDOM) and
                //   the attribute had a value and
                //   we are listening for urls and
                //   this attribute is registered as containing a URL...
                if (context.isFinalOutput() && attrValue != null &&
                        context.getUrlListener() != null &&
                        context.getConfiguration().isURLAttribute(name,
                                attrName)) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Generating URL Attribute Event " +
                                "for: " + name + " " + attrName + "='" +
                                attrValue + "'");
                    }
                    // Then generate the URL event for the listener.
                    context.getUrlListener().foundURL(attrValue);
                }
                   
                // Add the attribute start code
                AttributeStartCode attrStart =
                        context.getAttributeStarts().create(attrName, attrValue);
                contentHandler.addAttribute(attrStart);
                   
                // And figure out how to add the attribute value...
                // If the start code included a prefix
                String prefix = attrStart.getValuePrefix();
                if (prefix != null) {
                    // Remove the prefix from the value we are about to add
                    // as a string.
                    attrValue = attrValue.substring(prefix.length());
                }
                   
                // Process the attribute value.
                // Here we attempt to look up a registered attribute
                // processor and if that fails we fall back to the default.
                WBSAXValueProcessor attrValueProcessor =
                        context.getAttributeValueProcessor(attrName);
                if (attrValueProcessor == null) {
                    attrValueProcessor = defaultAttributeValueProcessor;
                }
                attrValueProcessor.value(attrValue.toCharArray(),
                        attrValue.length());
            }
            contentHandler.endAttributes();
        }
    }
View Full Code Here

        ApplicationContext appContext =
            ContextInternals.getApplicationContext(requestContext);

        // If the accept headers indicate that WMLC is supported, create a
        // WBXML producer. If not, default to WMLProducer.
        WBSAXContentHandler handler = null;
        WBSAXDocumentOutputter wbsaxOutputter;
        WBSAXContentHandler producer;

        // If the user has not asked to know the output style of this protocol,
        // then we will not have calculated whether we will be generating WMLC.
        // In this case we better generate it now as we are about to need it.
        if (generateWMLC == null) {
View Full Code Here

                                    WBSAXProcessorContext processorContext,
                                    WBSAXContentHandler handler
                                    ) throws IOException, ProtocolException {

        URLOptimiser optimiser;
        WBSAXContentHandler filter;

        if (logger.isDebugEnabled()) {
            logger.debug("Using dissection");
        }
View Full Code Here

     * previous handler the current handler.
     *
     * @return the handler we were using up to this point.
     */
    public WBSAXContentHandler popHandler() {
        WBSAXContentHandler handler = this.handler;
        this.handler = (WBSAXContentHandler) handlerStack.pop();
        return handler;
    }
View Full Code Here

        this.urlAttributeConf = urlAttributeConf;
        this.urlListener = urlListener;
       
        this.buffer = new CharArrayWriter();
        // This will only be used to copy attribute values.
        WBSAXContentHandler copyHandler = new XMLProducer(buffer, buffer);
        this.teeHandler = new WBSAXTeeHandler(handler, copyHandler);
    }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.wbsax.WBSAXContentHandler

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.