Class StringResource
- java.lang.Object
- 
- org.apache.tools.ant.ProjectComponent
- 
- org.apache.tools.ant.types.DataType
- 
- org.apache.tools.ant.types.Resource
- 
- org.apache.tools.ant.types.resources.StringResource
 
 
 
 
- 
- All Implemented Interfaces:
- java.lang.Cloneable,- java.lang.Comparable<Resource>,- java.lang.Iterable<Resource>,- ResourceCollection
 
 public class StringResource extends Resource Exposes a string as a Resource.- Since:
- Ant 1.7
 
- 
- 
Field Summary- 
Fields inherited from class org.apache.tools.ant.types.ResourceMAGIC, UNKNOWN_DATETIME, UNKNOWN_SIZE
 - 
Fields inherited from class org.apache.tools.ant.ProjectComponentdescription, location, project
 
- 
 - 
Constructor SummaryConstructors Constructor Description StringResource()Default constructor.StringResource(java.lang.String value)Construct a StringResource with the supplied value.StringResource(Project project, java.lang.String value)Construct a StringResource with the supplied project and value, doing property replacement against the project if non-null.
 - 
Method SummaryModifier and Type Method Description voidaddText(java.lang.String text)Add nested text to this resource.protected java.lang.StringgetContent()Get the content of this StringResource.java.lang.StringgetEncoding()Get the encoding used by this StringResource.java.io.InputStreamgetInputStream()Get an InputStream for the Resource.java.lang.StringgetName()Synchronize access.java.io.OutputStreamgetOutputStream()Get an OutputStream for the Resource.protected StringResourcegetRef()Perform the check for circular references and return the referenced Resource.longgetSize()Get the size of this Resource.java.lang.StringgetValue()Get the value of this StringResource, resolving to the root reference if needed.inthashCode()Get the hash code for this Resource.booleanisExists()The exists attribute tells whether a resource exists.voidsetEncoding(java.lang.String s)Set the encoding to be used for this StringResource.voidsetName(java.lang.String s)Enforce String immutability.voidsetRefid(Reference r)Overrides the super version.voidsetValue(java.lang.String s)The value attribute is a semantically superior alias for the name attribute.java.lang.StringtoString()Get the string.- 
Methods inherited from class org.apache.tools.ant.types.Resourceas, asOptional, clone, compareTo, equals, getLastModified, getMagicNumber, isDirectory, isFilesystemOnly, iterator, setDirectory, setExists, setLastModified, setSize, size, toLongString
 - 
Methods inherited from class org.apache.tools.ant.types.DataTypecheckAttributesAllowed, checkChildrenAllowed, circularReference, dieOnCircularReference, dieOnCircularReference, dieOnCircularReference, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getDataTypeName, getRefid, invokeCircularReferenceCheck, isChecked, isReference, noChildrenAllowed, pushAndInvokeCircularReferenceCheck, setChecked, tooManyAttributes
 - 
Methods inherited from class org.apache.tools.ant.ProjectComponentgetDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject
 - 
Methods inherited from class java.lang.Objectfinalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface org.apache.tools.ant.types.ResourceCollectionisEmpty, stream
 
- 
 
- 
- 
- 
Constructor Detail- 
StringResourcepublic StringResource() Default constructor.
 - 
StringResourcepublic StringResource(java.lang.String value) Construct a StringResource with the supplied value.- Parameters:
- value- the value of this StringResource.
 
 - 
StringResourcepublic StringResource(Project project, java.lang.String value) Construct a StringResource with the supplied project and value, doing property replacement against the project if non-null.- Parameters:
- project- the owning Project.
- value- the value of this StringResource.
 
 
- 
 - 
Method Detail- 
setNamepublic void setName(java.lang.String s) Enforce String immutability.
 - 
setValuepublic void setValue(java.lang.String s) The value attribute is a semantically superior alias for the name attribute.- Parameters:
- s- the String's value.
 
 - 
getNamepublic java.lang.String getName() Synchronize access.
 - 
getValuepublic java.lang.String getValue() Get the value of this StringResource, resolving to the root reference if needed.- Returns:
- the represented String.
 
 - 
isExistspublic boolean isExists() The exists attribute tells whether a resource exists.
 - 
addTextpublic void addText(java.lang.String text) Add nested text to this resource. Properties will be expanded during this process.- Parameters:
- text- text to use as the string resource
- Since:
- Ant 1.7.1
 
 - 
setEncodingpublic void setEncoding(java.lang.String s) Set the encoding to be used for this StringResource.- Parameters:
- s- the encoding name.
 
 - 
getEncodingpublic java.lang.String getEncoding() Get the encoding used by this StringResource.- Returns:
- the encoding name.
 
 - 
getSizepublic long getSize() Get the size of this Resource.
 - 
hashCodepublic int hashCode() Get the hash code for this Resource.
 - 
toStringpublic java.lang.String toString() Get the string. SeegetContent()
 - 
getInputStreampublic java.io.InputStream getInputStream() throws java.io.IOExceptionGet an InputStream for the Resource.- Overrides:
- getInputStreamin class- Resource
- Returns:
- an InputStream containing this Resource's content.
- Throws:
- 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.
 
 - 
getOutputStreampublic java.io.OutputStream getOutputStream() throws java.io.IOExceptionGet an OutputStream for the Resource.- Overrides:
- getOutputStreamin class- Resource
- Returns:
- an OutputStream to which content can be written.
- Throws:
- 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.
 
 - 
setRefidpublic void setRefid(Reference r) Overrides the super version.
 - 
getContentprotected java.lang.String getContent() Get the content of this StringResource. SeegetValue()- Returns:
- a String or null if there is no value.
 
 - 
getRefprotected StringResource getRef() Description copied from class:ResourcePerform the check for circular references and return the referenced Resource.
 
- 
 
-