Package org.jdom

Examples of org.jdom.Text


        verifyObjectState(new ODOMXPath(attribute, NAMESPACES), xpath, map);

        // Check using text.
        xpath = "/parent/text()";
        parent = new Element("parent");
        Text text = new Text("textExample");
        parent.addContent(text);
        verifyObjectState(new ODOMXPath(text), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(text, namespacesNull), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(text, NAMESPACES), xpath, map);

        // Check using ODOMObservable.
        xpath = "/parent/textExample";
        parent = new Element("parent");
        ODOMObservable node = (ODOMElement) factory.element("textExample");
        parent.addContent((Element) node);
        verifyObjectState(new ODOMXPath(node), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(node, namespacesNull), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(node, NAMESPACES), xpath, map);

        // Check using element.
        xpath = "/parent/element";
        parent = new Element("parent");
        Element start = new Element("startElement");
        element = new Element("element");
        parent.addContent(element);
        verifyObjectState(new ODOMXPath(start, element), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(start, element, namespacesNull), xpath,
                          emptyMap);
        verifyObjectState(new ODOMXPath(start, element, NAMESPACES), xpath, map);

        // Check using attribute.
        xpath = "/parent/@attribute";
        parent = new Element("parent");
        start = new Element("startElement");
        attribute = new Attribute("attribute", "");
        parent.setAttribute(attribute);
        verifyObjectState(new ODOMXPath(start, attribute), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(start, attribute, namespacesNull), xpath,
                          emptyMap);
        verifyObjectState(new ODOMXPath(start, attribute, NAMESPACES), xpath, map);

        // Check using text.
        xpath = "/parent/text()";
        parent = new Element("parent");
        text = new Text("textExample");
        parent.addContent(text);
        start = new Element("startElement");
        verifyObjectState(new ODOMXPath(start, text), xpath, emptyMap);
        verifyObjectState(new ODOMXPath(start, text, namespacesNull), xpath,
                          emptyMap);
View Full Code Here


            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

        try {
            new ODOMXPath(new Text(""));
            fail("Expected an exception.");
        } catch (IllegalArgumentException e) {
        }

    }
View Full Code Here

        ODOMObservable removed = path.remove((ODOMObservable) root);

        assertNotNull("Removed element should exist", removed);
        assertTrue("Should be a Text node", removed instanceof Text);
        Text element = (Text) removed;
        assertEquals("Value should match", "Empire Burlesque",
                     element.getText());
    }
View Full Code Here

                    depthFirstTraversal((ODOMObservable) children.get(i));
                }
                List list = ((Element) node).getContent(filter);
                if ((list != null) && (list.size() > 0)) {
                    for (int i = 0; i < list.size(); i++) {
                        Text text = (Text) list.get(i);
                        if (text.getText().trim().length() > 0) {
                            System.out.println(new ODOMXPath(text).getExternalForm() +
                                               "-->" + text.getText());
                        }
                    }
                }
            }
            System.out.println(new ODOMXPath(node).getExternalForm());
View Full Code Here

     * garbage.
     */
    public Text setText(String text) {
        String oldText = getText();

        Text result = super.setText(text);

        fireChange(oldText, text, ChangeQualifier.TEXT);

        return result;
    }
View Full Code Here

    protected Text setParent(Element parent) {
        // obtain a reference to the old parent as we will need to notify it
        // that it has changed.
        Element oldParent = getParent();
        // set the new parent
        Text result = super.setParent(parent);

        // fire a change event. This will notify the new parent that the
        // hierarchy has changed
        ODOMChangeEvent event =
                fireChange(oldParent, parent, ChangeQualifier.HIERARCHY);
View Full Code Here

     * garbage.
     */
    public Text detach() {
        // No event trigger is required here since the superclass version will
        // end up calling {@link Text#setParent} with null anyway
        Text detachedText = super.detach();
        if (detachedText != null && changeSupport != null) {
            changeSupport.outputListenerWarnings();
        }
        return detachedText;
    }
View Full Code Here

            result = (ODOMObservable) attribute;

        } else if (xPathToken.startsWith(XPATH_TEXT_FUNCTION)) {
            // The token is a text item, to create a new text item and add
            // it to the context (if it is not found).
            Text text = factory.text("");
            context.addContent(text);
            result = (ODOMObservable) text;

        } else {
            Element element = createODOMElement(factory, xPathToken);
View Full Code Here

     * garbage.
     */
    public Text setText(String text) {
        String oldText = getText();

        Text result = super.setText(text);

        fireChange(oldText, text, ChangeQualifier.TEXT);

        return result;
    }
View Full Code Here

        // obtain a reference to the old parent as we will need to notify it
        // that it has changed.
        Element oldParent = getParent();

        // set the new parent
        Text result = super.setParent(parent);

        // fire a change event. This will notify the new parent that the
        // hierarchy has changed
        ODOMChangeEvent event =
                fireChange(oldParent, parent, ChangeQualifier.HIERARCHY);
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.