public class FileResource extends Resource implements Touchable, FileProvider, ResourceFactory, Appendable
MAGIC, UNKNOWN_DATETIME, UNKNOWN_SIZE
description, location, project
Constructor and Description |
---|
FileResource()
Default constructor.
|
FileResource(java.io.File f)
Construct a new FileResource from a File.
|
FileResource(java.io.File b,
java.lang.String name)
Construct a new FileResource using the specified basedir and relative name.
|
FileResource(Project p,
java.io.File f)
Create a new FileResource.
|
FileResource(Project p,
java.lang.String s)
Constructor for Ant attribute introspection.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(java.lang.Object another)
Compare this FileResource to another Resource.
|
boolean |
equals(java.lang.Object another)
Compare another Object to this FileResource for equality.
|
java.io.OutputStream |
getAppendOutputStream()
Get an appending OutputStream.
|
java.io.File |
getBaseDir()
Return the basedir to which the name is relative.
|
java.io.File |
getFile()
Get the file represented by this FileResource.
|
java.io.InputStream |
getInputStream()
Return an InputStream for reading the contents of this Resource.
|
long |
getLastModified()
Get the modification time in milliseconds since 01.01.1970 .
|
java.lang.String |
getName()
Get the name of this FileResource.
|
protected java.io.File |
getNotNullFile()
Get the file represented by this FileResource, ensuring it is not null.
|
java.io.OutputStream |
getOutputStream()
Get an OutputStream for the Resource.
|
Resource |
getResource(java.lang.String path)
Create a new resource that matches a relative or absolute path.
|
long |
getSize()
Get the size of this Resource.
|
int |
hashCode()
Get the hash code for this Resource.
|
boolean |
isDirectory()
Learn whether the resource is a directory.
|
boolean |
isExists()
Learn whether this file exists.
|
boolean |
isFilesystemOnly()
Fulfill the ResourceCollection contract.
|
void |
setBaseDir(java.io.File b)
Set the basedir for this FileResource.
|
void |
setFile(java.io.File f)
Set the File for this FileResource.
|
void |
setRefid(Reference r)
Overrides the super version.
|
java.lang.String |
toString()
Get the string representation of this Resource.
|
void |
touch(long modTime)
Implement the Touchable interface.
|
as, clone, getMagicNumber, iterator, setDirectory, setExists, setLastModified, setName, setSize, size, toLongString
checkAttributesAllowed, checkChildrenAllowed, circularReference, dieOnCircularReference, dieOnCircularReference, dieOnCircularReference, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getDataTypeName, getRefid, invokeCircularReferenceCheck, isChecked, isReference, noChildrenAllowed, pushAndInvokeCircularReferenceCheck, setChecked, tooManyAttributes
getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject
public FileResource()
public FileResource(java.io.File b, java.lang.String name)
b
- the basedir as File.name
- the relative filename.public FileResource(java.io.File f)
f
- the File represented.public FileResource(Project p, java.io.File f)
p
- Projectf
- File representedpublic FileResource(Project p, java.lang.String s)
p
- the Project against which to resolve s
.s
- the absolute or Project-relative filename as a String.IntrospectionHelper
public void setFile(java.io.File f)
f
- the File to be represented.public java.io.File getFile()
getFile
in interface FileProvider
public void setBaseDir(java.io.File b)
b
- the basedir as File.public java.io.File getBaseDir()
public void setRefid(Reference r)
public java.lang.String getName()
public boolean isExists()
public long getLastModified()
getLastModified
in class Resource
public boolean isDirectory()
isDirectory
in class Resource
public long getSize()
public java.io.InputStream getInputStream() throws java.io.IOException
getInputStream
in class Resource
java.io.IOException
- if an error occurs.public java.io.OutputStream getOutputStream() throws java.io.IOException
getOutputStream
in class Resource
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.io.OutputStream getAppendOutputStream() throws java.io.IOException
getAppendOutputStream
in interface Appendable
java.io.IOException
- if anything goes wrongpublic int compareTo(java.lang.Object another)
compareTo
in interface java.lang.Comparable
compareTo
in class Resource
another
- the other Resource against which to compare.public boolean equals(java.lang.Object another)
public int hashCode()
public java.lang.String toString()
public boolean isFilesystemOnly()
isFilesystemOnly
in interface ResourceCollection
isFilesystemOnly
in class Resource
public void touch(long modTime)
protected java.io.File getNotNullFile()
BuildException
- if file is null.public Resource getResource(java.lang.String path)
getResource
in interface ResourceFactory
path
- relative/absolute path to a resourceBuildException
- if desired