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, ...).
org.apache.tools.ant.types.resources.Touchable
Modifier and Type | Field and Description |
---|---|
private Boolean | |
private Boolean | |
private Long | |
protected static final int | MAGIC
Magic number |
private String | |
private static final int | |
private Long | |
public static final long | UNKNOWN_DATETIME
Constant unknown datetime for getLastModified |
public static final long | UNKNOWN_SIZE
Constant unknown size |
Access | Constructor and Description |
---|---|
public | |
public | |
public | |
public | Resource(String
relative path of the resource. Expects
"/" to be used as the directory separator. name, boolean if true the resource exists exists, long the last modification time of the resource lastmodified, boolean if true, this resource is a directory directory)Sets the name, lastmodified flag, exists flag, and directory flag. |
public | Resource(String
relative path of the resource. Expects
"/" to be used as the directory separator. name, boolean if true the resource exists exists, long the last modification time of the resource lastmodified, boolean if true, this resource is a directory directory, long the size of this resource. size)Sets the name, lastmodified flag, exists flag, directory flag, and size. |
Modifier and Type | Method and Description |
---|---|
public < desired type T> T | |
public < desired type T> Optional | Returns: Optional resource of a desired typea class clazz) |
public Object | Returns: copy of this.Overrides org. |
public int | Returns: a negative integer, zero, or a positive integer as this Resource is less than, equal to, or greater than the specified Resource.the object to compare to. other)Implements java. |
public boolean | Returns: true if the specified Object is equal to this Resource.the object to check against. other)Overrides java. |
public InputStream | Returns: an InputStream containing this Resource's content.Get an InputStream for the Resource. |
public long | Returns: the modification time, if that is meaningful (e.g. for a file resource which exists); 0 if the resource does not exist, to mirror the behavior ofjava. ;
or 0 if the notion of modification time is meaningless for this class
of resource (e.g. an inline string)Tells the modification time in milliseconds since 01.01.1970 (the "epoch"). |
protected static int | Returns: a magic number as int.byte[] to seed with. seed)Create a "magic number" for use in hashCode calculations. |
public String | Returns: the name of this resource.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. |
public OutputStream | Returns: an OutputStream to which content can be written.Get an OutputStream for the Resource. |
protected Resource | Returns: Resource .Perform the check for circular references and return the referenced Resource. |
public long | Returns: the size, as a long, 0 if the Resource does not exist (for compatibility with java.io.File), or UNKNOWN_SIZE if not known.Get the size of this Resource. |
public int | Returns: hash code as int.Overrides java. |
public boolean | Returns: boolean flag indicating if the resource is a directory.Tells if the resource is a directory. |
public boolean | Returns: true if this resource exists.The exists attribute tells whether a resource exists. |
public boolean | Returns: whether this Resource is a FileProvider.Implements org. |
public Iterator | Returns: an Iterator of Resources.Implements java. |
public void | |
public void | |
public void | setLastModified(long
the modification time in milliseconds since 01.01.1970. lastmodified)Set the last modification attribute. |
public void | |
public void | setRefid(Reference
the Reference to set. r)Overrides org. |
public void | |
public int | Returns: the size of this ResourceCollection.Implements org. |
public final String | Returns: this Resource formatted as a long String.Get a long String representation of this Resource. |
public String | Returns: this Resource formatted as a String.Overrides org. |
directory | back to summary |
---|---|
private Boolean directory |
exists | back to summary |
---|---|
private Boolean exists |
lastmodified | back to summary |
---|---|
private Long lastmodified |
MAGIC | back to summary |
---|---|
protected static final int MAGIC Magic number |
name | back to summary |
---|---|
private String name |
NULL_NAME | back to summary |
---|---|
private static final int NULL_NAME |
size | back to summary |
---|---|
private Long size |
UNKNOWN_DATETIME | back to summary |
---|---|
public static final long UNKNOWN_DATETIME Constant unknown datetime for getLastModified |
UNKNOWN_SIZE | back to summary |
---|---|
public static final long UNKNOWN_SIZE Constant unknown size |
Resource | back to summary |
---|---|
public Resource() Default constructor. |
Resource | back to summary |
---|---|
public Resource(String name) Only sets the name. This is a dummy, used for not existing resources.
|
Resource | back to summary |
---|---|
public Resource(String name, boolean exists, long lastmodified) Sets the name, lastmodified flag, and exists flag.
|
Resource | back to summary |
---|---|
public Resource(String name, boolean exists, long lastmodified, boolean directory) Sets the name, lastmodified flag, exists flag, and directory flag.
|
Resource | back to summary |
---|---|
public Resource(String name, boolean exists, long lastmodified, boolean directory, long size) Sets the name, lastmodified flag, exists flag, directory flag, and size.
|
as | back to summary |
---|---|
public <T> T as(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. 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.
|
asOptional | back to summary |
---|---|
public <T> Optional |
clone | back to summary |
---|---|
public Object clone() Overrides org. Clone this Resource. |
compareTo | back to summary |
---|---|
public int compareTo(Resource other) Implements java. Delegates to a comparison of names. |
equals | back to summary |
---|---|
public boolean equals(Object other) Overrides java. Implement basic Resource equality. |
getInputStream | back to summary |
---|---|
public InputStream getInputStream() throws IOException Get an InputStream for the Resource.
|
getLastModified | back to summary |
---|---|
public long getLastModified() Tells the modification time in milliseconds since 01.01.1970 (the "epoch").
|
getMagicNumber | back to summary |
---|---|
protected static int getMagicNumber(byte[] seed) Create a "magic number" for use in hashCode calculations.
|
getName | back to summary |
---|---|
public 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.
|
getOutputStream | back to summary |
---|---|
public OutputStream getOutputStream() throws IOException Get an OutputStream for the Resource.
|
getRef | back to summary |
---|---|
protected Resource getRef() Perform the check for circular references and return the referenced Resource.
|
getSize | back to summary |
---|---|
public long getSize() Get the size of this Resource.
|
hashCode | back to summary |
---|---|
public int hashCode() Overrides java. Get the hash code for this Resource.
|
isDirectory | back to summary |
---|---|
public boolean isDirectory() Tells if the resource is a directory.
|
isExists | back to summary |
---|---|
public boolean isExists() The exists attribute tells whether a resource exists.
|
isFilesystemOnly | back to summary |
---|---|
public boolean isFilesystemOnly() Implements org. Fulfill the ResourceCollection contract.
|
iterator | back to summary |
---|---|
public Iterator Implements java. Fulfill the ResourceCollection contract. |
setDirectory | back to summary |
---|---|
public void setDirectory(boolean directory) Set the directory attribute.
|
setExists | back to summary |
---|---|
public void setExists(boolean exists) Set the exists attribute.
|
setLastModified | back to summary |
---|---|
public void setLastModified(long lastmodified) Set the last modification attribute.
|
setName | back to summary |
---|---|
public void setName(String name) Set the name of this Resource.
|
setRefid | back to summary |
---|---|
public void setRefid(Reference r) Overrides org. Overrides the base version. |
setSize | back to summary |
---|---|
public void setSize(long size) Set the size of this Resource.
|
size | back to summary |
---|---|
public int size() Implements org. Fulfill the ResourceCollection contract.
|
toLongString | back to summary |
---|---|
public final String toLongString() Get a long String representation of this Resource.
This typically should be the value of
|
toString | back to summary |
---|---|
public String toString() Overrides org. Get the string representation of this Resource. |