Module org.wicketstuff.jqplot4j
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 -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDROP_ROOT_MODE drops the JSON root node.static final intSTRICT_MODE prevents invalid JSON for single value objects when dropping the root. -
Constructor Summary
ConstructorsConstructorDescriptionJqPlotJsonMapHierarchicalWriter(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
Modifier and TypeMethodDescriptionvoidaddAttribute(String key, String value) voidclose()voidendNode()protected voidvoidflush()voidvoidvoidcom.thoughtworks.xstream.io.HierarchicalStreamWriterprotected voidwriteAttributeValue(com.thoughtworks.xstream.core.util.QuickWriter writer, String text) protected void
-
Field Details
-
DROP_ROOT_MODE
public static final int DROP_ROOT_MODEDROP_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:
-
STRICT_MODE
public static final int STRICT_MODESTRICT_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:
-
-
Constructor Details
-
JqPlotJsonMapHierarchicalWriter
- Parameters:
writer-WriterlineIndenter- char arraynewLine- String
-
JqPlotJsonMapHierarchicalWriter
- Parameters:
writer-WriterlineIndenter- char array
-
JqPlotJsonMapHierarchicalWriter
- Parameters:
writer-WriterlineIndenter- StringnewLine- String ]
-
JqPlotJsonMapHierarchicalWriter
- Parameters:
writer-WriterlineIndenter- String
-
JqPlotJsonMapHierarchicalWriter
- 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
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 Details
-
startNode
- Specified by:
startNodein interfacecom.thoughtworks.xstream.io.HierarchicalStreamWriter
-
startNode
- Specified by:
startNodein interfacecom.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter- Parameters:
name- name of nodeclazz- type of class
-
setValue
- Specified by:
setValuein interfacecom.thoughtworks.xstream.io.HierarchicalStreamWriter- Parameters:
text- Text
-
addAttribute
- 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
- 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
-