Top Description Inners Fields Constructors Methods
org.apache.tools.ant.types.resources

public Class StringResource

extends Resource
Class Inheritance
Imports
java.io.ByteArrayInputStream, .ByteArrayOutputStream, .FilterOutputStream, .IOException, .InputStream, .OutputStream, org.apache.tools.ant.BuildException, .Project, org.apache.tools.ant.types.Reference, .Resource

Exposes a string as a Resource.
Since
Ant 1.7

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private static final String
private String
private static final int
STRING_MAGIC

Magic number

Inherited from org.apache.tools.ant.types.Resource:
MAGICUNKNOWN_DATETIMEUNKNOWN_SIZE

Constructor Summary

AccessConstructor and Description
public
StringResource()

Default constructor.

public
StringResource(String
the value of this StringResource.
value
)

Construct a StringResource with the supplied value.

public
StringResource(Project
the owning Project.
project
,
String
the value of this StringResource.
value
)

Construct a StringResource with the supplied project and value, doing property replacement against the project if non-null.

Method Summary

Modifier and TypeMethod and Description
public void
addText(String
text to use as the string resource
text
)

Add nested text to this resource.

protected synchronized String

Returns:

a String or null if there is no value.
getContent
()

Get the content of this StringResource.

public synchronized String

Returns:

the encoding name.
getEncoding
()

Get the encoding used by this StringResource.

public synchronized InputStream

Returns:

an InputStream containing this Resource's content.
getInputStream
()

Overrides org.apache.tools.ant.types.Resource.getInputStream.

Get an InputStream for the Resource.
public synchronized String

Returns:

the name/value of this StringResource.
getName
()

Overrides org.apache.tools.ant.types.Resource.getName.

Synchronize access.
public synchronized OutputStream

Returns:

an OutputStream to which content can be written.
getOutputStream
()

Overrides org.apache.tools.ant.types.Resource.getOutputStream.

Get an OutputStream for the Resource.
protected StringResource
getRef()

Overrides org.apache.tools.ant.types.Resource.getRef.

Perform the check for circular references and return the referenced Resource.
public synchronized 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.
getSize
()

Overrides org.apache.tools.ant.types.Resource.getSize.

Get the size of this Resource.
public synchronized String

Returns:

the represented String.
getValue
()

Get the value of this StringResource, resolving to the root reference if needed.

public synchronized int

Returns:

hash code as int.
hashCode
()

Overrides org.apache.tools.ant.types.Resource.hashCode.

Get the hash code for this Resource.
public boolean

Returns:

true if this resource exists.
isExists
()

Overrides org.apache.tools.ant.types.Resource.isExists.

The exists attribute tells whether a resource exists.
public synchronized void
setEncoding(String
the encoding name.
s
)

Set the encoding to be used for this StringResource.

public synchronized void
setName(String
the new name/value for this StringResource.
s
)

Overrides org.apache.tools.ant.types.Resource.setName.

Enforce String immutability.
public void
setRefid(Reference
the Reference to set.
r
)

Overrides org.apache.tools.ant.types.Resource.setRefid.

Overrides the super version.
public synchronized void
setValue(String
the String's value.
s
)

The value attribute is a semantically superior alias for the name attribute.

public String

Returns:

the string contents of the resource.
toString
()

Overrides org.apache.tools.ant.types.Resource.toString.

Get the string.
Inherited from org.apache.tools.ant.types.Resource:
asasOptionalclonecompareToequalsgetLastModifiedgetMagicNumberisDirectoryisFilesystemOnlyiteratorsetDirectorysetExistssetLastModifiedsetSizesizetoLongString

Field Detail

DEFAULT_ENCODINGback to summary
private static final String DEFAULT_ENCODING
encodingback to summary
private String encoding
STRING_MAGICback to summary
private static final int STRING_MAGIC

Magic number

Constructor Detail

StringResourceback to summary
public StringResource()

Default constructor.

StringResourceback to summary
public StringResource(String value)

Construct a StringResource with the supplied value.

Parameters
value:String

the value of this StringResource.

StringResourceback to summary
public StringResource(Project project, String value)

Construct a StringResource with the supplied project and value, doing property replacement against the project if non-null.

Parameters
project:Project

the owning Project.

value:String

the value of this StringResource.

Method Detail

addTextback to summary
public void addText(String text)

