Package org.jdom

Examples of org.jdom.Text


    }
   
    private Element createInheritedElement(String inheritedFrom) {
        Element inheritedElm = new Element(E_INHERITED, DNSP);
        Element hrefElm = new Element(E_HREF, DNSP);
        hrefElm.addContent(new Text(inheritedFrom));
        inheritedElm.addContent(hrefElm);
        return inheritedElm;
    }
View Full Code Here


            Element selfElm = new Element(E_SELF, DNSP);
            principalElm.addContent(selfElm);
        }
        else {
            Element hrefElm = new Element(E_HREF, DNSP);
            hrefElm.addContent(new Text(subjectUri));
            principalElm.addContent(hrefElm);
        }
        return principalElm;
    }
View Full Code Here

        }

        String[] children = {"done-flag", "uri-template"};
        for (String child : children) {
            Element childEle = new Element(child);
            childEle.setContent(new Text(((String) eval.getVariable(dataInName + "." + child)).replace('%', '$')));
            dsEle.getChildren().add(childEle);
        }

        String[] eleChildren = {"start-instance", "end-instance"};
        for (String child : eleChildren) {
            Element childEle = new Element(child);
            childEle.setContent(new Text("${" + ((String) eval.getVariable(dataInName + "." + child)) + "}"));
            ele.getChildren().add(childEle);
        }

        return ele;
    }
View Full Code Here

                }
                else if( o instanceof Element ) {
                    add((Element)o);
                }
                else if( o instanceof Text ) {
                    Text t = (Text)o;
                    t.setText( t.getTextTrim() );
                    add(t);
                }
                else if( o instanceof Comment ) {
                    add((Comment)o);
                }
View Full Code Here

            if (o instanceof Element && E_HREF.equals(((Element)o).getName())) {
                Element hrefElm = (Element)o;
                String href = hrefElm.getTextTrim();
                if (href.startsWith(servletContext)) {
                    hrefElm.setContent(java.util.Arrays.asList(
                                           new Text[]{new Text(href.substring(servletContext.length()))}));
                }
            }
        }
    }
View Full Code Here

     * @param element The element to update, must not be <code>null</code>.
     * @param value   The text string to set, must not be <code>null</code>.
     */
    private void rewriteValue( Element element, String value )
    {
        Text text = null;
        if ( element.getContent() != null )
        {
            for ( Iterator<?> it = element.getContent().iterator(); it.hasNext(); )
            {
                Object content = it.next();
                if ( ( content instanceof Text ) && ( (Text) content ).getTextTrim().length() > 0 )
                {
                    text = (Text) content;
                    while ( it.hasNext() )
                    {
                        content = it.next();
                        if ( content instanceof Text )
                        {
                            text.append( (Text) content );
                            it.remove();
                        }
                        else
                        {
                            break;
                        }
                    }
                    break;
                }
            }
        }
        if ( text == null )
        {
            element.addContent( value );
        }
        else
        {
            String chars = text.getText();
            String trimmed = text.getTextTrim();
            int idx = chars.indexOf( trimmed );
            String leadingWhitespace = chars.substring( 0, idx );
            String trailingWhitespace = chars.substring( idx + trimmed.length() );
            text.setText( leadingWhitespace + value + trailingWhitespace );
        }
    }
View Full Code Here

                Element artifactIdElement = rootElement.getChild( "artifactId", namespace );
                int index = rootElement.indexOf( artifactIdElement );

                versionElement = new Element( "version", namespace );
                versionElement.setText( version );
                rootElement.addContent( index + 1, new Text( "\n  " ) );
                rootElement.addContent( index + 2, versionElement );
            }
        }
        else
        {
View Full Code Here

     * @param element The element to update, must not be <code>null</code>.
     * @param value   The text string to set, must not be <code>null</code>.
     */
    private void rewriteValue( Element element, String value )
    {
        Text text = null;
        if ( element.getContent() != null )
        {
            for ( Iterator<?> it = element.getContent().iterator(); it.hasNext(); )
            {
                Object content = it.next();
                if ( ( content instanceof Text ) && ( (Text) content ).getTextTrim().length() > 0 )
                {
                    text = (Text) content;
                    while ( it.hasNext() )
                    {
                        content = it.next();
                        if ( content instanceof Text )
                        {
                            text.append( (Text) content );
                            it.remove();
                        }
                        else
                        {
                            break;
                        }
                    }
                    break;
                }
            }
        }
        if ( text == null )
        {
            element.addContent( value );
        }
        else
        {
            String chars = text.getText();
            String trimmed = text.getTextTrim();
            int idx = chars.indexOf( trimmed );
            String leadingWhitespace = chars.substring( 0, idx );
            String trailingWhitespace = chars.substring( idx + trimmed.length() );
            text.setText( leadingWhitespace + value + trailingWhitespace );
        }
    }
View Full Code Here

                Element artifactIdElement = rootElement.getChild( "artifactId", namespace );
                int index = rootElement.indexOf( artifactIdElement );

                versionElement = new Element( "version", namespace );
                versionElement.setText( version );
                rootElement.addContent( index + 1, new Text( "\n  " ) );
                rootElement.addContent( index + 2, versionElement );
            }
        }
        else
        {
View Full Code Here

        // only a positive integer value is allowed as the content for the
        // quantity element.
        Element item = getChild(root, "item");
        Element quantity = getChild(item, "quantity");
        // set the content of the quantity element to a string
        quantity.addContent(new Text("hello"));

        // calculate the expcted error path /shiporder/item[1]/quantity
        String expectedErrorPath = "/" + getQName("shiporder") +
                                   "/" + getQName("item[1]") +
                                   "/" + getQName("quantity");
View Full Code Here

TOP

Related Classes of org.jdom.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.