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:
Cloneable
,Comparable<Resource>
,Iterable<Resource>
,ResourceCollection
Exposes a string 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.ProjectComponent
description, location, project
-
Constructor Summary
ConstructorDescriptionDefault constructor.StringResource
(String value) Construct a StringResource with the supplied value.StringResource
(Project project, String value) Construct a StringResource with the supplied project and value, doing property replacement against the project if non-null. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add nested text to this resource.protected String
Get the content of this StringResource.Get the encoding used by this StringResource.Get an InputStream for the Resource.getName()
Synchronize access.Get an OutputStream for the Resource.protected StringResource
getRef()
Perform the check for circular references and return the referenced Resource.long
getSize()
Get the size of this Resource.getValue()
Get the value of this StringResource, resolving to the root reference if needed.int
hashCode()
Get the hash code for this Resource.boolean
isExists()
The exists attribute tells whether a resource exists.void
Set the encoding to be used for this StringResource.void
Enforce String immutability.void
Overrides the super version.void
The value attribute is a semantically superior alias for the name attribute.toString()
Get the string.Methods inherited from class org.apache.tools.ant.types.Resource
as, asOptional, clone, compareTo, equals, getLastModified, getMagicNumber, isDirectory, isFilesystemOnly, iterator, setDirectory, setExists, setLastModified, setSize, size, toLongString
Methods inherited from class org.apache.tools.ant.types.DataType
checkAttributesAllowed, 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.ProjectComponent
getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface org.apache.tools.ant.types.ResourceCollection
isEmpty, stream
-
Constructor Details
-
StringResource
public StringResource()Default constructor. -
StringResource
Construct a StringResource with the supplied value.- Parameters:
value
- the value of this StringResource.
-
StringResource
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 Details
-
setName
Enforce String immutability. -
setValue
The value attribute is a semantically superior alias for the name attribute.- Parameters:
s
- the String's value.
-
getName
Synchronize access. -
getValue
Get the value of this StringResource, resolving to the root reference if needed.- Returns:
- the represented String.
-
isExists
public boolean isExists()The exists attribute tells whether a resource exists. -
addText
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
-
setEncoding
Set the encoding to be used for this StringResource.- Parameters:
s
- the encoding name.
-
getEncoding
Get the encoding used by this StringResource.- Returns:
- the encoding name.
-
getSize
public long getSize()Get the size of this Resource. -
hashCode
public int hashCode()Get the hash code for this Resource. -
toString
Get the string. SeegetContent()
-
getInputStream
Get an InputStream for the Resource.- Overrides:
getInputStream
in classResource
- 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
Get an OutputStream for the Resource.- Overrides:
getOutputStream
in classResource
- 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.
-
setRefid
Overrides the super version. -
getContent
Get the content of this StringResource. SeegetValue()
- Returns:
- a String or null if there is no value.
-
getRef
Description copied from class:Resource
Perform the check for circular references and return the referenced Resource.
-