Package com.microstrategy.utils
Class GenericJsonGenerator
- java.lang.Object
-
- com.microstrategy.utils.GenericJsonGenerator
-
- Direct Known Subclasses:
JsonGenerator
public class GenericJsonGenerator extends java.lang.ObjectThis 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 preservedGenericJsonGenerator(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 voidaddProperty(java.lang.String propName, java.lang.String propValue)protected voidaddProperty(java.lang.String propName, java.lang.String propValue, boolean encodeName)static java.lang.StringapplyGenericEncoding(java.lang.String data)static java.lang.StringapplyJsonEncoding(java.lang.String input)protected java.lang.StringencodeData(java.lang.String data)java.util.Set<java.lang.String>getKeys()voidserializeInto(java.lang.StringBuilder stringBuilder)Serialize the contents of this object into the supplied StringBuilder, growing it first, as necessary, to accommodate the serialized form.voidsetBeanPaths(WebComponent wc, int[] events)Sets bean paths as properties of this JsonvoidsetEncoderChain(ContentEncoderChain encoderChain)voidsetJSObjectProperty(java.lang.String propName, java.lang.String propValue)This method adds a JavaScript Object property to the bonevoidsetProperty(java.lang.String propName, boolean propValue)This method adds a boolean property to the bonevoidsetProperty(java.lang.String propName, double propValue)This method adds a double property to the bonevoidsetProperty(java.lang.String propName, float propValue)This method adds a float property to the bonevoidsetProperty(java.lang.String propName, int propValue)This method adds an integer property to the bonevoidsetProperty(java.lang.String propName, int[] propValue)This method adds an integers array property to the bone.voidsetProperty(java.lang.String propName, GenericJsonGenerator propValue)This method adds a JSON property to the bonevoidsetProperty(java.lang.String propName, GenericJsonGenerator[] propValue)voidsetProperty(java.lang.String propName, GenericJsonGenerator[][] propValue)voidsetProperty(java.lang.String propName, java.lang.String propValue)This method adds a String property to the bonevoidsetProperty(java.lang.String propName, java.lang.String[] propValue)This method adds a String array property to the bonevoidsetProperty(java.lang.String propName, java.lang.String propValue, boolean quote)This method adds a String property to the boneintsize()java.lang.StringtoString()Deprecated.Inefficient--it is preferable to serialize the contents of this object into an existing StringBuilder instance.java.lang.StringtoStringStart()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.
-
-
-
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- TheComparatorto 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 propertypropValue- 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 propertypropValue- 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 propertypropValue- 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 propertypropValue- String the value of the propertyquote- 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 propertypropValue- 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 propertypropValue- 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 propertypropValue- 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 propertypropValue- 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 propertypropValue- 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 propertypropValue- 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. UseserializeInto(StringBuilder)instead.This method builds the JSON string that represents this object- Overrides:
toStringin classjava.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- TheStringBuilderto 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)
-
-