Class JSUtils.JSONSerializer

java.lang.Object
com.webmethods.caf.faces.render.util.JSUtils.JSONSerializer
Enclosing class:
JSUtils

public static class JSUtils.JSONSerializer extends Object
Extensible class for serializing objects to json.
  • Field Details

    • m_maxDepth

      protected int m_maxDepth
    • m_mappedProperties

      protected Map<String,?> m_mappedProperties
    • m_skippedProperties

      protected Collection<String> m_skippedProperties
  • Constructor Details

    • JSONSerializer

      public JSONSerializer()
    • JSONSerializer

      public JSONSerializer(Map<String,?> mappedProperties)
    • JSONSerializer

      public JSONSerializer(Map<String,?> mappedProperties, Collection<String> skippedProperties)
  • Method Details

    • serialize

      public void serialize(Object o, Appendable b) throws IOException
      Serializes specified object to specified appendable buffer.
      Parameters:
      o - Object to serialize.
      b - Buffer.
      Throws:
      IOException
    • serialize

      public void serialize(Object o, Appendable b, List<Object> stack) throws IOException
      Serializes specified object to specified appendable buffer. Subclasses should override the method with this signature (rather than the method without the stack param).
      Parameters:
      o - Object to serialize.
      b - Buffer.
      stack - Stack of objects already serialized (if null, lazily init'd).
      Throws:
      IOException
    • serializeSecure

      public void serializeSecure(Object o, Appendable b) throws IOException
      Serializes object within prototype-compatible "secure" comment (ie "/*-secure-{}*/") to the appendable buffer.
      Parameters:
      o - Object to serialize.
      b - Buffer.
      Throws:
      IOException
    • serializeContent

      public boolean serializeContent(Object o, Appendable b, List<Object> stack) throws IOException
      Serializes the content of the specified map, list, or array (sans brackets) to the appendable buffer.
      Parameters:
      map - Object to serialize.
      b - Buffer.
      stack - Stack of objects already serialized (if null, lazily init'd).
      Throws:
      IOException
    • writePropertyName

      protected void writePropertyName(Object o, Appendable b) throws IOException
      Writes the specified property name and colon to the appendable buffer (ie "foo:" or "'foo bar':").
      Parameters:
      o - Property name.
      b - Buffer.
      Throws:
      IOException
    • getMappedProperties

      public Map<String,?> getMappedProperties()
      Map of original property-names to re-mapped property-names. Properties whose names have been re-mapped to null will be skipped.
    • setMappedProperties

      public void setMappedProperties(Map<String,?> mappedProperties)
      Map of original property-names to re-mapped property-names. Properties whose names have been re-mapped to null will be skipped.
    • getSkippedProperties

      public Collection<String> getSkippedProperties()
      Set of original property-names to skip (in addition to any null re-mapped names).
    • setSkippedProperties

      public void setSkippedProperties(Collection<String> skippedProperties)
      Set of original property-names to skip (in addition to any null re-mapped names).
    • getMaxDepth

      public int getMaxDepth()
      Max depth to recurse into objects. A depth of zero (0) means properties even of the top-level object aren't serialized.
    • setMaxDepth

      public void setMaxDepth(int maxDepth)
      Max depth to recurse into objects. A depth of zero (0) means properties even of the top-level object aren't serialized.