Package org.dom4j

Examples of org.dom4j.Element


     * @param show the presence show value.
     * @throws IllegalArgumentException if the presence type is not available.
     * @see Show
     */
    public void setShow(Show show) {
        Element showElement = element.element("show");
        // If show is null, clear the subject.
        if (show == null) {
            if (showElement != null) {
                element.remove(showElement);
            }
            return;
        }
        if (showElement == null) {
            if (!isAvailable()) {
                throw new IllegalArgumentException("Cannot set 'show' if 'type' attribute is set.");
            }
            showElement = element.addElement("show");
        }
        showElement.setText(show.toString());
    }
View Full Code Here


     * of availability status.
     *
     * @param status the status.
     */
    public void setStatus(String status) {
        Element statusElement = element.element("status");
        // If subject is null, clear the subject.
        if (status == null) {
            if (statusElement != null) {
                element.remove(statusElement);
            }
            return;
        }

        if (statusElement == null) {
            statusElement = element.addElement("status");
        }
        statusElement.setText(status);
    }
View Full Code Here

    public void setPriority(int priority) {
        if (priority < -128 || priority > 128) {
            throw new IllegalArgumentException("Priority value of " + priority +
                    " is outside the valid range of -128 through 128");
        }
        Element priorityElement = element.element("priority");
        if (priorityElement == null) {
            priorityElement = element.addElement("priority");
        }
        priorityElement.setText(Integer.toString(priority));
    }
View Full Code Here

        try {
            XMLWriter xmlWriter = new XMLWriter(fileOutputStream, OutputFormat.createPrettyPrint());

            Document document = DocumentHelper.createDocument();
            Element rootElement = document.addElement(rootElementTag);
            DOM4JSettingsNode settingsNode = new DOM4JSettingsNode(rootElement);
            for (int index = 0; index < serializables.length; index++) {
                SettingsSerializable serializable = serializables[index];
                try //don't let a single serializer stop the entire thing from being written in.
                    serializable.serializeOut(settingsNode);
View Full Code Here

            return;
        }

        try {
            XMLWriter xmlWriter = new XMLWriter(fileOutputStream, OutputFormat.createPrettyPrint());
            Element rootElement = settingsNode.getElement();
            rootElement.detach();

            Document document = DocumentHelper.createDocument(rootElement);

            xmlWriter.write(document);
        } catch (Throwable t) {
View Full Code Here

        return file;   //it already ends with the correct extension.
    }

    public static DOM4JSettingsNode createBlankSettings() {
        Document document = DocumentHelper.createDocument();
        Element rootElement = document.addElement("root");
        DOM4JSettingsNode settings = new DOM4JSettingsNode(rootElement);
        return settings;
    }
View Full Code Here

    /**
     * This returns the node that is a child of the specified parent that has the specified 'name' and an attribute with
     * the specified value. This is similar to the below getChild, but this requires a specific tag name.
     */
    public static Element getChild(Element parent, String tagName, String attribute, String attributeValue) {
        Element childElement = null;
        Iterator iterator = parent.elements(tagName).iterator();
        while (iterator.hasNext() && childElement == null) {
            childElement = (Element) iterator.next();
            String actualValue = childElement.attributeValue(attribute);
            if (!attributeValue.equals(actualValue)) {
                childElement = null;
            }
        }
        return childElement;
View Full Code Here

    public static List<Element> getChildren(Element parent, String tagName, String attribute, String attributeValue) {
        List<Element> children = new ArrayList<Element>();

        Iterator iterator = parent.elements(tagName).iterator();
        while (iterator.hasNext()) {
            Element childElement = (Element) iterator.next();
            String actualValue = childElement.attributeValue(attribute);
            if (attributeValue.equals(actualValue)) {
                children.add(childElement);
            }
        }
View Full Code Here

    /**
     * Thie returns the node that is a child of hte specified parent that has the specified attribute with the specified
     * value. This is similar to the above getChild, but no tag name is required.
     */
    public static Element getChild(Element parent, String attribute, String attributeValue) {
        Element childElement = null;
        Iterator iterator = parent.elements().iterator();
        while (iterator.hasNext() && childElement == null) {
            childElement = (Element) iterator.next();
            String actualValue = childElement.attributeValue(attribute);
            if (!attributeValue.equals(actualValue)) {
                childElement = null;
            }
        }
        return childElement;
View Full Code Here

    public static List<Element> getChildren(Element parent, String attribute, String attributeValue) {
        List<Element> children = new ArrayList<Element>();

        Iterator iterator = parent.elements().iterator();
        while (iterator.hasNext()) {
            Element childElement = (Element) iterator.next();
            String actualValue = childElement.attributeValue(attribute);
            if (attributeValue.equals(actualValue)) {
                children.add(childElement);
            }
        }
View Full Code Here

TOP

Related Classes of org.dom4j.Element

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.