org.apache.tools.ant.types.resources

Class PropertyResource

Implemented Interfaces:
Cloneable, Comparable, ResourceCollection

public class PropertyResource
extends Resource

Exposes an Ant property as a Resource.
Since:
Ant 1.7

Field Summary

Fields inherited from class org.apache.tools.ant.types.Resource

MAGIC, UNKNOWN_DATETIME, 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

PropertyResource()
Default constructor.
PropertyResource(Project p, String n)
Construct a new PropertyResource with the specified name.

Method Summary

InputStream
getInputStream()
Get an InputStream for the Resource.
OutputStream
getOutputStream()
Get an OutputStream for the Resource.
long
getSize()
Get the size of this Resource.
String
getValue()
Get the value of this PropertyResource.
int
hashCode()
Get the hash code for this Resource.
boolean
isExists()
Find out whether this Resource exists.
String
toString()
Get the string.

Methods inherited from class org.apache.tools.ant.types.Resource

clone, compareTo, equals, getInputStream, getLastModified, getMagicNumber, getName, getOutputStream, getSize, hashCode, isDirectory, isExists, isFilesystemOnly, iterator, setDirectory, setExists, setLastModified, setName, setRefid, setSize, size, toLongString, toString

Methods inherited from class org.apache.tools.ant.types.DataType

checkAttributesAllowed, checkChildrenAllowed, circularReference, clone, dieOnCircularReference, dieOnCircularReference, dieOnCircularReference, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getDataTypeName, getRefid, invokeCircularReferenceCheck, isChecked, isReference, noChildrenAllowed, setChecked, setRefid, toString, tooManyAttributes

Methods inherited from class org.apache.tools.ant.ProjectComponent

clone, getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject

Constructor Details

PropertyResource

public PropertyResource()
Default constructor.

PropertyResource

public PropertyResource(Project p,
                        String n)
Construct a new PropertyResource with the specified name.
Parameters:
p - the project to use.
n - the String name of this PropertyResource (Ant property name/key).

Method Details

getInputStream

public InputStream getInputStream()
            throws IOException
Get an InputStream for the Resource.
Overrides:
getInputStream in interface Resource
Returns:
an InputStream containing this Resource's content.

getOutputStream

public OutputStream getOutputStream()
            throws IOException
Get an OutputStream for the Resource.
Overrides:
getOutputStream in interface Resource
Returns:
an OutputStream to which content can be written.

getSize

public long getSize()
Get the size of this Resource.
Overrides:
getSize in interface Resource
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.

getValue

public String getValue()
Get the value of this PropertyResource.
Returns:
the value of the specified Property.

hashCode

public int hashCode()
Get the hash code for this Resource.
Overrides:
hashCode in interface Resource
Returns:
hash code as int.

isExists

public boolean isExists()
Find out whether this Resource exists.
Overrides:
isExists in interface Resource
Returns:
true if the Property is set, false otherwise.

toString

public String toString()
Get the string.
Overrides:
toString in interface Resource
Returns:
the string contents of the resource.
Since:
Ant 1.7