/** * Test whether an Object equals this URLResource. * @param another the other Object to compare. * @return true if the specified Object is equal to this Resource. */ public synchronized boolean equals(Object another) { if (this == another) { return true; } if (isReference()) { return getCheckedRef().equals(another); } if (another == null || another.getClass() != getClass()) { return false; } URLResource other = (URLResource) another; return getURL() == null ? other.getURL() == null : getURL().equals(other.getURL()); }
/** * Ensure that we have a connection. * @param logLevel severity to use when logging connection errors. * Should be one of the <code>MSG_</code> constants in {@link * Project Project}. * @throws IOException if the connection cannot be established. * @since Ant 1.8.2 */ protected synchronized void connect(int logLevel) throws IOException { URL u = getURL(); if (u == null) { throw new BuildException("URL not set"); } if (conn == null) { try { conn = u.openConnection(); conn.connect(); } catch (IOException e) { log(e.toString(), logLevel); conn = null; throw e; } } }
/** * Get the name of this URLResource * (its file component minus the leading separator). * @return the name of this resource. */ public synchronized String getName() { if (isReference()) { return getCheckedRef().getName(); } String name = getURL().getFile(); return name.isEmpty() ? name : name.substring(1); }
/** * Get the URL used by this URLResource. * @return a URL object. */ public synchronized URL getURL() { if (isReference()) { return ((URLResource) getCheckedRef()).getURL(); } if (url == null) { if (baseURL != null) { if (relPath == null) { throw new BuildException("must provide relativePath" + " attribute when using baseURL."); } try { url = new URL(baseURL, relPath); } catch (MalformedURLException e) { throw new BuildException(e); } } } return url; }
/** * Return this URLResource formatted as a String. * @return a String representation of this URLResource. */ public synchronized String toString() { return isReference() ? getCheckedRef().toString() : String.valueOf(getURL()); }
if (getURL() == null) { return false;