Constructors Summary |
---|
public Resource()Default constructor.
|
public Resource(String name)Only sets the name.
This is a dummy, used for not existing resources.
this(name, false, 0, false);
|
public Resource(String name, boolean exists, long lastmodified)Sets the name, lastmodified flag, and exists flag.
this(name, exists, lastmodified, false);
|
public Resource(String name, boolean exists, long lastmodified, boolean directory)Sets the name, lastmodified flag, exists flag, and directory flag.
this(name, exists, lastmodified, directory, UNKNOWN_SIZE);
|
public Resource(String name, boolean exists, long lastmodified, boolean directory, long size)Sets the name, lastmodified flag, exists flag, directory flag, and size.
this.name = name;
setName(name);
setExists(exists);
setLastModified(lastmodified);
setDirectory(directory);
setSize(size);
|
Methods Summary |
---|
public java.lang.Object | clone()Clone this Resource.
try {
return super.clone();
} catch (CloneNotSupportedException e) {
throw new UnsupportedOperationException(
"CloneNotSupportedException for a Resource caught. "
+ "Derived classes must support cloning.");
}
|
public int | compareTo(java.lang.Object other)Delegates to a comparison of names.
if (isReference()) {
return ((Comparable) getCheckedRef()).compareTo(other);
}
if (!(other instanceof Resource)) {
throw new IllegalArgumentException(
"Can only be compared with Resources");
}
return toString().compareTo(other.toString());
|
public boolean | equals(java.lang.Object other)Implement basic Resource equality.
if (isReference()) {
return getCheckedRef().equals(other);
}
return other.getClass().equals(getClass()) && compareTo(other) == 0;
|
public java.io.InputStream | getInputStream()Get an InputStream for the Resource.
if (isReference()) {
return ((Resource) getCheckedRef()).getInputStream();
}
throw new UnsupportedOperationException();
|
public long | getLastModified()Tells the modification time in milliseconds since 01.01.1970 .
if (isReference()) {
return ((Resource) getCheckedRef()).getLastModified();
}
if (!isExists() || lastmodified == null) {
return UNKNOWN_DATETIME;
}
long result = lastmodified.longValue();
return result < UNKNOWN_DATETIME ? UNKNOWN_DATETIME : result;
|
protected static int | getMagicNumber(byte[] seed)Create a "magic number" for use in hashCode calculations.
return new BigInteger(seed).intValue();
|
public java.lang.String | getName()Name attribute will contain the path of a file relative to the
root directory of its fileset or the recorded path of a zip
entry.
example for a file with fullpath /var/opt/adm/resource.txt
in a file set with root dir /var/opt it will be
adm/resource.txt.
"/" will be used as the directory separator.
return isReference() ? ((Resource) getCheckedRef()).getName() : name;
|
public java.io.OutputStream | getOutputStream()Get an OutputStream for the Resource.
if (isReference()) {
return ((Resource) getCheckedRef()).getOutputStream();
}
throw new UnsupportedOperationException();
|
public long | getSize()Get the size of this Resource.
if (isReference()) {
return ((Resource) getCheckedRef()).getSize();
}
return isExists()
? (size != null ? size.longValue() : UNKNOWN_SIZE)
: 0L;
|
public int | hashCode()Get the hash code for this Resource.
if (isReference()) {
return getCheckedRef().hashCode();
}
String name = getName();
return MAGIC * (name == null ? NULL_NAME : name.hashCode());
|
public boolean | isDirectory()Tells if the resource is a directory.
if (isReference()) {
return ((Resource) getCheckedRef()).isDirectory();
}
//default false:
return directory != null && directory.booleanValue();
|
public boolean | isExists()The exists attribute tells whether a file exists.
if (isReference()) {
return ((Resource) getCheckedRef()).isExists();
}
//default true:
return exists == null || exists.booleanValue();
|
public boolean | isFilesystemOnly()Fulfill the ResourceCollection contract.
//default false:
return isReference() && ((Resource) getCheckedRef()).isFilesystemOnly();
|
public java.util.Iterator | iterator()Fulfill the ResourceCollection contract.
return isReference() ? ((Resource) getCheckedRef()).iterator()
: new Iterator() {
private boolean done = false;
public boolean hasNext() {
return !done;
}
public Object next() {
if (done) {
throw new NoSuchElementException();
}
done = true;
return Resource.this;
}
public void remove() {
throw new UnsupportedOperationException();
}
};
|
public void | setDirectory(boolean directory)Set the directory attribute.
checkAttributesAllowed();
this.directory = directory ? Boolean.TRUE : Boolean.FALSE;
|
public void | setExists(boolean exists)Set the exists attribute.
checkAttributesAllowed();
this.exists = exists ? Boolean.TRUE : Boolean.FALSE;
|
public void | setLastModified(long lastmodified)Set the last modification attribute.
checkAttributesAllowed();
this.lastmodified = new Long(lastmodified);
|
public void | setName(java.lang.String name)Set the name of this Resource.
checkAttributesAllowed();
this.name = name;
|
public void | setRefid(Reference r)Overrides the base version.
if (name != null
|| exists != null
|| lastmodified != null
|| directory != null
|| size != null) {
throw tooManyAttributes();
}
super.setRefid(r);
|
public void | setSize(long size)Set the size of this Resource.
checkAttributesAllowed();
this.size = new Long(size > UNKNOWN_SIZE ? size : UNKNOWN_SIZE);
|
public int | size()Fulfill the ResourceCollection contract.
return isReference() ? ((Resource) getCheckedRef()).size() : 1;
|
public final java.lang.String | toLongString()Get a long String representation of this Resource.
This typically should be the value of toString()
prefixed by a type description.
return isReference() ? ((Resource) getCheckedRef()).toLongString()
: getDataTypeName() + " \"" + toString() + '"";
|
public java.lang.String | toString()Get the string representation of this Resource.
if (isReference()) {
return getCheckedRef().toString();
}
String n = getName();
return n == null ? "(anonymous)" : n;
|