Package com.volantis.mcs.dom

Examples of com.volantis.mcs.dom.Text


                            "Document cannot have multiple elements at the " +
                                    "root, found " + root.getName() + " and " +
                                    element.getName());
                }
            } else if (node instanceof Text) {
                Text text = (Text) node;
                if (!text.isWhitespace()) {
                    throw new IllegalStateException(
                            "Document cannot have non whitespace text node " +
                                    "at the root, found {" +
                                    new String(text.getContents(), 0,
                                            text.getLength()) +
                                    "}");
                }
            } else if (node instanceof Comment) {
                // Ignore comments at the top level.
            } else {
View Full Code Here


                element.copy(prototype);

                result = element;
            } else if (sibling instanceof Text) {
                Text text;
                Text prototype = (Text)sibling;

                text = factory.createText();

                text.append(prototype.getContents(), 0, prototype.getLength());
                text.setEncoded(prototype.isEncoded());

                result = text;
            }
        }
View Full Code Here

    public void fixUpSpace(Element element, boolean isOpen) {
        Node left = (isOpen) ? element.getPrevious() : element.getTail();
        Node right = (isOpen) ? element.getHead() : element.getNext();

        if (left instanceof Text && right instanceof Text) {
            Text leftText = (Text) left;
            Text rightText = (Text) right;
            // append a whitespace to the previous
            leftText.append(SINGLE_WHITESPACE);

            // prepend append a whitespace to next
            prependText(rightText, SINGLE_WHITESPACE);
View Full Code Here

        root.addTail(child2);

        Element child3 = domFactory.createElement();
        child3.setName("child3");
        child3.setAttribute("href", "<24 inches>");
        Text text = domFactory.createText();
        text.append("This is some text for \"Child3\"");
        child3.addHead(text);
        child2.addHead(child3);

        child3 = domFactory.createElement("script");
        text = domFactory.createText();
        text.append("This is some text for <script>");
        child3.addHead(text);
        child2.addTail(child3);

        child3 = domFactory.createElement("style");
        text = domFactory.createText();
        text.append("This is some text for <style>");
        child3.addHead(text);
        child2.addTail(child3);

        child3 = domFactory.createElement("p");
        text = domFactory.createText();
        text.append("This is some text for <paragraph>");
        child3.addHead(text);
        child2.addTail(child3);

        child3 = domFactory.createElement("p");
        text = domFactory.createText();
        text.append("This <node> is \"Text\" and already encoded.");
        text.setEncoded(true);
        child3.addHead(text);
        child2.addTail(child3);


    }
View Full Code Here

        root.addTail(child2);

        Element child3 = domFactory.createElement();
        child3.setName("child3");
        child3.setAttribute("href", "24 inches");
        Text text = domFactory.createText();
        text.append("This is some text for \"Child3\"");
        child3.addHead(text);

        text = domFactory.createText();
        text.append("This <node> is \"Text\" and already encoded.");
        text.setEncoded(true);
        child3.addTail(text);

        child2.addHead(child3);
    }
View Full Code Here

        return new TextImpl(this);
    }

    // Javadoc inherited.
    public Text createText(String contents) {
        Text text = new TextImpl(this);
        text.append(contents);
        return text;
    }
View Full Code Here

        final MetaData metaData = (MetaData) metaDataMap.get("fragment-link-id");

        DOMOutputBuffer value = (DOMOutputBuffer) metaData.getPropertyValue(
            MetaPropertyHandlerFactory.FRAGMENT_LINK_LABEL);
        assertNotNull(value);
        Text head = (Text) value.getRoot().getHead();
        assertEquals("link text 1",
            new String(head.getContents(), 0, head.getLength()));
        Element heading = (Element) head.getNext();
        Text headingText = (Text) heading.getHead();
        assertEquals("link heading",
            new String(headingText.getContents(), 0, headingText.getLength()));
        Text tail = (Text) heading.getNext();
        assertEquals("link text 2",
            new String(tail.getContents(), 0, tail.getLength()));
        assertNull(tail.getNext());

        value = (DOMOutputBuffer) metaData.getPropertyValue(
            MetaPropertyHandlerFactory.ENCLOSING_FRAGMENT_LINK_LABEL);
        assertNotNull(value);
        head = (Text) value.getRoot().getHead();
View Full Code Here

    // javadoc inherited
    public void fixUpSpace(Element element, boolean isOpen) {
        Node node = (isOpen) ? element.getPrevious() : element.getNext();
        if (node instanceof Text) {
            Text text = (Text) node;
            if (isOpen) {
                // append the text to the previous element

                text.append(NON_BREAKING_SPACE);
                text.append(SINGLE_WHITESPACE);
            } else {
                // prepend the spaces
                prependText(text, NON_BREAKING_SPACE + SINGLE_WHITESPACE);
            }
        }
View Full Code Here

            }
        }
    }

    public void addText(String string) {
        Text text = factory.createText();
        text.append(string);
        addTail(text);
    }
View Full Code Here

                // Get the next node.
                Node next = element.getNext();

                if (next != null) {
                    if (next instanceof Text) {
                        Text text = (Text) next;

                        // If the next node is a piece of zero length text, we
                        // remove it and surround the following node with the
                        // keeptogether element.
                        if (text.getLength() == 0) {
                            next = text.getNext();
                            text.remove();
                            // Get the next node
                            continue;
                        }
                    }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.dom.Text

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.