Package nu.xom

Examples of nu.xom.Comment


     * It does need to have the other pieces.
     */
    private static Element combineTextNodes(Element element) {

        Element stub = new Element("a");
        Comment stubc = new Comment("c");
        StringBuffer sb = new StringBuffer();
        int count = element.getChildCount();
        for (int i = 0; i < count; i++) {
            Node child = element.getChild(i);
            if (child instanceof Text) {
                sb.setLength(0);
                do {
                    sb.append(child.getValue());
                    i++;
                    if (i == count) {
                        break;
                    }
                    child = element.getChild(i);
                } while (child instanceof Text);
                i--;
                stub.appendChild(sb.toString());
            }
            else {
                stub.appendChild(stubc.copy());
            }
        }       
        return stub;
       
    }
View Full Code Here


        }
        catch (IndexOutOfBoundsException success) {
            assertNotNull(success.getMessage());  
       
       
        nodes.append(new Comment("data"));
        try {
            nodes.get(-1);
            fail("Didn't throw IndexOutOfBoundsException for -1");
        }
        catch (IndexOutOfBoundsException success) {
View Full Code Here

        Nodes nodes = new Nodes();
        int length = 10;
        for (int i = 0; i < length; i++) {
            nodes.append(new Text(String.valueOf(i)));  
        }
        nodes.insert(new Comment("dTA"), 3);
        nodes.insert(new Comment("dTA"), 5);
        nodes.insert(new Comment("dTA"), 12);
        assertEquals(length+3, nodes.size());
        for (int i = 0; i < 3; i++) {
            assertEquals(String.valueOf(i), nodes.get(i).getValue());  
        }    
        assertEquals("dTA", nodes.get(3).getValue());
View Full Code Here

      throws IOException, SAXException, ParsingException {
       
        Element root = new Element("root");
        root.appendChild("   Lots of random text\n\n\n  ");
        Document doc = new Document(root);
        doc.insertChild(new Comment("some comment data"), 0)
        root.insertChild(new Comment("some comment data"), 0)
        doc.appendChild(new Comment("some comment data"))
        convertAndCompare(doc);
       
    }
View Full Code Here

        Builder builder = new Builder(new NodeFactory() {
           
            public Nodes makeDocType(String name, String publicID, String systemID) {
                Nodes result = new Nodes();
                result.append(new DocType(name, publicID, systemID));
                result.append(new Comment("sajdha"));
                result.append(new DocType(name, publicID, systemID));
                return result;
            }
           
        });
View Full Code Here

        String data = "<root/>";  
        Builder builder = new Builder(new NodeFactory() {
           
            public Nodes finishMakingElement(Element element) {
                Nodes result = new Nodes();
                result.append(new Comment("test"));
                result.append(new Element("newroot"));
                result.append(new ProcessingInstruction("test", "test"));
                return result;  
            }
           
View Full Code Here

        String data = "<root/>";  
        Builder builder = new Builder(new NodeFactory() {
           
            public Nodes finishMakingElement(Element element) {
                Nodes result = new Nodes();
                result.append(new Comment("test"));
                result.append(element);
                result.append(new ProcessingInstruction("test", "test"));
                return result;  
            }
           
View Full Code Here

        String data = "<root/>";  
        Builder builder = new Builder(new NodeFactory() {
           
            public Nodes finishMakingElement(Element element) {
                Nodes result = new Nodes();
                result.append(new Comment("test"));
                result.append(new ProcessingInstruction("test", "test"));
                return result;  
            }
           
        });
View Full Code Here

        super(name);
    }

   
    public void testConstructor() {
        Comment c1 = new Comment("test");
        assertEquals("test", c1.getValue());
        Comment c2 = new Comment("");
        assertEquals("", c2.getValue());
    }
View Full Code Here

        assertEquals("", c2.getValue());
    }

   
    public void testCopyConstructor() {
        Comment c1 = new Comment("test");
        Comment c2 = new Comment(c1);
        assertEquals("test", c2.getValue());
        assertEquals(c1.getValue(), c2.getValue());
        assertTrue(c1 != c2);    
    }
View Full Code Here

TOP

Related Classes of nu.xom.Comment

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.