Package com.volantis.mcs.wbsax

Examples of com.volantis.mcs.wbsax.AttributeStartCode


       
        // Send a href event to optimiser
        AttributeStartFactory attributeStartFactory = new AttributeStartFactory();
        TokenTable tokenTable = new WMLVersion1_1TokenTable();
        tokenTable.registerAttrStarts(attributeStartFactory);
        AttributeStartCode hrefStartCode
             = attributeStartFactory.create("href", null);
        optimiser.addAttribute(hrefStartCode);
       
        // send url to optimiser
        optimiser.addAttributeValue(new WBSAXString(codec,
            "http://www.my.com/page.jsp;jsessionid=123?parm=value#ref"));
       
        // Send a title event to optimiser
        AttributeStartCode titleStartCode
            = attributeStartFactory.create("title", null);
        optimiser.addAttribute(titleStartCode);
       
        // Send the value of the title to optimiser
        optimiser.addAttributeValue(new WBSAXString(codec, "my title"));

        // Send another href to optimiser
        optimiser.addAttribute(hrefStartCode);
       
        // send url to optimiser
        optimiser.addAttributeValue(new WBSAXString(codec,
            "http://www.my.com/page2.jsp;jsessionid=123?parm=value#ref2"));
       
        // Get the events      
        Iterator events = contentHandler.getEvents();
       
        // Check startDocument
        assertEquals("Wrong versionCode", versionCode,
                     (VersionCode)events.next());
        assertEquals("Wrong publicIdCode", publicIdCode,
                     (PublicIdCode)events.next());
        assertEquals("Wrong codec", codec, (Codec)events.next());       

        // Skip past the StringTable created by the optimiser
        assertTrue("StringTable should be next",
                   events.next() instanceof StringTable);
       
        // Check href
        AttributeStartCode aStartCode = (AttributeStartCode)events.next();
        assertEquals("Wrong AttributeStartCode integer", 0x4A,
                     aStartCode.getInteger());
        assertEquals("Wrong AttributeStartCode name", "href",
                     aStartCode.getName());
        assertNull("Wrong AttributeStartCode value prefix",
                   aStartCode.getValuePrefix());
       
        // Check prefix
        assertEquals("Wrong url prefix",
                     new WBSAXString(codec, "http://www.my.com/page.jsp"),
                     (WBSAXString)events.next());
       
        // Check jsessionid
        StringReference stringReference1 = (StringReference)events.next();       
        assertEquals("Wrong url jsessionid",
                     new WBSAXString(codec, ";jsessionid=123"),
                     stringReference1.resolveString());
       
        // Check suffix
        assertEquals("Wrong url suffix",
                     new WBSAXString(codec, "?parm=value#ref"),
                     (WBSAXString)events.next());
       
        // Check title
        aStartCode = (AttributeStartCode)events.next();
        assertEquals("Wrong AttributeStartCode integer", 0x36,
                     aStartCode.getInteger());
        assertEquals("Wrong AttributeStartCode name", "title",
                     aStartCode.getName());
        assertNull("Wrong AttributeStartCode value prefix",
                   aStartCode.getValuePrefix());
       
        // Check title's value       
        assertEquals("Wrong title",
                     new WBSAXString(codec, "my title"),
                     (WBSAXString)events.next());
       
        // Check href
        aStartCode = (AttributeStartCode)events.next();
        assertEquals("Wrong AttributeStartCode integer", 0x4A,
                     aStartCode.getInteger());
        assertEquals("Wrong AttributeStartCode name", "href",
                     aStartCode.getName());
        assertNull("Wrong AttributeStartCode value prefix",
                   aStartCode.getValuePrefix());
       
        // Check prefix
        assertEquals("Wrong url prefix",
                     new WBSAXString(codec, "http://www.my.com/page2.jsp"),
                     (WBSAXString)events.next());
View Full Code Here


                    // 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());
                }
View Full Code Here

        writer.print(string);
    }
       
    // Inherit Javadoc.
    public void visitCodeProvider(CodedNameProvider code) throws WBDOMException {
        AttributeStartCode startCode = (AttributeStartCode)code.getCodedName();
        print(startCode.getName() + "=" + startCode.getValuePrefix());
    }
View Full Code Here

TOP

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

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.