| java.lang.Object org.restlet.resource.Variant org.restlet.resource.Representation org.restlet.resource.StreamRepresentation org.restlet.resource.StringRepresentation
All known Subclasses: org.restlet.ext.json.JsonRepresentation,
StringRepresentation | public class StringRepresentation extends StreamRepresentation (Code) | | Represents an Unicode string that can be converted to any character set
supported by Java.
author: Jerome Louvel (contact@noelios.com) |
Method Summary | |
public InputStream | getStream() Returns a stream with the representation's content. | public String | getText() Converts the representation to a string value. | public void | setCharacterSet(CharacterSet characterSet) Sets the character set or null if not applicable. | public void | setText(String text) Sets the string value. | protected void | updateSize() Updates the expected size according to the current string value. | public void | write(OutputStream outputStream) Writes the representation to a byte stream. |
StringRepresentation | public StringRepresentation(CharSequence text)(Code) | | Constructor. The following metadata are used by default: "text/plain"
media type, no language and the ISO-8859-1 character set.
Parameters: text - The string value. |
StringRepresentation | public StringRepresentation(CharSequence text, Language language)(Code) | | Constructor. The following metadata are used by default: "text/plain"
media type, no language and the ISO-8859-1 character set.
Parameters: text - The string value. Parameters: language - The language. |
StringRepresentation | public StringRepresentation(CharSequence text, MediaType mediaType)(Code) | | Constructor. The following metadata are used by default: no language and
the ISO-8859-1 character set.
Parameters: text - The string value. Parameters: mediaType - The media type. |
StringRepresentation | public StringRepresentation(CharSequence text, MediaType mediaType, Language language)(Code) | | Constructor. The following metadata are used by default: ISO-8859-1
character set.
Parameters: text - The string value. Parameters: mediaType - The media type. Parameters: language - The language. |
StringRepresentation | public StringRepresentation(CharSequence text, MediaType mediaType, Language language, CharacterSet characterSet)(Code) | | Constructor.
Parameters: text - The string value. Parameters: mediaType - The media type. Parameters: language - The language. Parameters: characterSet - The character set. |
getStream | public InputStream getStream() throws IOException(Code) | | Returns a stream with the representation's content. This method is
ensured to return a fresh stream for each invocation unless it is a
transient representation, in which case null is returned.
A stream with the representation's content. throws: IOException - |
getText | public String getText()(Code) | | Converts the representation to a string value. Be careful when using this
method as the conversion of large content to a string fully stored in
memory can result in OutOfMemoryErrors being thrown.
The representation as a string value. |
setCharacterSet | public void setCharacterSet(CharacterSet characterSet)(Code) | | Sets the character set or null if not applicable.
Parameters: characterSet - The character set or null if not applicable. |
setText | public void setText(String text)(Code) | | Sets the string value.
Parameters: text - The string value. |
updateSize | protected void updateSize()(Code) | | Updates the expected size according to the current string value.
|
write | public void write(OutputStream outputStream) throws IOException(Code) | | Writes the representation to a byte stream. This method is ensured to
write the full content for each invocation unless it is a transient
representation, in which case an exception is thrown.
Parameters: outputStream - The output stream. throws: IOException - |
Fields inherited from org.restlet.resource.Variant | final public static long UNKNOWN_SIZE(Code)(Java Doc)
|
|
|