/** * Get the text contents of the current {@link Element Element}, if it exists, is non-empty and * has local name <i>name</i>, as an <code>boolean</code>. * * <p>The cursor will only be moved forward if the local element name matches <i>name</i>. * * @param name The local element name to test for. * @param defaultValue The <code>boolean</code> value to return if the element does not exist. * @return The text contents of the current {@link Element Element} as an <code>boolean</code>, if * it exists, is non-empty and has local name <i>name</i>, <i>defaultValue</i> otherwise. * @throws NoSuchElementException If the current element has local name <i>name</i> but has * non-text content. * @throws IllegalArgumentException If the current element has local name <i>name</i> and has * text-only content that cannot be parsed as an <code>boolean</code>. */ public boolean getBooleanConditional(String name, boolean defaultValue) throws NoSuchElementException { String s = getStringConditional(name); return s != null ? DOMUtil.booleanValue(s) : defaultValue; }
/** * Get the text contents of the current {@link Element Element}, which must have local name * <i>name</i>, as an <code>boolean</code>. * * @param name The local element name expected. * @return The text contents of the current {@link Element Element}, as an <code>boolean</code>. * @throws NoSuchElementException if the current element has non-text content, if it's local name * is not <i>name</i> or if there is no current element. * @throws IllegalArgumentException if the current element has local name <i>name</i> and is empty * or has text-only content that cannot be parsed as an <code>boolean</code>. */ public boolean getBoolean(String name) throws NoSuchElementException { return DOMUtil.booleanValue(getString(name)); }