Add nested text to this resource. Properties will be expanded during this process.

Parameters
text:String

text to use as the string resource

Since
Ant 1.7.1
getContentback to summary
protected synchronized String getContent()

Get the content of this StringResource. See getValue()

Returns:String

a String or null if there is no value.

getEncodingback to summary
public synchronized String getEncoding()

Get the encoding used by this StringResource.

Returns:String

the encoding name.

getInputStreamback to summary
public synchronized InputStream getInputStream() throws IOException

Overrides org.apache.tools.ant.types.Resource.getInputStream.

Get an InputStream for the Resource.

Returns:InputStream

an InputStream containing this Resource's content.

Annotations
@Override
Exceptions
IOException:
if unable to provide the content of this Resource as a stream.
UnsupportedOperationException:
if InputStreams are not supported for this Resource type.
getNameback to summary
public synchronized String getName()

Overrides org.apache.tools.ant.types.Resource.getName.

Synchronize access.

Returns:String

the name/value of this StringResource.

Annotations
@Override
getOutputStreamback to summary
public synchronized OutputStream getOutputStream() throws IOException

Overrides org.apache.tools.ant.types.Resource.getOutputStream.

Get an OutputStream for the Resource.

Returns:OutputStream

an OutputStream to which content can be written.

Annotations
@Override
Exceptions
IOException:
if unable to provide the content of this Resource as a stream.
UnsupportedOperationException:
if OutputStreams are not supported for this Resource type.
getRefback to summary
protected StringResource getRef()

Overrides org.apache.tools.ant.types.Resource.getRef.

Doc from org.apache.tools.ant.types.Resource.getRef.

Perform the check for circular references and return the referenced Resource.

Returns:StringResource

Resource.

Annotations
@Override
getSizeback to summary
public synchronized long getSize()

Overrides org.apache.tools.ant.types.Resource.getSize.

Get the size of this Resource.

Returns:long

the size, as a long, 0 if the Resource does not exist (for compatibility with java.io.File), or UNKNOWN_SIZE if not known.

Annotations
@Override
getValueback to summary
public synchronized String getValue()

Get the value of this StringResource, resolving to the root reference if needed.

Returns:String

the represented String.

hashCodeback to summary
public synchronized int hashCode()

Overrides org.apache.tools.ant.types.Resource.hashCode.

Get the hash code for this Resource.

Returns:int

hash code as int.

Annotations
@Override
isExistsback to summary
public boolean isExists()

Overrides org.apache.tools.ant.types.Resource.isExists.

The exists attribute tells whether a resource exists.

Returns:boolean

true if this resource exists.

Annotations
@Override
setEncodingback to summary
public synchronized void setEncoding(String s)

Set the encoding to be used for this StringResource.

Parameters
s:String

the encoding name.

setNameback to summary
public synchronized void setName(String s)

Overrides org.apache.tools.ant.types.Resource.setName.

Enforce String immutability.

Parameters
s:String

the new name/value for this StringResource.

Annotations
@Override
setRefidback to summary
public void setRefid(Reference r)

Overrides org.apache.tools.ant.types.Resource.setRefid.

Overrides the super version.

Parameters
r:Reference

the Reference to set.

Annotations
@Override
setValueback to summary
public synchronized void setValue(String s)

The value attribute is a semantically superior alias for the name attribute.

Parameters
s:String

the String's value.

toStringback to summary
public String toString()

Overrides org.apache.tools.ant.types.Resource.toString.

Get the string. See getContent()

Returns:String

the string contents of the resource.

Annotations
@Override
Since
Ant 1.7
org.apache.tools.ant.types.resources back to summary

private Class StringResource.StringResourceFilterOutputStream

extends FilterOutputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final ByteArrayOutputStream
Inherited from java.io.FilterOutputStream:
out

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.FilterOutputStream.close.

Implements java.io.Closeable.close.

Closes this output stream and releases any system resources associated with the stream.
private void
Inherited from java.io.FilterOutputStream:
flushwritewritewrite

Field Detail

baosback to summary
private final ByteArrayOutputStream baos

Constructor Detail

StringResourceFilterOutputStreamback to summary
public StringResourceFilterOutputStream()

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.FilterOutputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.FilterOutputStream.close.

Closes this output stream and releases any system resources associated with the stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
setValueFromOutputStreamback to summary
private void setValueFromOutputStream(String output)