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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classJqPlotJsonMapHierarchicalWriter.Node
-
Field Summary
Fields Modifier and Type Field Description static intDROP_ROOT_MODEDROP_ROOT_MODE drops the JSON root node.static intSTRICT_MODESTRICT_MODE prevents invalid JSON for single value objects when dropping the root.
-
Constructor Summary
Constructors Constructor Description JqPlotJsonMapHierarchicalWriter(Writer writer)JqPlotJsonMapHierarchicalWriter(Writer writer, char[] lineIndenter)JqPlotJsonMapHierarchicalWriter(Writer writer, char[] lineIndenter, String newLine)JqPlotJsonMapHierarchicalWriter(Writer writer, char[] lineIndenter, String newLine, int mode)JqPlotJsonMapHierarchicalWriter(Writer writer, int mode)Create a JsonWriter where the writer mode can be chosen.JqPlotJsonMapHierarchicalWriter(Writer writer, String lineIndenter)JqPlotJsonMapHierarchicalWriter(Writer writer, String lineIndenter, String newLine)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttribute(String key, String value)voidclose()voidendNode()protected voidendOfLine()voidflush()voidsetValue(String text)voidstartNode(String name)voidstartNode(String name, Class clazz)com.thoughtworks.xstream.io.HierarchicalStreamWriterunderlyingWriter()protected voidwriteAttributeValue(com.thoughtworks.xstream.core.util.QuickWriter writer, String text)protected voidwriteText(com.thoughtworks.xstream.core.util.QuickWriter writer, String text)
-
-
-
Field Detail
-
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 unlessSTRICT_MODEis also set.- Since:
- 1.3.1
- See Also:
- Constant Field Values
-
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 theDROP_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 activateSTRICT_MODEand aConversionExceptionis thrown instead.- Since:
- 1.3.1
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JqPlotJsonMapHierarchicalWriter
public JqPlotJsonMapHierarchicalWriter(Writer writer, char[] lineIndenter, String newLine)
- Parameters:
writer-WriterlineIndenter- char arraynewLine- String
-
JqPlotJsonMapHierarchicalWriter
public JqPlotJsonMapHierarchicalWriter(Writer writer, char[] lineIndenter)
- Parameters:
writer-WriterlineIndenter- char array
-
JqPlotJsonMapHierarchicalWriter
public JqPlotJsonMapHierarchicalWriter(Writer writer, String lineIndenter, String newLine)
- Parameters:
writer-WriterlineIndenter- StringnewLine- String ]
-
JqPlotJsonMapHierarchicalWriter
public JqPlotJsonMapHierarchicalWriter(Writer writer, String lineIndenter)
- Parameters:
writer-WriterlineIndenter- String
-
JqPlotJsonMapHierarchicalWriter
public JqPlotJsonMapHierarchicalWriter(Writer writer)
- Parameters:
writer-Writer
-
JqPlotJsonMapHierarchicalWriter
public JqPlotJsonMapHierarchicalWriter(Writer writer, char[] lineIndenter, String newLine, int mode)
- Parameters:
writer- WriterlineIndenter- array of charnewLine- new linemode- 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:DROP_ROOT_MODE: drop the root nodeSTRICT_MODE: do not throwConversionException, if writer should generate invalid JSON
- Parameters:
writer- theWriterwhere the JSON is written tomode- the JsonWriter mode- Since:
- 1.3.1
-
-
Method Detail
-
startNode
public void startNode(String name)
- Specified by:
startNodein interfacecom.thoughtworks.xstream.io.HierarchicalStreamWriter
-
startNode
public void startNode(String name, Class clazz)
- Specified by:
startNodein interfacecom.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter- Parameters:
name- name of nodeclazz- type of class
-
setValue
public void setValue(String text)
- Specified by:
setValuein interfacecom.thoughtworks.xstream.io.HierarchicalStreamWriter- Parameters:
text- Text
-
addAttribute
public void addAttribute(String key, String value)
- Specified by:
addAttributein interfacecom.thoughtworks.xstream.io.HierarchicalStreamWriter- Parameters:
key- keyvalue- value
-
writeAttributeValue
protected void writeAttributeValue(com.thoughtworks.xstream.core.util.QuickWriter writer, String text)- Parameters:
writer- writertext- text
-
writeText
protected void writeText(com.thoughtworks.xstream.core.util.QuickWriter writer, String text)- Parameters:
writer- writertext- text
-
endNode
public void endNode()
- Specified by:
endNodein interfacecom.thoughtworks.xstream.io.HierarchicalStreamWriter
-
endOfLine
protected void endOfLine()
-
flush
public void flush()
- Specified by:
flushin interfacecom.thoughtworks.xstream.io.HierarchicalStreamWriter
-
close
public void close()
- Specified by:
closein interfacecom.thoughtworks.xstream.io.HierarchicalStreamWriter
-
underlyingWriter
public com.thoughtworks.xstream.io.HierarchicalStreamWriter underlyingWriter()
- Specified by:
underlyingWriterin interfacecom.thoughtworks.xstream.io.HierarchicalStreamWriter- Returns:
- HierarchicalStreamWriter
-
-