public class Resource extends DataType implements java.lang.Comparable<Resource>, ResourceCollection
Touchable| Modifier and Type | Field and Description | 
|---|---|
| protected static int | MAGICMagic number | 
| static long | UNKNOWN_DATETIMEConstant unknown datetime for getLastModified | 
| static long | UNKNOWN_SIZEConstant unknown size | 
description, location, project| Constructor and Description | 
|---|
| Resource()Default constructor. | 
| Resource(java.lang.String name)Only sets the name. | 
| Resource(java.lang.String name,
        boolean exists,
        long lastmodified)Sets the name, lastmodified flag, and exists flag. | 
| Resource(java.lang.String name,
        boolean exists,
        long lastmodified,
        boolean directory)Sets the name, lastmodified flag, exists flag, and directory flag. | 
| Resource(java.lang.String name,
        boolean exists,
        long lastmodified,
        boolean directory,
        long size)Sets the name, lastmodified flag, exists flag, directory flag, and size. | 
| Modifier and Type | Method and Description | 
|---|---|
| <T> T | as(java.lang.Class<T> clazz)Returns a view of this resource that implements the interface
 given as the argument or null if there is no such view. | 
| java.lang.Object | clone()Clone this Resource. | 
| int | compareTo(Resource other)Delegates to a comparison of names. | 
| boolean | equals(java.lang.Object other)Implement basic Resource equality. | 
| java.io.InputStream | getInputStream()Get an InputStream for the Resource. | 
| long | getLastModified()Tells the modification time in milliseconds since 01.01.1970 (the "epoch"). | 
| protected static int | getMagicNumber(byte[] seed)Create a "magic number" for use in hashCode calculations. | 
| 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. | 
| java.io.OutputStream | getOutputStream()Get an OutputStream for the Resource. | 
| long | getSize()Get the size of this Resource. | 
| int | hashCode()Get the hash code for this Resource. | 
| boolean | isDirectory()Tells if the resource is a directory. | 
| boolean | isExists()The exists attribute tells whether a resource exists. | 
| boolean | isFilesystemOnly()Fulfill the ResourceCollection contract. | 
| java.util.Iterator<Resource> | iterator()Fulfill the ResourceCollection contract. | 
| void | setDirectory(boolean directory)Set the directory attribute. | 
| void | setExists(boolean exists)Set the exists attribute. | 
| void | setLastModified(long lastmodified)Set the last modification attribute. | 
| void | setName(java.lang.String name)Set the name of this Resource. | 
| void | setRefid(Reference r)Overrides the base version. | 
| void | setSize(long size)Set the size of this Resource. | 
| int | size()Fulfill the ResourceCollection contract. | 
| java.lang.String | toLongString()Get a long String representation of this Resource. | 
| java.lang.String | toString()Get the string representation of this Resource. | 
checkAttributesAllowed, checkChildrenAllowed, circularReference, dieOnCircularReference, dieOnCircularReference, dieOnCircularReference, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getDataTypeName, getRefid, invokeCircularReferenceCheck, isChecked, isReference, noChildrenAllowed, pushAndInvokeCircularReferenceCheck, setChecked, tooManyAttributesgetDescription, getLocation, getProject, log, log, setDescription, setLocation, setProjectpublic static final long UNKNOWN_SIZE
public static final long UNKNOWN_DATETIME
protected static final int MAGIC
public Resource()
public Resource(java.lang.String name)
This is a dummy, used for not existing resources.
name - relative path of the resource.  Expects
 "/" to be used as the directory separator.public Resource(java.lang.String name,
        boolean exists,
        long lastmodified)
name - relative path of the resource.  Expects
 "/" to be used as the directory separator.exists - if true, this resource exists.lastmodified - the last modification time of this resource.public Resource(java.lang.String name,
        boolean exists,
        long lastmodified,
        boolean directory)
name - relative path of the resource.  Expects
 "/" to be used as the directory separator.exists - if true the resource existslastmodified - the last modification time of the resourcedirectory - if true, this resource is a directorypublic Resource(java.lang.String name,
        boolean exists,
        long lastmodified,
        boolean directory,
        long size)
name - relative path of the resource.  Expects
 "/" to be used as the directory separator.exists - if true the resource existslastmodified - the last modification time of the resourcedirectory - if true, this resource is a directorysize - the size of this resource.protected static int getMagicNumber(byte[] seed)
seed - byte[] to seed with.public java.lang.String getName()
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.
public void setName(java.lang.String name)
name - relative path of the resource.  Expects
 "/" to be used as the directory separator.public boolean isExists()
public void setExists(boolean exists)
exists - if true, this resource exists.public long getLastModified()
File.lastModified();
         or 0 if the notion of modification time is meaningless for this class
           of resource (e.g. an inline string)public void setLastModified(long lastmodified)
lastmodified - the modification time in milliseconds since 01.01.1970.public boolean isDirectory()
public void setDirectory(boolean directory)
directory - if true, this resource is a directory.public void setSize(long size)
size - the size, as a long.public long getSize()
public java.lang.Object clone()
public int compareTo(Resource other)
compareTo in interface java.lang.Comparable<Resource>other - the object to compare to.public boolean equals(java.lang.Object other)
equals in class java.lang.Objectother - the object to check against.public int hashCode()
hashCode in class java.lang.Objectpublic java.io.InputStream getInputStream()
                                   throws java.io.IOException
java.io.IOException - if unable to provide the content of this
         Resource as a stream.java.lang.UnsupportedOperationException - if InputStreams are not
         supported for this Resource type.public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
java.io.IOException - if unable to provide the content of this
         Resource as a stream.java.lang.UnsupportedOperationException - if OutputStreams are not
         supported for this Resource type.public java.util.Iterator<Resource> iterator()
iterator in interface java.lang.Iterable<Resource>iterator in interface ResourceCollectionpublic int size()
size in interface ResourceCollectionpublic boolean isFilesystemOnly()
isFilesystemOnly in interface ResourceCollectionpublic java.lang.String toString()
public final java.lang.String toLongString()
toString()
 prefixed by a type description.public void setRefid(Reference r)
public <T> T as(java.lang.Class<T> clazz)
This allows extension interfaces to be added to resources without growing the number of permutations of interfaces decorators/adapters need to implement.
This implementation of the method will return the current instance itself if it can be assigned to the given class.