public class StringRepresentation extends CharacterRepresentation
UNKNOWN_SIZE| Constructor and Description |
|---|
StringRepresentation(char[] chars)
Constructor.
|
StringRepresentation(CharSequence text)
Constructor.
|
StringRepresentation(CharSequence text,
Language language)
Constructor.
|
StringRepresentation(CharSequence text,
MediaType mediaType)
Constructor.
|
StringRepresentation(CharSequence text,
MediaType mediaType,
Language language)
Constructor.
|
StringRepresentation(CharSequence text,
MediaType mediaType,
Language language,
CharacterSet characterSet)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Reader |
getReader()
Returns a characters reader with the representation's content.
|
InputStream |
getStream()
Returns a stream with the representation's content.
|
String |
getText()
Converts the representation to a string value.
|
void |
release()
Closes and releases the input stream.
|
void |
setCharacterSet(CharacterSet characterSet)
Sets the character set or null if not applicable.
Note that when used with HTTP connectors, this property maps to the "Content-Type" header. |
void |
setText(CharSequence text)
Sets the string value.
|
void |
setText(String text)
Sets the string value.
|
String |
toString() |
protected void |
updateSize()
Updates the expected size according to the current string value.
|
void |
write(Writer writer)
Writes the representation to a characters writer.
|
getChannel, write, writeappend, exhaust, getAvailableSize, getDigest, getDisposition, getExpirationDate, getRange, getRegistration, getSize, hasKnownSize, isAvailable, isEmpty, isSelectable, isTransient, setAvailable, setDigest, setDisposition, setExpirationDate, setListener, setRange, setSize, setTransientgetModificationDate, getTag, setModificationDate, setTagcreateClientInfo, equals, getCharacterSet, getEncodings, getLanguages, getLocationRef, getMediaType, hashCode, includes, isCompatible, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaTypepublic StringRepresentation(char[] chars)
chars - The characters array.public StringRepresentation(CharSequence text)
text - The string value.public StringRepresentation(CharSequence text, Language language)
text - The string value.language - The language.public StringRepresentation(CharSequence text, MediaType mediaType)
text - The string value.mediaType - The media type.public StringRepresentation(CharSequence text, MediaType mediaType, Language language)
text - The string value.mediaType - The media type.language - The language.public StringRepresentation(CharSequence text, MediaType mediaType, Language language, CharacterSet characterSet)
text - The string value.mediaType - The media type.language - The language.characterSet - The character set.public Reader getReader() throws IOException
RepresentationgetReader in class RepresentationIOExceptionpublic InputStream getStream() throws IOException
RepresentationgetStream in class CharacterRepresentationIOExceptionpublic String getText()
RepresentationgetText in class Representationpublic void release()
release in class Representationpublic void setCharacterSet(CharacterSet characterSet)
VariantsetCharacterSet in class VariantcharacterSet - The character set or null if not applicable.public void setText(CharSequence text)
text - The string value.public void setText(String text)
text - The string value.protected void updateSize()
public void write(Writer writer) throws IOException
RepresentationWriter after writing to it as this will be handled by
the Restlet connectors automatically.write in class Representationwriter - The characters writer.IOExceptionCopyright © 2005–2025. All rights reserved.