Methods Summary |
---|
public int | compareTo(java.lang.Object another)Compare this FileResource to another Resource.
if (isReference()) {
return ((Comparable) getCheckedRef()).compareTo(another);
}
if (this.equals(another)) {
return 0;
}
if (another.getClass().equals(getClass())) {
FileResource otherfr = (FileResource) another;
File f = getFile();
if (f == null) {
return -1;
}
File of = otherfr.getFile();
if (of == null) {
return 1;
}
return f.compareTo(of);
}
return super.compareTo(another);
|
public boolean | equals(java.lang.Object another)Compare another Object to this FileResource for equality.
if (this == another) {
return true;
}
if (isReference()) {
return getCheckedRef().equals(another);
}
if (!(another.getClass().equals(getClass()))) {
return false;
}
FileResource otherfr = (FileResource) another;
return getFile() == null
? otherfr.getFile() == null
: getFile().equals(otherfr.getFile());
|
public java.io.File | getBaseDir()Return the basedir to which the name is relative.
return isReference()
? ((FileResource) getCheckedRef()).getBaseDir() : baseDir;
|
public java.io.File | getFile()Get the file represented by this FileResource.
return isReference() ? ((FileResource) getCheckedRef()).getFile() : file;
|
public java.io.InputStream | getInputStream()Return an InputStream for reading the contents of this Resource.
return isReference()
? ((Resource) getCheckedRef()).getInputStream()
: new FileInputStream(getNotNullFile());
|
public long | getLastModified()Get the modification time in milliseconds since 01.01.1970 .
return isReference()
? ((Resource) getCheckedRef()).getLastModified()
: getNotNullFile().lastModified();
|
public java.lang.String | getName()Get the name of this FileResource. If the basedir is set,
the name will be relative to that. Otherwise the basename
only will be returned.
if (isReference()) {
return ((Resource) getCheckedRef()).getName();
}
File b = getBaseDir();
return b == null ? getNotNullFile().getName()
: FILE_UTILS.removeLeadingPath(b, getNotNullFile());
|
protected java.io.File | getNotNullFile()Get the file represented by this FileResource, ensuring it is not null.
if (getFile() == null) {
throw new BuildException("file attribute is null!");
}
return getFile();
|
public java.io.OutputStream | getOutputStream()Get an OutputStream for the Resource.
if (isReference()) {
return ((Resource) getCheckedRef()).getOutputStream();
}
File f = getNotNullFile();
if (f.exists()) {
if (f.isFile()) {
f.delete();
}
} else {
File p = f.getParentFile();
if (p != null && !(p.exists())) {
p.mkdirs();
}
}
return new FileOutputStream(f);
|
public long | getSize()Get the size of this Resource.
return isReference() ? ((Resource) getCheckedRef()).getSize()
: getNotNullFile().length();
|
public int | hashCode()Get the hash code for this Resource.
if (isReference()) {
return getCheckedRef().hashCode();
}
return MAGIC * (getFile() == null ? NULL_FILE : getFile().hashCode());
|
public boolean | isDirectory()Learn whether the resource is a directory.
return isReference() ? ((Resource) getCheckedRef()).isDirectory()
: getNotNullFile().isDirectory();
|
public boolean | isExists()Learn whether this file exists.
return isReference() ? ((Resource) getCheckedRef()).isExists()
: getNotNullFile().exists();
|
public boolean | isFilesystemOnly()Fulfill the ResourceCollection contract.
return !isReference()
|| ((FileResource) getCheckedRef()).isFilesystemOnly();
|
public void | setBaseDir(java.io.File b)Set the basedir for this FileResource.
checkAttributesAllowed();
baseDir = b;
|
public void | setFile(java.io.File f)Set the File for this FileResource.
checkAttributesAllowed();
file = f;
|
public void | setRefid(org.apache.tools.ant.types.Reference r)Overrides the super version.
if (file != null || baseDir != null) {
throw tooManyAttributes();
}
super.setRefid(r);
|
public java.lang.String | toString()Get the string representation of this Resource.
if (isReference()) {
return getCheckedRef().toString();
}
if (file == null) {
return "(unbound file resource)";
}
String absolutePath = file.getAbsolutePath();
return FILE_UTILS.normalize(absolutePath).getAbsolutePath();
|
public void | touch(long modTime)Implement the Touchable interface.
if (isReference()) {
((FileResource) getCheckedRef()).touch(modTime);
return;
}
getNotNullFile().setLastModified(modTime);
|