Example usage for org.jdom2.filter Filters element

List of usage examples for org.jdom2.filter Filters element

Introduction

In this page you can find the example usage for org.jdom2.filter Filters element.

Prototype

public static final Filter<Element> element() 

Source Link

Document

Return a Filter that matches any Element data.

Usage

From source file:AIR.Common.xml.XmlElement.java

License:Open Source License

public List<Element> selectNodes(String xpath) {
    XPathFactory factory = XPathFactory.instance();
    XPathExpression<Element> expr = factory.compile(xpath, Filters.element());
    return expr.evaluate(_element);
}

From source file:AIR.Common.xml.XmlElement.java

License:Open Source License

public List<Element> selectNodes(String xpath, XmlNamespaceManager nsmgr) {
    XPathFactory factory = XPathFactory.instance();
    XPathExpression<Element> expr = factory.compile(xpath, Filters.element(), null, nsmgr.getNamespaceList());
    return expr.evaluate(_element);
}

From source file:AIR.Common.xml.XmlElement.java

License:Open Source License

public Element selectSingleNode(String xpath, XmlNamespaceManager nsmgr) {
    XPathFactory factory = XPathFactory.instance();
    XPathExpression<Element> expr = factory.compile(xpath, Filters.element(), null, nsmgr.getNamespaceList());
    return expr.evaluateFirst(_element);
}

From source file:AIR.Common.xml.XmlElement.java

License:Open Source License

public Element selectSingleNode(String xpath) {
    XPathFactory factory = XPathFactory.instance();
    XPathExpression<Element> expr = factory.compile(xpath, Filters.element());
    return expr.evaluateFirst(_element);
}

From source file:AIR.Common.xml.XmlElement.java

License:Open Source License

public List<Element> getElementsByTagName(String name) {
    List<Element> list = new ArrayList<Element>();
    if (!(_element instanceof Element))
        return list;

    Iterator<Element> it = ((Element) _element).getDescendants(Filters.element());

    while (it.hasNext()) {
        Element e = it.next();// ww w .  j  av  a  2  s .com
        if (e.getName().equals(name)) {
            list.add(e);
        }
    }
    return list;
}

From source file:ataraxis.passwordmanager.XMLHandler.java

License:Open Source License

/**
 * Delete the Element with the ID ElementID and all sub-Elements
 *
 * @param ElementID ID of Element /*from   ww w .j av  a  2  s.c om*/
 * @throws JDOMException if Element does not exist
 */
private void deleteElement(String ElementID) throws JDOMException {
    XPathExpression<Element> xpath = XPathFactory.instance().compile("//*[@id='" + ElementID + "']",
            Filters.element());
    Element el = xpath.evaluateFirst(s_doc);

    if (el != null) {
        el.detach();
    } else {
        throw new JDOMException("Element not Found");
    }
}

From source file:ataraxis.passwordmanager.XMLHandler.java

License:Open Source License

/**
 * Returns true if the Element exist, false otherwise
 * //from  w w w  .ja  va2 s .c o m
 * @param ElementID the ID of the Element
 * @return true if exist, false otherwise
 */
public boolean existID(String EntryID) {
    boolean exist = false;

    try {
        XPathExpression<Element> xpath = XPathFactory.instance().compile("//*[@id='" + EntryID + "']",
                Filters.element());
        Element tempElement = xpath.evaluateFirst(s_doc);

        if (tempElement != null)
            exist = true;
    } catch (Exception e) {
        logger.debug("Element " + EntryID + " NOT found");
    }

    return exist;
}

From source file:ataraxis.passwordmanager.XMLHandler.java

License:Open Source License

/**
 * Check if ElementID is a Element of type group
 * //from  w w  w.j  a v a  2 s . c o m
 * @param ElementID the ID of the Element
 * @return true if it is a group, false otherwise
 */
public boolean isGroupElement(String ElementID) {
    boolean isGroupElement = false;

    try {
        XPathExpression<Element> xpath = XPathFactory.instance().compile("//group[@id='" + ElementID + "']",
                Filters.element());
        Element tempElement = xpath.evaluateFirst(s_doc);

        if (tempElement != null) {
            isGroupElement = true;
        }
    } catch (Exception e) {
        logger.debug("Element " + ElementID + " NOT found");
    }

    return isGroupElement;
}

From source file:ataraxis.passwordmanager.XMLHandler.java

License:Open Source License

/**
 * Return a List of all groups/*from   ww  w  .  j a v a2  s  .  com*/
 * @return the GroupList
 * @throws JDOMException by problems with JDOM 
 */
private List<Element> getGroupList() throws JDOMException {
    XPathExpression<Element> xpath = XPathFactory.instance().compile("//group", Filters.element());
    return xpath.evaluate(s_doc);
}

From source file:ataraxis.passwordmanager.XMLHandler.java

License:Open Source License

/**
 * Return a List of all entries/*from  w w  w  .ja  v  a  2  s .  co m*/
 * @return the GroupList
 * @throws JDOMException by problems with JDOM 
 */
private List<Element> getAccountList() throws JDOMException {
    XPathExpression<Element> xpath = XPathFactory.instance().compile("//account", Filters.element());
    return xpath.evaluate(s_doc);
}