Package com.volantis.mcs.dom

Examples of com.volantis.mcs.dom.Node


     *                                  the preceding-sibling axis.
     * @return a sibling <code>Node</code>, or null.
     */
    private Node getSiblingForRemovalTest(final Node ancestorOrSelfWithSibling,
                                          final boolean following) {
        Node sibling = null;
        if (ancestorOrSelfWithSibling != null) {
            sibling = following ? ancestorOrSelfWithSibling.getNext() :
                    ancestorOrSelfWithSibling.getPrevious();
            sibling = findSibling(sibling, following);
        }
View Full Code Here


     *                checked for a previous sibling.
     * @return true if the element has a non null sibling either immediately
     *         before or after it
     */
    private boolean hasSibling(Node node, boolean forward) {
        Node sibling = (forward ? node.getNext() : node.getPrevious());
        return sibling != null;
    }
View Full Code Here

     * @param following if <code>true</code> traverses the following-sibling
     *                  axis, otherwise traverse the preceding-sibling axis.
     * @return the valid sibling, or null if none is found.
     */
    protected Node findSibling(Node startNode, boolean following) {
        Node sibling = startNode;
        while (sibling != null) {
            Node node = sibling;
            if (node instanceof Element) {
                Element element = (Element) node;

                // If name is null drill down and try to find adjacent sibling
                // as a child of the current sibling.
View Full Code Here

         * @return                 the insert after node given the map and the
         *                         node.
         */
        private Node getInsertAfterNode(final Map nodeMap,
                                        final Node insertAfterNode) {
            Node result = null;
            if (insertAfterNode != null) {
                result = insertAfterNode;
                Node node = (Node) nodeMap.get(insertAfterNode);
                if (node != null) {
                    Node next = node.getNext();
                    if (next != null) {
                        result = next;
                    }
                }
                // Always update the map.
View Full Code Here

                entryPaneBuffer,
                captionPaneBuffer,
                dom
            );

            final Node insertAfterCaptionNode = selector.getInsertAfterCaptionNode();
            // Insert root of ONE buffer to insertAfter node
            if (insertAfterCaptionNode != null) {

                if (insertAfterCaptionNodeMap == null) {
                    insertAfterCaptionNodeMap = new HashMap();
                }
                selector.insertAfterCaptionNode(
                    getInsertAfterNode(insertAfterCaptionNodeMap,
                                       insertAfterCaptionNode));
            }

            if (selector.getInsertAfterEntryNode() != insertAfterCaptionNode) {
                // Both nodes are different (one may be null) so insert root
                // of each buffer to 'insertAfter' node.
                Node insertAfterEntryNode = selector.getInsertAfterEntryNode();
                if (insertAfterEntryNode != null) {
                    if (insertAfterEntryNodeMap == null) {
                        insertAfterEntryNodeMap = new HashMap();
                    }
                    selector.insertAfterEntryNode(
View Full Code Here

         */
        protected Element getFirstChildElement(Element element) {
            if (element == null) {
                return null;
            }
            Node node = element.getHead();
            while ((node != null) && !(node instanceof Element)) {
                node = node.getNext();
            }
            // Either null or Element
            return (Element) node;
        }
View Full Code Here

         *
         * @return the image node or null if no img element is found, the
         *         image's siblings are not whitespace or there is more than one img.
         */
        protected Node findImageNode(Node node) {
            Node imageNode = null;

            do {
                if (node instanceof Text) {
                    Text text = (Text) node;

View Full Code Here

        protected boolean eligibleForTransformation(
                Element tableElement,
                int rows,
                int columns) {
            if ((columns == 2) && (rows == 1)) {
                Node node = tableElement.getHead();

                if (matches(node, "tr")) {

                    // See if the 2nd column contains an image.
                    node = ((Element) node).getHead();

                    // 1st column
                    if (matches(node, "td")) {
                        node = node.getNext();
                        // 2nd column
                        if (matches(node, "td")) {
                            node = ((Element) node).getHead();
                            if (matches(node, "div")) {
                                node = ((Element) node).getHead();
View Full Code Here

         * @return true if the specified element encloses and combination
         *         of div and table elements, false otherwise.
         */
        protected boolean enclosesTableOrDivMarkup(Element element) {
            boolean enclosesTableOrDiv = true;
            Node child = element.getHead();
            while (enclosesTableOrDiv && child != null) {
                if (child instanceof Text) {
                    enclosesTableOrDiv = false;
                } else {
                    String childName = ((Element) child).getName();
                    if (!("table".equalsIgnoreCase(childName) ||
                            ("div".equalsIgnoreCase(childName)))) {
                        enclosesTableOrDiv = false;
                    }
                }
                child = child.getNext();
            }
            return enclosesTableOrDiv;
        }
View Full Code Here

         */
        private boolean tableElementHasContent(Element tableElement) {
            boolean hasContent = false;
            if ("table".equals(tableElement.getName())) {
                // Iterate through the rows to look for content.
                Node child = tableElement.getHead();
                while (child != null && !hasContent) {
                    if (child instanceof Element) {
                        hasContent = tableElementHasContent((Element) child);
                    }
                    if (!hasContent) {
                        child = child.getNext();
                    }
                }

            } else if ("tr".equals(tableElement.getName())) {
                // Iterate through the cells to look for content.
                Node child = tableElement.getHead();
                while (child != null && !hasContent) {
                    if (child instanceof Element) {
                        hasContent = tableElementHasContent((Element) child);
                    }
                    if (!hasContent) {
                        child = child.getNext();
                    }
                }
            } else if ("td".equals(tableElement.getName()) ||
                    "th".equals(tableElement.getName())) {

                // Iterate through the table children to look for content.
                Node child = tableElement.getHead();
                while (child != null && !hasContent) {
                    if (child instanceof Element) {
                        hasContent = true;
                    } else {
                        hasContent = ((Text) child).getLength() > 0;
                    }
                    child = child.getNext();
                }
            } else {
                // Non table, tr, td and th elements are considered to have
                // content.
                hasContent = true;
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.