List of usage examples for org.jdom2 JDOMException JDOMException
public JDOMException(String message)
Exception
with the given message. 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 a v a 2s. com * @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
/** * Return the Element with the ID ElementID * * @param ElementID the ID of the Element (group or account) * @throws JDOMException by problems with jdom */// www. ja v a 2 s . c o m private Element getElement(String ElementID) throws JDOMException { Element returnElement; XPathExpression<Element> xpath = XPathFactory.instance().compile("//*[@id='" + ElementID + "']", Filters.element()); Element tempElement = xpath.evaluateFirst(s_doc); if (tempElement != null) { returnElement = tempElement; } else { throw new JDOMException("Element not Found"); } return returnElement; }
From source file:de.smartics.maven.alias.domain.AliasesProcessor.java
License:Apache License
/** * Default constructor./*from w w w . j a v a 2s .c o m*/ * * @param source the source to read the alias XML document from. * @throws NullPointerException if {@code source} is <code>null</code>. * @throws IOException if the XML document cannot be read. * @throws JDOMException if the XML document cannot be parsed. */ public AliasesProcessor(final InputSource source) throws NullPointerException, IOException, JDOMException { if (source == null) { throw new NullPointerException("'source' must not be 'null'."); } final SAXBuilder sax = new SAXBuilder();// XMLReaders.XSDVALIDATING); this.doc = sax.build(source); this.nsAlias = doc.getRootElement().getNamespace(); final String uri = nsAlias.getURI(); if (!uri.startsWith(SUPPORTED_NAMESPACE_PREFIX)) { throw new JDOMException( "The namespace '" + nsAlias + "' is not supported. Namespace is required to start with '" + SUPPORTED_NAMESPACE_PREFIX + "'."); } }