| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.tools.ant.ProjectComponent
org.apache.tools.ant.types.DataType
org.apache.tools.ant.types.Resource
public class Resource
Describes a "File-like" resource (File, ZipEntry, etc.). This class is meant to be used by classes needing to record path and date/time information about a file, a zip entry or some similar resource (URL, archive in a version control repository, ...).
Touchable| Field Summary | |
|---|---|
| protected static int | MAGICMagic number | 
| static long | UNKNOWN_DATETIMEConstant unknown datetime for getLastModified | 
| static long | UNKNOWN_SIZEConstant unknown size | 
| Fields inherited from class org.apache.tools.ant.types.DataType | 
|---|
| checked, ref | 
| Fields inherited from class org.apache.tools.ant.ProjectComponent | 
|---|
| description, location, project | 
| Constructor Summary | |
|---|---|
| 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. | |
| Method Summary | ||
|---|---|---|
| 
 | 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. | |
| Methods inherited from class org.apache.tools.ant.types.DataType | 
|---|
| checkAttributesAllowed, checkChildrenAllowed, circularReference, dieOnCircularReference, dieOnCircularReference, dieOnCircularReference, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getDataTypeName, getRefid, invokeCircularReferenceCheck, isChecked, isReference, noChildrenAllowed, pushAndInvokeCircularReferenceCheck, setChecked, tooManyAttributes | 
| Methods inherited from class org.apache.tools.ant.ProjectComponent | 
|---|
| getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject | 
| Methods inherited from class java.lang.Object | 
|---|
| finalize, getClass, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
|---|
public static final long UNKNOWN_SIZE
public static final long UNKNOWN_DATETIME
protected static final int MAGIC
| Constructor Detail | 
|---|
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 directory
public 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.| Method Detail | 
|---|
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()
clone in class DataTypepublic 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.Object
public 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()
toString in class DataTypepublic final java.lang.String toLongString()
toString()
 prefixed by a type description.
public void setRefid(Reference r)
setRefid in class DataTyper - the Reference to set.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.
| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||