/** * @param node * @param attr * @return The value of the given attribute, or null if not present. */ public static String getAttribute(Node node, String attr) { return getAttribute(node, attr, null); }
/** * @param node * @param attr * @return The value of the given attribute, or null if not present. */ public static String getAttribute(Node node, String attr) { return getAttribute(node, attr, null); }
/** * @param node * @param attr * @return The value of the given attribute, or null if not present. */ public static String getAttribute(Node node, String attr) { return getAttribute(node, attr, null); }
/** * @param node * @param attr * @return The value of the given attribute, or null if not present. */ public static String getAttribute(Node node, String attr) { return getAttribute(node, attr, null); }
/** * @param node * @param attr * @return The value of the given attribute, or null if not present. */ public static String getAttribute(Node node, String attr) { return getAttribute(node, attr, null); }
/** * @return An attribute coerced to an integer. */ public static int getIntAttribute(Node node, String attr, int def) { String value = getAttribute(node, attr); if (value == null) { return def; } try { return Integer.parseInt(value); } catch (NumberFormatException e) { return def; } }
private String getMethodAttribute(Element element) { String method = XmlUtil.getAttribute(element, "method"); return ("GET".equals(method) || "POST".equals(method)) ? method : "GET"; } }
/** * Currently does not validate icon data. * @param element */ public Icon(Element element) throws SpecParserException { mode = XmlUtil.getAttribute(element, "mode"); if (mode != null && !mode.equals("base64")) { throw new SpecParserException( "The only valid value for Icon@mode is \"base64\""); } type = XmlUtil.getAttribute(element, "type", ""); content = element.getTextContent(); }
/** * Currently does not validate icon data. * @param element */ public Icon(Element element) throws SpecParserException { mode = XmlUtil.getAttribute(element, "mode"); if (mode != null && !mode.equals("base64")) { throw new SpecParserException( "The only valid value for Icon@mode is \"base64\""); } type = XmlUtil.getAttribute(element, "type", ""); content = element.getTextContent(); }
/** * Constructs a message bundle from a /ModulePrefs/Locale with nested messages. * @param element XML Dom element to parse * @throws SpecParserException when badly formed xml is provided */ public MessageBundle(Element element) throws SpecParserException { messages = parseMessages(element); languageDirection = XmlUtil.getAttribute(element, "language_direction", "ltr"); }
/** * Constructs a message bundle from a /ModulePrefs/Locale with nested messages. * @param element XML Dom element to parse * @throws SpecParserException when badly formed xml is provided */ public MessageBundle(Element element) throws SpecParserException { messages = parseMessages(element); languageDirection = XmlUtil.getAttribute(element, "language_direction", "ltr"); }
/** * Constructs a message bundle from a /ModulePrefs/Locale with nested messages. * @param element XML Dom element to parse * @throws SpecParserException when badly formed xml is provided */ public MessageBundle(Element element) throws SpecParserException { messages = parseMessages(element); languageDirection = XmlUtil.getAttribute(element, "language_direction", "ltr"); }
public LinkSpec(Element element, Uri base) throws SpecParserException { this.base = base; rel = XmlUtil.getAttribute(element, "rel"); if (rel == null) { throw new SpecParserException("Link/@rel is required!"); } href = XmlUtil.getUriAttribute(element, "href"); if (href == null) { throw new SpecParserException("Link/@href is required!"); } }
public LinkSpec(Element element, Uri base) throws SpecParserException { this.base = base; rel = XmlUtil.getAttribute(element, "rel"); if (rel == null) { throw new SpecParserException("Link/@rel is required!"); } href = XmlUtil.getUriAttribute(element, "href"); if (href == null) { throw new SpecParserException("Link/@href is required!"); } }
@Test public void getAttribute() { assertEquals(STRING_VALUE, XmlUtil.getAttribute(node, STRING_ATTR)); assertEquals(STRING_VALUE, XmlUtil.getAttribute(node, FAKE_ATTR, STRING_VALUE)); assertNull("getAttribute must return null for undefined attributes.", XmlUtil.getAttribute(node, FAKE_ATTR)); }
@Test public void getAttribute() { assertEquals(STRING_VALUE, XmlUtil.getAttribute(node, STRING_ATTR)); assertEquals(STRING_VALUE, XmlUtil.getAttribute(node, FAKE_ATTR, STRING_VALUE)); assertNull("getAttribute must return null for undefined attributes.", XmlUtil.getAttribute(node, FAKE_ATTR)); }
@Test public void getAttribute() { assertEquals(STRING_VALUE, XmlUtil.getAttribute(node, STRING_ATTR)); assertEquals(STRING_VALUE, XmlUtil.getAttribute(node, FAKE_ATTR, STRING_VALUE)); assertNull("getAttribute must return null for undefined attributes.", XmlUtil.getAttribute(node, FAKE_ATTR)); }
@Test public void getAttribute() { assertEquals(STRING_VALUE, XmlUtil.getAttribute(node, STRING_ATTR)); assertEquals(STRING_VALUE, XmlUtil.getAttribute(node, FAKE_ATTR, STRING_VALUE)); assertNull("getAttribute must return null for undefined attributes.", XmlUtil.getAttribute(node, FAKE_ATTR)); }
@Test public void getAttribute() { assertEquals(STRING_VALUE, XmlUtil.getAttribute(node, STRING_ATTR)); assertEquals(STRING_VALUE, XmlUtil.getAttribute(node, FAKE_ATTR, STRING_VALUE)); assertNull("getAttribute must return null for undefined attributes.", XmlUtil.getAttribute(node, FAKE_ATTR)); }
public LinkSpec(Element element, Uri base) throws SpecParserException { this.base = base; rel = XmlUtil.getAttribute(element, "rel"); if (rel == null) { throw new SpecParserException("Link/@rel is required!"); } href = XmlUtil.getUriAttribute(element, "href"); if (href == null) { throw new SpecParserException("Link/@href is required!"); } method = getMethodAttribute(element); }