|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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 |
MAGIC
Magic number |
static long |
UNKNOWN_DATETIME
Constant unknown datetime for getLastModified |
static long |
UNKNOWN_SIZE
Constant 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 | |
---|---|
java.lang.Object |
clone()
Clone this Resource. |
int |
compareTo(java.lang.Object 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 . |
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 file exists. |
boolean |
isFilesystemOnly()
Fulfill the ResourceCollection contract. |
java.util.Iterator |
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, 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 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.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
.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 DataType
public int compareTo(java.lang.Object other)
compareTo
in interface java.lang.Comparable
other
- the object to compare to.
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- 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 iterator()
iterator
in interface ResourceCollection
public int size()
size
in interface ResourceCollection
public boolean isFilesystemOnly()
isFilesystemOnly
in interface ResourceCollection
public java.lang.String toString()
toString
in class DataType
public final java.lang.String toLongString()
toString()
prefixed by a type description.
public void setRefid(Reference r)
setRefid
in class DataType
r
- the Reference to set.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |