Package com.sodius.mdw.server.storage
Interface NodeWriter
-
- All Superinterfaces:
AutoCloseable
,Closeable
public interface NodeWriter extends Closeable
A writer that builds a node tree that is later serialized as JSON or XML format. An writer instance is created using a dedicatedFactory
.Client needs to make sure the
close()
method is always called, so that the serialization can complete and temporary resources can be disposed.This interface is not intended to be implemented by clients.
- Since:
- 2.0
- See Also:
NodeContentProducer
,NodeWriter.Factory.XML
,NodeWriter.Factory.JSON
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
NodeWriter.Factory
A factory to instantiate a node writer.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description NodeWriter
endArray()
Ends the current array node production.NodeWriter
endDocument()
Finalizes the production of the node tree.NodeWriter
endNode()
Ends the current node production.NodeWriter
startArray(String name)
Starts a new array node production.NodeWriter
startDocument(String name)
Start the production of the node tree.NodeWriter
startNode()
Starts a new node production, child of the current node which is expected to be an array node.NodeWriter
startNode(String name)
Starts a new node production with the specified name.NodeWriter
write(String name, String value)
Writes a name/value pair on the current node.
-
-
-
Method Detail
-
startDocument
NodeWriter startDocument(String name) throws IOException
Start the production of the node tree.- Parameters:
name
- the name of the root node. This name is not used by the JSON implementation.- Returns:
- the same node writer instance.
- Throws:
IOException
- if anything prevents the writing process.
-
endDocument
NodeWriter endDocument() throws IOException
Finalizes the production of the node tree.- Returns:
- the same node writer instance.
- Throws:
IOException
- if anything prevents the writing process.
-
startNode
NodeWriter startNode() throws IOException
Starts a new node production, child of the current node which is expected to be an array node. The new node name will be the one of the parent array node.- Returns:
- the same node writer instance.
- Throws:
IOException
- if anything prevents the writing process.- See Also:
startArray(String)
-
startNode
NodeWriter startNode(String name) throws IOException
Starts a new node production with the specified name.- Parameters:
name
- the node name.- Returns:
- the same node writer instance.
- Throws:
IOException
- if anything prevents the writing process.
-
endNode
NodeWriter endNode() throws IOException
Ends the current node production.- Returns:
- the same node writer instance.
- Throws:
IOException
- if anything prevents the writing process.
-
startArray
NodeWriter startArray(String name) throws IOException
Starts a new array node production. Client is expected to callstartNode()
method for each item of the array.- Parameters:
name
- the node name.- Returns:
- the same node writer instance.
- Throws:
IOException
- if anything prevents the writing process.- See Also:
startNode()
-
endArray
NodeWriter endArray() throws IOException
Ends the current array node production.- Returns:
- the same node writer instance.
- Throws:
IOException
- if anything prevents the writing process.
-
write
NodeWriter write(String name, String value) throws IOException
Writes a name/value pair on the current node.- Parameters:
name
- the attribute name.value
- the attribute value.- Returns:
- the same node writer instance.
- Throws:
IOException
- if anything prevents the writing process.
-
-