/** * Retrieves an attribute as a URI. * @param node * @param attr * @return The parsed uri, or null. */ public static Uri getUriAttribute(Node node, String attr) { return getUriAttribute(node, attr, null); }
/** * Retrieves an attribute as a URI. * @param node * @param attr * @return The parsed uri, or null. */ public static Uri getUriAttribute(Node node, String attr) { return getUriAttribute(node, attr, null); }
/** * Retrieves an attribute as a URI. * @param node * @param attr * @return The parsed uri, or null. */ public static Uri getUriAttribute(Node node, String attr) { return getUriAttribute(node, attr, null); }
/** * Retrieves an attribute as a URI. * @param node * @param attr * @return The parsed uri, or null. */ public static Uri getUriAttribute(Node node, String attr) { return getUriAttribute(node, attr, null); }
/** * Retrieves an attribute as a URI. * @param node * @param attr * @return The parsed uri, or null. */ public static Uri getUriAttribute(Node node, String attr) { return getUriAttribute(node, attr, null); }
href = XmlUtil.getUriAttribute(preload, "href"); if (href == null) { throw new SpecParserException("Preload/@href is missing or invalid.");
href = XmlUtil.getUriAttribute(preload, "href"); if (href == null) { throw new SpecParserException("Preload/@href is missing or invalid.");
/** * Retrieves an attribute as a URI, and verifies that the URI is an http * or https URI. * @param node * @param attr * @param base *@param def @return the parsed uri, or def if the attribute is not a valid http or * https URI. */ public static Uri getHttpUriAttribute(Node node, String attr, Uri base, Uri def) { Uri uri = getUriAttribute(node, attr, def); if (uri == null) { return def; } // resolve to base before checking if (base != null) { uri = base.resolve(uri); } if (!"http".equalsIgnoreCase(uri.getScheme()) && !"https".equalsIgnoreCase(uri.getScheme())) { return def; } return uri; }
/** * Retrieves an attribute as a URI, and verifies that the URI is an http * or https URI. * @param node * @param attr * @param base *@param def @return the parsed uri, or def if the attribute is not a valid http or * https URI. */ public static Uri getHttpUriAttribute(Node node, String attr, Uri base, Uri def) { Uri uri = getUriAttribute(node, attr, def); if (uri == null) { return def; } // resolve to base before checking if (base != null) { uri = base.resolve(uri); } if (!"http".equalsIgnoreCase(uri.getScheme()) && !"https".equalsIgnoreCase(uri.getScheme())) { return def; } return uri; }
/** * Retrieves an attribute as a URI, and verifies that the URI is an http * or https URI. * @param node * @param attr * @param base *@param def @return the parsed uri, or def if the attribute is not a valid http or * https URI. */ public static Uri getHttpUriAttribute(Node node, String attr, Uri base, Uri def) { Uri uri = getUriAttribute(node, attr, def); if (uri == null) { return def; } // resolve to base before checking if (base != null) { uri = base.resolve(uri); } if (!"http".equalsIgnoreCase(uri.getScheme()) && !"https".equalsIgnoreCase(uri.getScheme())) { return def; } return uri; }
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!"); } }
/** * Retrieves an attribute as a URI, and verifies that the URI is an http * or https URI. * @param node * @param attr * @param base *@param def @return the parsed uri, or def if the attribute is not a valid http or * https URI. */ public static Uri getHttpUriAttribute(Node node, String attr, Uri base, Uri def) { Uri uri = getUriAttribute(node, attr, def); if (uri == null) { return def; } // resolve to base before checking if (base != null) { uri = base.resolve(uri); } if (!"http".equalsIgnoreCase(uri.getScheme()) && !"https".equalsIgnoreCase(uri.getScheme())) { return def; } return uri; }
/** * Retrieves an attribute as a URI, and verifies that the URI is an http * or https URI. * @param node * @param attr * @param base *@param def @return the parsed uri, or def if the attribute is not a valid http or * https URI. */ public static Uri getHttpUriAttribute(Node node, String attr, Uri base, Uri def) { Uri uri = getUriAttribute(node, attr, def); if (uri == null) { return def; } // resolve to base before checking if (base != null) { uri = base.resolve(uri); } if (!"http".equalsIgnoreCase(uri.getScheme()) && !"https".equalsIgnoreCase(uri.getScheme())) { return def; } return uri; }
@Test public void getUriAttribute() { assertEquals(URI_VALUE, XmlUtil.getUriAttribute(node, URI_ATTR)); assertEquals(URI_VALUE, XmlUtil.getUriAttribute(node, FAKE_ATTR, URI_VALUE)); assertEquals(URI_VALUE, XmlUtil.getUriAttribute(node, URI_MALFORMED_ATTR, URI_VALUE)); assertNull("getUriAttribute must return null for undefined attributes.", XmlUtil.getUriAttribute(node, FAKE_ATTR)); assertEquals(FTP_URI_VALUE, XmlUtil.getUriAttribute(node, FTP_URI_ATTR)); }
@Test public void getUriAttribute() { assertEquals(URI_VALUE, XmlUtil.getUriAttribute(node, URI_ATTR)); assertEquals(URI_VALUE, XmlUtil.getUriAttribute(node, FAKE_ATTR, URI_VALUE)); assertEquals(URI_VALUE, XmlUtil.getUriAttribute(node, URI_MALFORMED_ATTR, URI_VALUE)); assertNull("getUriAttribute must return null for undefined attributes.", XmlUtil.getUriAttribute(node, FAKE_ATTR)); assertEquals(FTP_URI_VALUE, XmlUtil.getUriAttribute(node, FTP_URI_ATTR)); }
@Test public void getUriAttribute() { assertEquals(URI_VALUE, XmlUtil.getUriAttribute(node, URI_ATTR)); assertEquals(URI_VALUE, XmlUtil.getUriAttribute(node, FAKE_ATTR, URI_VALUE)); assertEquals(URI_VALUE, XmlUtil.getUriAttribute(node, URI_MALFORMED_ATTR, URI_VALUE)); assertNull("getUriAttribute must return null for undefined attributes.", XmlUtil.getUriAttribute(node, FAKE_ATTR)); assertEquals(FTP_URI_VALUE, XmlUtil.getUriAttribute(node, FTP_URI_ATTR)); }
@Test public void getUriAttribute() { assertEquals(URI_VALUE, XmlUtil.getUriAttribute(node, URI_ATTR)); assertEquals(URI_VALUE, XmlUtil.getUriAttribute(node, FAKE_ATTR, URI_VALUE)); assertEquals(URI_VALUE, XmlUtil.getUriAttribute(node, URI_MALFORMED_ATTR, URI_VALUE)); assertNull("getUriAttribute must return null for undefined attributes.", XmlUtil.getUriAttribute(node, FAKE_ATTR)); assertEquals(FTP_URI_VALUE, XmlUtil.getUriAttribute(node, FTP_URI_ATTR)); }
@Test public void getUriAttribute() { assertEquals(URI_VALUE, XmlUtil.getUriAttribute(node, URI_ATTR)); assertEquals(URI_VALUE, XmlUtil.getUriAttribute(node, FAKE_ATTR, URI_VALUE)); assertEquals(URI_VALUE, XmlUtil.getUriAttribute(node, URI_MALFORMED_ATTR, URI_VALUE)); assertNull("getUriAttribute must return null for undefined attributes.", XmlUtil.getUriAttribute(node, FAKE_ATTR)); assertEquals(FTP_URI_VALUE, XmlUtil.getUriAttribute(node, FTP_URI_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); }