Class JqPlotJsonMapHierarchicalWriter

java.lang.Object
org.wicketstuff.jqplot.lib.support.JqPlotJsonMapHierarchicalWriter
All Implemented Interfaces:
com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter, com.thoughtworks.xstream.io.HierarchicalStreamWriter

public class JqPlotJsonMapHierarchicalWriter extends Object implements com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter
Author:
Joe Walnes. / inaiat
  • Field Details

    • DROP_ROOT_MODE

      public static final int DROP_ROOT_MODE
      DROP_ROOT_MODE drops the JSON root node. The root node is the first level of the JSON object i.e.
       { "person": {
           "name": "Joe"
       }}
       
      will be written without root simply as
       {
           "name": "Joe"
       }
       
      Without a root node, the top level element might now also be an array. However, it is possible to generate invalid JSON unless STRICT_MODE is also set.
      Since:
      1.3.1
      See Also:
    • STRICT_MODE

      public static final int STRICT_MODE
      STRICT_MODE prevents invalid JSON for single value objects when dropping the root. The mode is only useful in combination with the DROP_ROOT_MODE. An object with a single value as first node i.e.
       { "name": "Joe" }
       
      is simply written as
       "Joe"
       
      However, this is no longer valid JSON. Therefore you can activate STRICT_MODE and a ConversionException is thrown instead.
      Since:
      1.3.1
      See Also:
  • Constructor Details

    • JqPlotJsonMapHierarchicalWriter

      public JqPlotJsonMapHierarchicalWriter(Writer writer, char[] lineIndenter, String newLine)
      Parameters:
      writer - Writer
      lineIndenter - char array
      newLine - String
    • JqPlotJsonMapHierarchicalWriter

      public JqPlotJsonMapHierarchicalWriter(Writer writer, char[] lineIndenter)
      Parameters:
      writer - Writer
      lineIndenter - char array
    • JqPlotJsonMapHierarchicalWriter

      public JqPlotJsonMapHierarchicalWriter(Writer writer, String lineIndenter, String newLine)
      Parameters:
      writer - Writer
      lineIndenter - String
      newLine - String ]
    • JqPlotJsonMapHierarchicalWriter

      public JqPlotJsonMapHierarchicalWriter(Writer writer, String lineIndenter)
      Parameters:
      writer - Writer
      lineIndenter - String
    • JqPlotJsonMapHierarchicalWriter

      public JqPlotJsonMapHierarchicalWriter(Writer writer)
      Parameters:
      writer - Writer
    • JqPlotJsonMapHierarchicalWriter

      public JqPlotJsonMapHierarchicalWriter(Writer writer, char[] lineIndenter, String newLine, int mode)
      Parameters:
      writer - Writer
      lineIndenter - array of char
      newLine - new line
      mode - mode
      Since:
      1.3.1
    • JqPlotJsonMapHierarchicalWriter

      public JqPlotJsonMapHierarchicalWriter(Writer writer, int mode)
      Create a JsonWriter where the writer mode can be chosen. Following constants can be used as bit mask:
      Parameters:
      writer - the Writer where the JSON is written to
      mode - the JsonWriter mode
      Since:
      1.3.1
  • Method Details

    • startNode

      public void startNode(String name)
      Specified by:
      startNode in interface com.thoughtworks.xstream.io.HierarchicalStreamWriter
    • startNode

      public void startNode(String name, Class clazz)
      Specified by:
      startNode in interface com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter
      Parameters:
      name - name of node
      clazz - type of class
    • setValue

      public void setValue(String text)
      Specified by:
      setValue in interface com.thoughtworks.xstream.io.HierarchicalStreamWriter
      Parameters:
      text - Text
    • addAttribute

      public void addAttribute(String key, String value)
      Specified by:
      addAttribute in interface com.thoughtworks.xstream.io.HierarchicalStreamWriter
      Parameters:
      key - key
      value - value
    • writeAttributeValue

      protected void writeAttributeValue(com.thoughtworks.xstream.core.util.QuickWriter writer, String text)
      Parameters:
      writer - writer
      text - text
    • writeText

      protected void writeText(com.thoughtworks.xstream.core.util.QuickWriter writer, String text)
      Parameters:
      writer - writer
      text - text
    • endNode

      public void endNode()
      Specified by:
      endNode in interface com.thoughtworks.xstream.io.HierarchicalStreamWriter
    • endOfLine

      protected void endOfLine()
    • flush

      public void flush()
      Specified by:
      flush in interface com.thoughtworks.xstream.io.HierarchicalStreamWriter
    • close

      public void close()
      Specified by:
      close in interface com.thoughtworks.xstream.io.HierarchicalStreamWriter
    • underlyingWriter

      public com.thoughtworks.xstream.io.HierarchicalStreamWriter underlyingWriter()
      Specified by:
      underlyingWriter in interface com.thoughtworks.xstream.io.HierarchicalStreamWriter
      Returns:
      HierarchicalStreamWriter