org.apache.tools.ant.types.resources

Class PropertyResource

public class PropertyResource extends Resource

Exposes an Ant property as a Resource.

Since: Ant 1.7

Constructor Summary
PropertyResource()
Default constructor.
PropertyResource(Project p, String n)
Construct a new PropertyResource with the specified name.
Method Summary
InputStreamgetInputStream()
Get an InputStream for the Resource.
OutputStreamgetOutputStream()
Get an OutputStream for the Resource.
longgetSize()
Get the size of this Resource.
StringgetValue()
Get the value of this PropertyResource.
inthashCode()
Get the hash code for this Resource.
booleanisExists()
Find out whether this Resource exists.
StringtoString()
Get the string.

Constructor Detail

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 Detail

getInputStream

public InputStream getInputStream()
Get an InputStream for the Resource.

Returns: an InputStream containing this Resource's content.

Throws: IOException if unable to provide the content of this Resource as a stream. UnsupportedOperationException if InputStreams are not supported for this Resource type.

getOutputStream

public OutputStream getOutputStream()
Get an OutputStream for the Resource.

Returns: an OutputStream to which content can be written.

Throws: IOException if unable to provide the content of this Resource as a stream. UnsupportedOperationException if OutputStreams are not supported for this Resource type.

getSize

public long getSize()
Get the size of this 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.

Returns: hash code as int.

isExists

public boolean isExists()
Find out whether this Resource exists.

Returns: true if the Property is set, false otherwise.

toString

public String toString()
Get the string.

Returns: the string contents of the resource.

Since: Ant 1.7