Interface MarkupOutput

  • All Known Subinterfaces:
    EncodedMarkupOutput

    public interface MarkupOutput
    This object is used by a transform to record the results of a transformation. This object can be in two modes: text or binary. In text mode, all elements inside this object are of String type. In binary mode, all elements inside this object are of byte [] type. User can use the getBianryMode() method to check the mode. Before this object has any data, it will be in neither mode. But after the first element is added into the collection, its mode has been fixed. After the mode has been fixed, if user adds other type of data into this collection, or asks for the other type representation of this object, an IllegalStateException will be thrown. Inside this object, when it is in the text mode, we will keep the data into an array of StringBuffer. When user calls getTextChunkAt(i), the content of the ith StringBuffer in the array will be returned. User can control the StringBuffer's initial and maximum size by putting a properties file name 'MarkupOutput.properties" in the classpath. In this file, user should specify two properties: initBufferSize and maxBufferSize, which is in unit of character.
    Since:
    MicroStrategy Web 7.3.1 or earlier
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addBlock​(Block block)
      Adds a "root-level" Block to this MarkupOutput instance.
      void addErrorInfo​(java.lang.String error)
      Append more error information to the MarkupOutput.
      void addHeader​(java.lang.String key, java.lang.String value)
      Adds a header with the specified key value pair.
      void append​(byte[] element)
      Adds data at the end of the MarkupOutput object.
      void append​(ComponentBlock child)
      Append a ComponentBlock object to the MarkupOutput if the "primary" ComponentBlock is set it will be appended as its children otherwise it will be appended to a list field and then gets appended to a ComponentBlock later
      void append​(MarkupOutput element)
      Adds data at the end of the MarkupOutput object.
      void append​(MarkupOutput element, boolean encode)
      Adds data at the end of the EncodedMarkupOutput object.
      void append​(java.lang.Object element)
      Adds data at the end of the MarkupOutput object.
      void append​(java.lang.String element)
      Adds data at the end of the MarkupOutput object.
      void appendHtml​(java.lang.String element)
      Adds encoded HTML data at the end of the MarkupOutput object.
      void appendHtml​(java.lang.StringBuilder element)  
      void appendHtmlAttributeTooltip​(java.lang.String element)
      Adds encoded HTML data at the end of the MarkupOutput object.
      void appendJS​(java.lang.String element)
      Adds encoded JSON data at the end of the MarkupOutput object.
      void appendJSForAttribute​(java.lang.String jsCode)
      Adds encoded JavaScript code at the end of the MarkupOutput object.
      void appendUrl​(java.lang.String element)
      Adds encoded URL data at the end of the MarkupOutput object.
      int chunkCount()
      Returns the number of chunks contained in the MarkupOutput object.
      byte[] getBinaryChunkAt​(int i)
      Returns the byte array chunk at the specified index.
      byte[] getBinaryContent()
      Get all of the binary data in the MarkupOutput at once.
      boolean getBinaryMode()
      Returns whether the output is set to collate binary or text data.
      Block getBlock​(int index)
      Returns the ith "root level" Block associated with this MarkupOutput object.
      BlockContext getBlockContext()
      Returns the current "block context" object which is used for BlockProperty value expansion and overall Block serialization.
      int getBlockCount()
      Returns the number of "root level" Blocks populated by a transform or layout file and associated with this MarkupOutput instance.
      java.util.List<ComponentBlock> getChildBlocks()
      Gets the list of child ComponentBlocks
      ComponentBlock getComponentBlock()
      Returns the "primpary" ComponentBlock this MarkupOutput instance holds
      int getContentLength()
      Returns the length of the content.
      java.lang.String getContentType()
      Returns the content-type associated with this output.
      java.lang.String getCopyAsString()
      Returns the content of this object in the String format.
      java.lang.StringBuffer getErrorInfo()
      Returns the error information that is held by this MarkupOutput instance.
      int getHeaderCount()
      Returns the header count.
      java.lang.String getHeaderKey​(int i)
      Returns the header key at the specified index.
      java.lang.String getHeaderValue​(java.lang.String key)
      Returns the header value for the given header key.
      java.lang.String getTextChunkAt​(int i)
      Returns the String chunk at the specified index.
      java.lang.Object getUnserializedObject()
      Gets the UnserializedObject member which is used to contain the actual unprocessed output object.
      boolean hasChildBlocks()
      Returns a flag indicating whether the child ComponentBlocks list is empty or not
      boolean hasComponentBlock()
      Returns a flag indicating whether the "primary" ComponentBlock is set or not
      boolean hasErrorInfo()
      Returns the flag which indicates whether this MarkupOutput instance has with error information recorded or not
      void send​(java.io.OutputStream outStream)
      The results are sent back to the user via the supplied OutputStream object.
      void send​(java.io.Writer writer)
      The results are sent back to the user via the implicit out object.
      void setBinaryContent​(byte[] bytes)
      Replaces the existing binary content with a new byte array.
      void setBlockContext​(BlockContext blockContext)
      Sets the current "block context" object which is used for BlockProperty value expansion and overall Block serialization.
      void setComponentBlock​(ComponentBlock cb)
      Sets the "primary" ComponentBlock on the MarkupOutput instance once it's set all the other ComponentBlock will be appended as its children
      void setContentType​(java.lang.String contentType)
      Sets the Content-Type associated with this output.
      void setErrorInfo​(java.lang.StringBuffer error)
      Set error information onto the MarkupOutput.
      void setUnserializedObject​(java.lang.Object unserializedObject)
      Sets the UnserializedObject member which is used to contain the actual unprocessed output object.
    • Method Detail

      • send

        void send​(java.io.Writer writer)
           throws java.lang.IllegalStateException,
                  java.io.IOException
        The results are sent back to the user via the implicit out object.
        Parameters:
        writer - the implicit out object.
        Throws:
        java.lang.IllegalStateException - thrown if the current mode is binary.
        java.io.IOException - thrown in case an error occurs while writing to the output.
      • send

        void send​(java.io.OutputStream outStream)
           throws java.lang.IllegalStateException,
                  java.io.IOException
        The results are sent back to the user via the supplied OutputStream object.
        Parameters:
        outStream - the binary output stream object.
        Throws:
        java.lang.IllegalStateException - thrown if current mode is text.
        java.io.IOException
      • append

        void append​(MarkupOutput element)
             throws java.lang.IllegalArgumentException,
                    java.lang.IllegalStateException
        Adds data at the end of the MarkupOutput object. NOTE: The current content in the input parameter will be added into this MarkupOutput immediately. Future changes to the input parameter element will not be reflected in this MarkupOutput.
        Parameters:
        element - the object wanted to be appended to the collection.
        Throws:
        java.lang.IllegalArgumentException - thrown if the element is null.
        java.lang.IllegalStateException - thrown if the mode of the current MarkupOutput is not compatible with the mode of the input MarkupOutput.
      • append

        void append​(java.lang.String element)
             throws java.lang.IllegalArgumentException,
                    java.lang.IllegalStateException
        Adds data at the end of the MarkupOutput object.
        Parameters:
        element - the String wanted to be appended to the collection.
        Throws:
        java.lang.IllegalArgumentException - thrown if the element is null.
        java.lang.IllegalStateException - thrown if current MarkupOutput is at binary mode.
      • appendHtml

        void appendHtml​(java.lang.String element)
                 throws java.lang.IllegalArgumentException,
                        java.lang.IllegalStateException
        Adds encoded HTML data at the end of the MarkupOutput object.
        Parameters:
        element - the String to be encoded and appended to the collection.
        Throws:
        java.lang.IllegalArgumentException - thrown if the element is null.
        java.lang.IllegalStateException - thrown if current MarkupOutput is in binary mode.
      • appendHtml

        void appendHtml​(java.lang.StringBuilder element)
                 throws java.lang.IllegalArgumentException,
                        java.lang.IllegalStateException
        Throws:
        java.lang.IllegalArgumentException
        java.lang.IllegalStateException
      • appendHtmlAttributeTooltip

        void appendHtmlAttributeTooltip​(java.lang.String element)
                                 throws java.lang.IllegalArgumentException,
                                        java.lang.IllegalStateException
        Adds encoded HTML data at the end of the MarkupOutput object. In addition to HTML encoding, the data will be encoded for "\r", "\n", and "\t". These whitespace characters are respected in tool tips and so they must be properly encoded. For more information, see DE72585.
        Parameters:
        element - the String to be encoded and appended to the collection.
        Throws:
        java.lang.IllegalArgumentException - thrown if the element is null.
        java.lang.IllegalStateException - thrown if current MarkupOutput is in binary mode.
      • appendJS

        void appendJS​(java.lang.String element)
               throws java.lang.IllegalArgumentException,
                      java.lang.IllegalStateException
        Adds encoded JSON data at the end of the MarkupOutput object.
        Parameters:
        element - the String to be encoded and appended to the collection.
        Throws:
        java.lang.IllegalArgumentException - thrown if the element is null.
        java.lang.IllegalStateException - thrown if current MarkupOutput is in binary mode.
      • appendJSForAttribute

        void appendJSForAttribute​(java.lang.String jsCode)
                           throws java.lang.IllegalArgumentException,
                                  java.lang.IllegalStateException
        Adds encoded JavaScript code at the end of the MarkupOutput object.
        Parameters:
        jsCode - String containing the JavaScript code to be encoded and appended to the collection.
        Throws:
        java.lang.IllegalArgumentException - thrown if the element is null.
        java.lang.IllegalStateException - thrown if current MarkupOutput is in binary mode.
      • appendUrl

        void appendUrl​(java.lang.String element)
                throws java.lang.IllegalArgumentException,
                       java.lang.IllegalStateException,
                       java.io.UnsupportedEncodingException
        Adds encoded URL data at the end of the MarkupOutput object.
        Parameters:
        element - the String to be encoded and appended to the collection.
        Throws:
        java.lang.IllegalArgumentException - thrown if the element is null.
        java.lang.IllegalStateException - thrown if current MarkupOutput is in binary mode.
        java.io.UnsupportedEncodingException - thrown if the underlying encoding is not supported.
      • append

        void append​(byte[] element)
             throws java.lang.IllegalArgumentException,
                    java.lang.IllegalStateException
        Adds data at the end of the MarkupOutput object.
        Parameters:
        element - the byte array wanted to be appended to the collection.
        Throws:
        java.lang.IllegalArgumentException - thrown if the element is null.
        java.lang.IllegalStateException - thrown if current MarkupOutput is at text mode.
      • append

        void append​(java.lang.Object element)
             throws java.lang.IllegalArgumentException,
                    java.lang.IllegalStateException
        Adds data at the end of the MarkupOutput object.
        Parameters:
        element - the object wanted to be appended to the collection.
        Throws:
        java.lang.IllegalArgumentException - thrown if the element is null.
        java.lang.IllegalStateException - thrown if current MarkupOutput is at binary mode.
      • append

        void append​(MarkupOutput element,
                    boolean encode)
             throws java.lang.IllegalArgumentException,
                    java.lang.IllegalStateException
        Adds data at the end of the EncodedMarkupOutput object.
        Parameters:
        element - the String wanted to be appended to the collection.
        encode - the Boolean indicating whether encode is needed or not upon appending.
        Throws:
        java.lang.IllegalArgumentException - thrown if the element is null.
        java.lang.IllegalStateException - thrown if current MarkupOutput is at binary mode.
      • getTextChunkAt

        java.lang.String getTextChunkAt​(int i)
                                 throws java.lang.IndexOutOfBoundsException,
                                        java.lang.IllegalStateException
        Returns the String chunk at the specified index.
        Parameters:
        i - the index of the element in the collection.
        Returns:
        string chunk at the specified index.
        Throws:
        java.lang.IndexOutOfBoundsException - thrown if no chunk in the collection has the given index.
        java.lang.IllegalStateException - thrown if current MarkupOutput is at binary mode
      • getBinaryChunkAt

        byte[] getBinaryChunkAt​(int i)
                         throws java.lang.IndexOutOfBoundsException,
                                java.lang.IllegalStateException
        Returns the byte array chunk at the specified index.
        Parameters:
        i - the index of the element in the collection.
        Returns:
        The byte array at the specified index.
        Throws:
        java.lang.IndexOutOfBoundsException - thrown if no item in the collection has the given index.
        java.lang.IllegalStateException - thrown if current MarkupOutput is at text mode
      • getBinaryContent

        byte[] getBinaryContent()
                         throws java.lang.IllegalStateException
        Get all of the binary data in the MarkupOutput at once.
        Returns:
        A single byte array that contains all binary content. If there is no binary data, null is returned.
        Throws:
        java.lang.IllegalStateException - If current MarkupOutput is in "text mode"
      • setBinaryContent

        void setBinaryContent​(byte[] bytes)
                       throws java.lang.IllegalStateException
        Replaces the existing binary content with a new byte array. The previous byte data is dropped.
        Parameters:
        bytes - The new byte array to be associated with this MarkupOutput.
        Throws:
        java.lang.IllegalStateException - If current MarkupOutput is in "text mode"
      • chunkCount

        int chunkCount()
        Returns the number of chunks contained in the MarkupOutput object.
        Returns:
        number of elements in the MarkupOutput object.
      • getBinaryMode

        boolean getBinaryMode()
        Returns whether the output is set to collate binary or text data. This is determined by inspecting the content of the first append operation. If no data has been appended, it will return false (i.e. text mode) by default.
        Returns:
        true=binary, false=text mode.
      • getContentType

        java.lang.String getContentType()
        Returns the content-type associated with this output.
        Returns:
        the content type
      • getContentLength

        int getContentLength()
        Returns the length of the content.
        Returns:
        The length of the content (the number of bytes if it's binary, or the number of characters if it's not).
        Since:
        MicroStrategy Web 7.5.0
      • setContentType

        void setContentType​(java.lang.String contentType)
        Sets the Content-Type associated with this output.
        Parameters:
        contentType - the content type.
      • addHeader

        void addHeader​(java.lang.String key,
                       java.lang.String value)
        Adds a header with the specified key value pair.
        Parameters:
        key - header key name.
        value - header value.
      • getHeaderCount

        int getHeaderCount()
        Returns the header count.
        Returns:
        the header count.
      • getHeaderKey

        java.lang.String getHeaderKey​(int i)
        Returns the header key at the specified index.
        Parameters:
        i - index.
        Returns:
        the header key.
      • getHeaderValue

        java.lang.String getHeaderValue​(java.lang.String key)
        Returns the header value for the given header key.
        Parameters:
        key - header key.
        Returns:
        header value.
      • getCopyAsString

        java.lang.String getCopyAsString()
        Returns the content of this object in the String format.
        Returns:
        a String representing the current content.
      • getBlockCount

        int getBlockCount()
        Returns the number of "root level" Blocks populated by a transform or layout file and associated with this MarkupOutput instance.
        Returns:
        The number of Block objects associated with this markup output.
        Since:
        MicroStrategy Web 8.1.0
      • getBlock

        Block getBlock​(int index)
        Returns the ith "root level" Block associated with this MarkupOutput object.
        Parameters:
        index - The index of the Block to return.
        Returns:
        The ith Block in this list.
        Since:
        MicroStrategy Web 8.1.0
      • addBlock

        void addBlock​(Block block)
        Adds a "root-level" Block to this MarkupOutput instance. The fully populated Block can then be retrieved by the caller and integrated into a larger Block hierarchy.
        Parameters:
        block - The Block instance to add to this MarkupOutput object. Note that only "top-level" Blocks should be added. Nested Blocks need not be associated with this MarkupOutput instance.
        Since:
        MicroStrategy Web 8.1.0
      • getBlockContext

        BlockContext getBlockContext()
        Returns the current "block context" object which is used for BlockProperty value expansion and overall Block serialization.
        Returns:
        The BlockContext to use when converting a Block into a serialized form in the MarkupOutput.
        Since:
        MicroStrategy Web 9.0.0
      • setBlockContext

        void setBlockContext​(BlockContext blockContext)
        Sets the current "block context" object which is used for BlockProperty value expansion and overall Block serialization.
        Parameters:
        blockContext - The BlockContext to use when converting a Block into a serialized form in the MarkupOutput.
        Since:
        MicroStrategy Web 9.0.0
      • setUnserializedObject

        void setUnserializedObject​(java.lang.Object unserializedObject)
        Sets the UnserializedObject member which is used to contain the actual unprocessed output object.
        Since:
        MicroStrategy Web 9.0.0
      • getUnserializedObject

        java.lang.Object getUnserializedObject()
        Gets the UnserializedObject member which is used to contain the actual unprocessed output object.
        Since:
        MicroStrategy Web 9.0.0
      • setComponentBlock

        void setComponentBlock​(ComponentBlock cb)
        Sets the "primary" ComponentBlock on the MarkupOutput instance once it's set all the other ComponentBlock will be appended as its children
        Parameters:
        cb - the ComponentBlock to be set
      • hasComponentBlock

        boolean hasComponentBlock()
        Returns a flag indicating whether the "primary" ComponentBlock is set or not
        Returns:
        boolean true if set false if not
      • getComponentBlock

        ComponentBlock getComponentBlock()
        Returns the "primpary" ComponentBlock this MarkupOutput instance holds
        Returns:
        the ComponentBlock instance
      • append

        void append​(ComponentBlock child)
        Append a ComponentBlock object to the MarkupOutput if the "primary" ComponentBlock is set it will be appended as its children otherwise it will be appended to a list field and then gets appended to a ComponentBlock later
        Parameters:
        child - the ComponentBlock that needs to be appended
      • getChildBlocks

        java.util.List<ComponentBlock> getChildBlocks()
        Gets the list of child ComponentBlocks
        Returns:
        List the block list
      • hasChildBlocks

        boolean hasChildBlocks()
        Returns a flag indicating whether the child ComponentBlocks list is empty or not
        Returns:
        boolean true if it contains child ComponentBlocks false otherwise
      • hasErrorInfo

        boolean hasErrorInfo()
        Returns the flag which indicates whether this MarkupOutput instance has with error information recorded or not
        Returns:
        boolean true if it contains error information false otherwise
      • addErrorInfo

        void addErrorInfo​(java.lang.String error)
        Append more error information to the MarkupOutput. If componentBlock is set the error will be get appended there otherwise this MarkupOutput instance will host the info.
        Parameters:
        error - the error information that needs to be added
      • getErrorInfo

        java.lang.StringBuffer getErrorInfo()
        Returns the error information that is held by this MarkupOutput instance.
        Returns:
        StringBuffer the StringBuffer that holds the error information
      • setErrorInfo

        void setErrorInfo​(java.lang.StringBuffer error)
        Set error information onto the MarkupOutput. If componentBlock is set the error will be set there otherwise this MarkupOutput instance will host the error info.
        Parameters:
        error - the StringBuffer with error information that needs to be set