Class StringTextResult
- java.lang.Object
-
- com.inet.taskplanner.server.api.result.StringTextResult
-
- All Implemented Interfaces:
Result
,TextResult
public class StringTextResult extends java.lang.Object implements TextResult
A Result which contains of human readable text.- Since:
- taskplanner 3.0
-
-
Constructor Summary
Constructors Constructor Description StringTextResult(java.lang.String text, java.lang.String contentType)
Creates a new TextResult instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanup()
When result-handling is finished, then this method is called to clean up used system resources, i.e.java.lang.String
getText()
Returns the content of the result in form of aString
.java.io.InputStream
getTextContent()
Returns the content of the result in form of anInputStream
with encodingStandardCharsets.UTF_8
.java.lang.String
getTextContentType()
Get the MIME type this result has.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.inet.taskplanner.server.api.result.Result
supportsFlavor, supportsOneFlavorOf
-
Methods inherited from interface com.inet.taskplanner.server.api.result.TextResult
getFlavors
-
-
-
-
Method Detail
-
getTextContent
@Nonnull public java.io.InputStream getTextContent() throws java.io.IOException
Returns the content of the result in form of anInputStream
with encodingStandardCharsets.UTF_8
. The actual interpretation of the content depends on the type as returned byTextResult.getTextContentType()
.- Specified by:
getTextContent
in interfaceTextResult
- Returns:
- the content as
String
- Throws:
java.io.IOException
- thrown if the content is created on demand and the creation failed
-
cleanup
public void cleanup() throws java.io.IOException
When result-handling is finished, then this method is called to clean up used system resources, i.e. to delete a created file.This is also called if no appropriate
ResultAction
handled this Result.
-
getTextContentType
public java.lang.String getTextContentType() throws java.lang.Exception
Get the MIME type this result has.- Specified by:
getTextContentType
in interfaceTextResult
- Returns:
- the content type of this result. When
null
, 'text/plain' is to be used. - Throws:
java.lang.Exception
- if the type is could not be determined due to an IO problem
-
getText
public java.lang.String getText() throws java.io.IOException
Returns the content of the result in form of aString
. The actual interpretation of the content depends on the type as returned byTextResult.getTextContentType()
.- Specified by:
getText
in interfaceTextResult
- Returns:
- the content as
String
- Throws:
java.io.IOException
- thrown if the content is created on demand and the creation failed
-
-