Class 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 a String.
      java.io.InputStream getTextContent()
      Returns the content of the result in form of an InputStream with encoding StandardCharsets.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
    • Constructor Detail

      • StringTextResult

        public StringTextResult​(java.lang.String text,
                                java.lang.String contentType)
        Creates a new TextResult instance.
        Parameters:
        text - the text this result contains.
        contentType - the content type, typical MimeTypes.TXT or MimeTypes.HTM
        Since:
        taskplanner 3.0
    • Method Detail

      • getTextContent

        @Nonnull
        public java.io.InputStream getTextContent()
                                           throws java.io.IOException
        Returns the content of the result in form of an InputStream with encoding StandardCharsets.UTF_8. The actual interpretation of the content depends on the type as returned by TextResult.getTextContentType().
        Specified by:
        getTextContent in interface TextResult
        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.

        Specified by:
        cleanup in interface Result
        Throws:
        java.io.IOException
      • getTextContentType

        public java.lang.String getTextContentType()
                                            throws java.lang.Exception
        Get the MIME type this result has.
        Specified by:
        getTextContentType in interface TextResult
        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 a String. The actual interpretation of the content depends on the type as returned by TextResult.getTextContentType().
        Specified by:
        getText in interface TextResult
        Returns:
        the content as String
        Throws:
        java.io.IOException - thrown if the content is created on demand and the creation failed