Package com.volantis.mcs.dom

Examples of com.volantis.mcs.dom.Text


        Node child = element.getHead();

        StringBuffer content = new StringBuffer();
        for (child = element.getHead(); child!=null; child = child.getNext()) {
            if (child instanceof Text) {
                Text text = (Text)child;
                content.append(text.getContents(), 0, text.getLength());
            }
        }

        // MMS_SMIL layouts are so simple that the head and tail should point
        // to the same element.
View Full Code Here


        final Element second = (Element) first.getNext();
        assertEquals("script", second.getName());
        assertNull(second.getAttributeValue("src"));
        assertNull(second.getAttributeValue("charset"));
        assertEquals("text/javascript", second.getAttributeValue("type"));
        Text text = (Text) second.getHead();
        assertEquals("some javascript 2",
            new String(text.getContents(), 0, text.getLength()));

        final Element third = (Element) second.getNext();
        assertEquals("script", third.getName());
        assertNull(third.getAttributeValue("src"));
        assertNull(third.getAttributeValue("charset"));
        assertEquals("text/javascript", third.getAttributeValue("type"));
        text = (Text) third.getHead();
        assertEquals("some javascript 3",
            new String(text.getContents(), 0, text.getLength()));

        assertNull(third.getNext());
    }
View Full Code Here

                            createOrMergeElement(elementToPushDown, element);
                        }
                    }
                }
            } else if (x instanceof Text) {
                Text text = (Text) x;
                // We only push stylistic elements down so we don't need to
                // wrap the text in a stylistic element if the length is zero
                // or the parent of the text doesn't permit stylistic elements.
                String parentName = x.getParent().getName();
                boolean wrapNode = (text.getLength() > 0) && wrapNode(
                        parentName, elementToPushDown.getName());

                if ((wrapNode)) {
                    // Processing a text node so create a new clone of the
                    // stylistic element and add the text as a child of this
View Full Code Here

                important = false;
                for (Node child = element.getHead();
                     child != null && !important;
                     child = child.getNext()) {
                    if (child instanceof Text) {
                        final Text text = (Text) child;
                        important = text.getLength() > 0;
                    } else if (child instanceof Element){
                        final Element childElement = (Element)child;
                        if(isInlineElement(childElement.getName())){
                            // inline element can not have text-align defined
                            // so parent can not be removed because we property value
View Full Code Here

                for (Node child = element.getHead();
                     child != null && !important;
                     child = child.getNext()) {

                    if (child instanceof Text) {
                        final Text text = (Text) child;
                        important = text.getLength() > 0;
                    } else {
                        final Element childElement = (Element) child;
                        final Styles childStyles = childElement.getStyles();
                        if (childStyles != null) {
                            final PropertyValues childValues =
View Full Code Here

    public void visit(Element element) {

        // Does the current element belong to the list of elements
        // that need to have some sort of space added?
        if (element.getPrevious() instanceof Text) {
            Text text = (Text) element.getPrevious();
            WhiteSpaceFixStrategy strategy =
                    getWhiteSpaceFixStrategy(element, true);
            int whitespaceCount = 0;
            if (strategy != null &&
                (whitespaceCount =
                    removeAndCountTrailingWhiteSpace(text)) > 0) {
                for (int i=0; i<whitespaceCount; i++) {
                    strategy.fixUpSpace(element, true);
                }
            }
        }

        if (element.getNext() instanceof Text) {
            Text text = (Text) element.getNext();
            WhiteSpaceFixStrategy strategy =
                    getWhiteSpaceFixStrategy(element, false);
            int whitespaceCount = 0;
            if (strategy != null &&
                    (whitespaceCount =
View Full Code Here

        //emulated version
        Element newElement = element.getDOMFactory().createElement();
        newElement.setName("script");
        newElement.setAttribute("type","text/javascript");
        newElement.insertAfter(element);
        Text scriptContent = element.getDOMFactory().createText();

        String cornersScript = "Widget.addStartupItem(function(){Widget.register('"+ widgetID +"',new Widget.Corners('" + widgetID + "', [";
        cornersScript += "[";
        if(topLeftRadius != null) {
            cornersScript += "'" + ((StylePair)topLeftRadius).getFirst().getStandardCSS() + "'";
            cornersScript += ",'" + ((StylePair)topLeftRadius).getSecond().getStandardCSS() + "'";
        }
        cornersScript += "]";
        cornersScript += ",[";
        if(topRightRadius != null) {
            cornersScript += "'" + ((StylePair)topRightRadius).getFirst().getStandardCSS() + "'";
            cornersScript += ",'" + ((StylePair)topRightRadius).getSecond().getStandardCSS() + "'";
        }
        cornersScript += "]";
        cornersScript += ",[";
        if(bottomRightRadius != null) {
            cornersScript += "'" + ((StylePair)bottomRightRadius).getFirst().getStandardCSS() + "'";
            cornersScript += ",'" + ((StylePair)bottomRightRadius).getSecond().getStandardCSS() + "'";
        }
        cornersScript += "]";
        cornersScript += ",[";
        if(bottomLeftRadius != null) {
            cornersScript += "'" + ((StylePair)bottomLeftRadius).getFirst().getStandardCSS() + "'";
            cornersScript += ",'" + ((StylePair)bottomLeftRadius).getSecond().getStandardCSS() + "'";
        }
        cornersScript += "]";       
        cornersScript += "]))});";
       
        scriptContent.append(cornersScript);
        newElement.addHead(scriptContent);     
      
        //set startup onload body element
        setScriptStartup(body);
    }
View Full Code Here

                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }

                    // Create text node with serialized string.
                    Text text = protocol.getDOMFactory().createText();

                    text.append(writer.toString());

                    // Replace the element with its textualized form.
                    text.replace(element);
                } else {
                    element.forEachChild(this);
                }
            }
        };
View Full Code Here

        } else {
            // Try and reuse existing Text nodes if we can.
            Node previous = currentPosition == null ?
                    currentElement.getTail() : currentPosition;
            if (previous instanceof Text) {
                Text text = (Text) previous;
                // If the encoding of the text node matches the encoding of
                // the text being added then we reuse it, otherwise we have to
                // create a new node.
                if (text.isEncoded() == preEncoded) {
                    node = text;
                }
            }
        }
View Full Code Here

            // Ensure that that child is a Text node.
            if (!(firstNode instanceof Text)) {
                throw new IllegalStateException("child is not Text");
            }

            Text text = (Text) firstNode;
            pcdata = new String(text.getContents(), 0, text.getLength());
        }
        // else the buffer is empty, so return null.

        return pcdata;
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.