Package com.volantis.mcs.dom

Examples of com.volantis.mcs.dom.Node


        Text text = domFactory.createText();
        Text textResult;
        String textMessage = "atishoo, atishoo, we all fall down";
        BasicMapperElement me = new BasicMapperElement("tr", element, false);
        BasicMapperElement mt = new BasicMapperElement("td", text, true);
        Node result;
        char[] textResultMessage;

        element.setName("br");
        text.append(textMessage);
View Full Code Here


     * Element sibling, the "clone" is made via a shallow copy. If the
     * sibling is non-null and is not a Text or Element node null is always
     * returned.
     */
    public Node getSiblingInstance() {
        Node result = null;

        if (sibling != null) {
            DOMFactory factory = sibling.getDOMFactory();
            if (sibling instanceof Element) {
                Element element;
View Full Code Here

public class WhiteSpaceInsideAndOutStrategy
        extends AbstractWhiteSpaceFixStrategy {

    // javadoc inherited
    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
View Full Code Here

public class NonBreakingSpaceOutsideStrategy
        extends AbstractWhiteSpaceFixStrategy {

    // 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
View Full Code Here

     * @param pageContext       the page context.
     */
    protected Node getInsertAfterNode(
            ContainerInstance containerInstance,
            MarinerPageContext pageContext) {
        Node result = null;
        if (containerInstance != null) {
            DOMOutputBuffer dom = (DOMOutputBuffer)
                    containerInstance.getCurrentBuffer();

            result = dom.getRoot().getTail();
View Full Code Here

            // Need to examine the children of the indivisible element to see
            // if it contains any anti-xxx elements that have an open
            // counterpart. If one is found we need to push the open
            // counterpart into the indivisible element and promote and then
            // remove the anti-element.
            Node x = element.getHead();
            while (x != null) {
                boolean removed = false;
                if (x instanceof Element) {
                    Element childElement = (Element) x;
                    String child = childElement.getName();

                    boolean pushedDown = false;

                    if (styleCfg.isAntiElement(child)) {
                        // Found an anti-element...push any open stylistic elements
                        // into this indivisible element.
                        Iterator stylisticElements = styleCfg.
                                getCounterpartElementNames(child);

                        while (stylisticElements.hasNext()) {
                            String stylisticElement =
                                    (String) stylisticElements.next();
                            if (tracker.isOpen(stylisticElement)) {
                                // This child is an anti-element and its
                                // counterpart is open. We need to push the
                                // counterpart into the  indivisible element.
                                pushCounterpartElementDown(element,
                                        stylisticElement);
                                pushedDown = true;
                                tracker.closed(stylisticElement);
                            }
                        }
                        if (pushedDown) {
                            // Promote and then remove anti-element.
                            childElement.promote(true);
                            removeElement(childElement);
                            removed = true;

                            // I have had an anti-element that has been
                            // promoted. The dom tree may have changed
                            // so we should terminate the traversal here.
                            // terminateTraversal = true;
                        } else {
                            // anti-element may be removed (but take care
                            // since we still want to continue this
                            // iteration.
                            removeElement(childElement);
                            removed = true;
                        }
                        // Start the traversal from the beginning again
                        // because we have promoted and/or removed a child
                        // element. Doing this is guarenteed to be fail-safe.
                        x = element.getHead();

                    } else {
                        // It is not an anti-element but its children may
                        // be or their children may be so we need to ensure
                        // that they are also visited.
                        visit(childElement);
                    }
                }
                if (!removed && (x != null)) {
                    x = x.getNext();
                }
            }
        }

        element.forEachChild(this);
View Full Code Here

     * @param element the element that will be used to push any of its style
     *                elements down
     */
    protected void pushStyleElementsDown(Element element) {
        if (element != null) {
            Node x = element.getHead();
            boolean modified;
            while (x != null) {
                modified = false;
                if (x instanceof Element) {
                    final Element child = ((Element) x);
                    String name = child.getName();

                    if (styleCfg.isAntiElement(name)) {
                        modified = true;
                        pushStyleElementsDown(child);

                    } else if (styleCfg.isStylisticElement(name)) {
                        pushStyleElementsDown(child);
                        pushElementDownToAllChildren(child, child.getHead(),
                                false, null);
                        modified = true;
                    }
                    if (modified) {
                        x = x.getNext();
                        removeElement(child);
                    }
                }
                // We need to check this since x may have been removed and
                // x was the only child.
                if (!modified && (x != null)) {
                    x = x.getNext();
                }
            }
        }
    }
View Full Code Here

            try {
                dom = getStrictStyledDOMHelper().parse(values[i][DOM]);
                dom.accept(new NullRemoverTreeVisitor());

                // 'html' node
                Node node = dom.getRootElement();
                assertTrue(node instanceof Element);
                assertEquals("html", ((Element)node).getName());

                node = ((Element) node).getHead();
                if (values[i][MATCH] != null) {
                    String nodeName = getNodeName(node);
                    while ((node != null) && !values[i][MATCH].equals(nodeName)) {
                        node = node.getNext();
                        nodeName = getNodeName(node);
                    }
                    assertEquals(values[i][MATCH], nodeName);
                }
                assertNotNull(node);
                // Previous sibling test
                Node testNode = divRemover.findSibling(node.getPrevious(), false);
                assertEquals("TestPrev " + i, values[i][EXPECTED_PREVIOUS], getNodeName(testNode));

                // Next sibling test
                testNode = divRemover.findSibling(node.getNext(), true);
                assertEquals("TestNext " + i, values[i][EXPECTED_NEXT], getNodeName(testNode));
View Full Code Here

     */
    private void updateParentReferences(
            NodeImpl first, NodeImpl last,
            ElementImpl parent) {

        Node end = (last == null ? null : last.next);
        for (NodeImpl node = first; node != end; node = node.next) {
            node.parent = parent;
        }
    }
View Full Code Here

    // Javadoc inherited.
    public void forEach(NodeIteratee nodeIteratee) {
        if (first != null) {

            Node end;
            if (last == null) {
                end = null;
            } else {
                end = last.getNext();
            }
            Node node = first;
            while (node != end) {
                // Get the next node before calling the iteratee just in case
                // it does anything to the current node, i.e. removes it.
                Node next = node.getNext();
                IterationAction action = nodeIteratee.next(node);
                if (action == IterationAction.BREAK) {
                    break;
                } else if (action != IterationAction.CONTINUE) {
                    throw new IllegalStateException(
View Full Code Here

TOP

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

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.