Class GenericJsonGenerator

  • Direct Known Subclasses:
    JsonGenerator

    public class GenericJsonGenerator
    extends java.lang.Object
    This class generates JavaScript Object Notation strings (JSON)
    Since:
    MicroStrategy Web 9.0.0
    • Constructor Summary

      Constructors 
      Constructor Description
      GenericJsonGenerator()
      The default, no args constructor.
      GenericJsonGenerator​(boolean preserveOrder)
      A constructor used if caller needs the properties insertion order to be preserved
      GenericJsonGenerator​(java.util.Comparator<java.lang.String> keyComparator)
      A constructor that passes in a Comparator to use for sorting properties.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected void addProperty​(java.lang.String propName, java.lang.String propValue)  
      protected void addProperty​(java.lang.String propName, java.lang.String propValue, boolean encodeName)  
      static java.lang.String applyGenericEncoding​(java.lang.String data)  
      static java.lang.String applyJsonEncoding​(java.lang.String input)  
      protected java.lang.String encodeData​(java.lang.String data)  
      java.util.Set<java.lang.String> getKeys()  
      void serializeInto​(java.lang.StringBuilder stringBuilder)
      Serialize the contents of this object into the supplied StringBuilder, growing it first, as necessary, to accommodate the serialized form.
      void setBeanPaths​(WebComponent wc, int[] events)
      Sets bean paths as properties of this Json
      void setEncoderChain​(ContentEncoderChain encoderChain)  
      void setJSObjectProperty​(java.lang.String propName, java.lang.String propValue)
      This method adds a JavaScript Object property to the bone
      void setProperty​(java.lang.String propName, boolean propValue)
      This method adds a boolean property to the bone
      void setProperty​(java.lang.String propName, double propValue)
      This method adds a double property to the bone
      void setProperty​(java.lang.String propName, float propValue)
      This method adds a float property to the bone
      void setProperty​(java.lang.String propName, int propValue)
      This method adds an integer property to the bone
      void setProperty​(java.lang.String propName, int[] propValue)
      This method adds an integers array property to the bone.
      void setProperty​(java.lang.String propName, GenericJsonGenerator propValue)
      This method adds a JSON property to the bone
      void setProperty​(java.lang.String propName, GenericJsonGenerator[] propValue)  
      void setProperty​(java.lang.String propName, GenericJsonGenerator[][] propValue)  
      void setProperty​(java.lang.String propName, java.lang.String propValue)
      This method adds a String property to the bone
      void setProperty​(java.lang.String propName, java.lang.String[] propValue)
      This method adds a String array property to the bone
      void setProperty​(java.lang.String propName, java.lang.String propValue, boolean quote)
      This method adds a String property to the bone
      int size()  
      java.lang.String toString()
      Deprecated.
      Inefficient--it is preferable to serialize the contents of this object into an existing StringBuilder instance.
      java.lang.String toStringStart()
      This method builds part of the JSON string that represents this object the string outcome include the starting bracket and all the properties this object holds without the ending bracket.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • GenericJsonGenerator

        public GenericJsonGenerator()
        The default, no args constructor.
      • GenericJsonGenerator

        public GenericJsonGenerator​(java.util.Comparator<java.lang.String> keyComparator)
        A constructor that passes in a Comparator to use for sorting properties.
        Parameters:
        keyComparator - The Comparator to use for ordering the keys in the map. If null, then no ordering is guaranteed.
      • GenericJsonGenerator

        public GenericJsonGenerator​(boolean preserveOrder)
        A constructor used if caller needs the properties insertion order to be preserved
        Parameters:
        preserveOrder - whether to preserve the insertion order.
    • Method Detail

      • setEncoderChain

        public void setEncoderChain​(ContentEncoderChain encoderChain)
        Since:
        MicroStrategy Web 9.0.1
      • setProperty

        public void setProperty​(java.lang.String propName,
                                int propValue)
        This method adds an integer property to the bone
        Parameters:
        propName - String the name of the property
        propValue - int the value of the property
      • setProperty

        public void setProperty​(java.lang.String propName,
                                double propValue)
        This method adds a double property to the bone
        Parameters:
        propName - String the name of the property
        propValue - double the value of the property
      • setProperty

        public void setProperty​(java.lang.String propName,
                                float propValue)
        This method adds a float property to the bone
        Parameters:
        propName - String the name of the property
        propValue - float the value of the property
      • setProperty

        public void setProperty​(java.lang.String propName,
                                java.lang.String propValue,
                                boolean quote)
        This method adds a String property to the bone
        Parameters:
        propName - String the name of the property
        propValue - String the value of the property
        quote - If 'true', then encode the data in the string and quote it (with a single quote).
      • setProperty

        public void setProperty​(java.lang.String propName,
                                java.lang.String propValue)
        This method adds a String property to the bone
        Parameters:
        propName - String the name of the property
        propValue - String the value of the property
      • setProperty

        public void setProperty​(java.lang.String propName,
                                boolean propValue)
        This method adds a boolean property to the bone
        Parameters:
        propName - String the name of the property
        propValue - boolean the value of the property
      • setProperty

        public void setProperty​(java.lang.String propName,
                                java.lang.String[] propValue)
        This method adds a String array property to the bone
        Parameters:
        propName - String the name of the property
        propValue - String the value of the property
      • setProperty

        public void setProperty​(java.lang.String propName,
                                int[] propValue)
        This method adds an integers array property to the bone.
        Parameters:
        propName - String the name of the property
        propValue - String the value of the property
      • setProperty

        public void setProperty​(java.lang.String propName,
                                GenericJsonGenerator propValue)
        This method adds a JSON property to the bone
        Parameters:
        propName - String the name of the property
        propValue - the value of the property
      • setProperty

        public void setProperty​(java.lang.String propName,
                                GenericJsonGenerator[] propValue)
      • setProperty

        public void setProperty​(java.lang.String propName,
                                GenericJsonGenerator[][] propValue)
        Since:
        MicroStrategy Web 9.0.1
      • setJSObjectProperty

        public void setJSObjectProperty​(java.lang.String propName,
                                        java.lang.String propValue)
        This method adds a JavaScript Object property to the bone
        Parameters:
        propName - String the name of the property
        propValue - String the value of the property, that when parsed by the browser will evaluate into a JavaScript object
      • size

        public int size()
        Returns:
        int the number of properties this object has set
      • toString

        @Deprecated
        public java.lang.String toString()
        Deprecated.
        Inefficient--it is preferable to serialize the contents of this object into an existing StringBuilder instance. Use serializeInto(StringBuilder) instead.
        This method builds the JSON string that represents this object
        Overrides:
        toString in class java.lang.Object
        Returns:
        String JSON
      • toStringStart

        public java.lang.String toStringStart()
        This method builds part of the JSON string that represents this object the string outcome include the starting bracket and all the properties this object holds without the ending bracket.
        Returns:
        String JSON piece
      • serializeInto

        public void serializeInto​(java.lang.StringBuilder stringBuilder)
        Serialize the contents of this object into the supplied StringBuilder, growing it first, as necessary, to accommodate the serialized form.
        Parameters:
        stringBuilder - The StringBuilder to serialize into.
        Since:
        MicroStrategy Web 9.0.1
      • setBeanPaths

        public void setBeanPaths​(WebComponent wc,
                                 int[] events)
        Sets bean paths as properties of this Json
        Parameters:
        wc - the web component that will be used to resolve the bean events.
        events - an array of event codes
      • applyGenericEncoding

        public static java.lang.String applyGenericEncoding​(java.lang.String data)
      • applyJsonEncoding

        public static java.lang.String applyJsonEncoding​(java.lang.String input)
      • getKeys

        public java.util.Set<java.lang.String> getKeys()
        Since:
        MicroStrategy Web 9.0.1
      • addProperty

        protected void addProperty​(java.lang.String propName,
                                   java.lang.String propValue)
      • addProperty

        protected void addProperty​(java.lang.String propName,
                                   java.lang.String propValue,
                                   boolean encodeName)
      • encodeData

        protected java.lang.String encodeData​(java.lang.String data)