/** * Get the hash code for this Resource. * @return hash code as int. */ @Override public int hashCode() { return super.hashCode() * (getArchive() == null ? NULL_ARCHIVE : getArchive().hashCode()); }
/** * Get the archive that holds this Resource. * @return the archive as a Resource. */ public Resource getArchive() { return isReference() ? getCheckedRef().getArchive() : archive; }
/** * Compare another Object to this ArchiveResource for equality. * @param another the other Object to compare. * @return true if another is a Resource representing * the same entry in the same archive. */ @Override public boolean equals(Object another) { if (this == another) { return true; } if (isReference()) { return getCheckedRef().equals(another); } if (another == null || !another.getClass().equals(getClass())) { return false; } ArchiveResource r = (ArchiveResource) another; return getArchive().equals(r.getArchive()) && getName().equals(r.getName()); }
/** * Validate settings and ensure that the represented "archive entry" * has been established. */ protected final synchronized void checkEntry() throws BuildException { dieOnCircularReference(); if (haveEntry) { return; } String name = getName(); if (name == null) { throw new BuildException("entry name not set"); } Resource r = getArchive(); if (r == null) { throw new BuildException("archive attribute not set"); } if (!r.isExists()) { throw new BuildException("%s does not exist.", r); } if (r.isDirectory()) { throw new BuildException("%s denotes a directory.", r); } fetchEntry(); haveEntry = true; }
/** * Format this Resource as a String. * @return String representation of this Resource. */ @Override public String toString() { return isReference() ? getCheckedRef().toString() : getArchive().toString() + ':' + getName(); }