|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.dhmp.io.MapWriter
This class can generate large output formed by several HierarchicalMap and also
support relative key manipulation.
For instance, the structure above can be generated as follows:
<order>
<address>
<shipping>
...
</shipping>
<billing>
...
</billing>
</address>
</order>
Notice that each MapWriter keeps an internal reference. The subsequent
writeMap methods will write the map starting from this reference.
This object is not synchronizes and also it is a stateful object. Therefore,
avoid sharing this object with other threads.
MapWriter mw = new MapWriter(System.out);
MapWriter mw2 = mw.writeMap("Order/Address");
mw2.writeMap("Shipping", shippingMap);
mw2.writeMap("Billing", billingMap);
| Constructor Summary | |
MapWriter(AbstractMapOutput out)
Creates a new instance of MapWriter sharing the same relative position. |
|
MapWriter(MapWriter out)
Creates a new instance of MapWriter. |
|
| Method Summary | |
void |
close()
Closes this output stream and releases any system resources associated with the stream. |
void |
flush()
Flushes this output stream and forces any buffered output bytes to be written out. |
void |
flushAll()
Flushes this output stream and also ends any HierarchicalMap written so far. |
java.lang.String |
getCurrentPath()
Gets the current path relative to the reference. |
java.lang.String |
getReferencePath()
Gets the path used as reference for all writing methods. |
boolean |
hasSamePath()
Returns true if the path has not changed after last writing method. |
void |
init(HierarchicalMap paramMap)
Initializes this class using the configuration passed. |
void |
init(java.lang.String config)
Initializes this class using the configuration passed. |
MapWriter |
newCurrentWriter()
Returns new MapWriter with reference path set to current path of this class. |
MapWriter |
newCurrentWriter(java.lang.Object start)
Returns new MapWriter with reference path set to start. |
MapWriter |
newLatestWriter()
Returns new MapWriter with reference path set to last written position. |
MapWriter |
newWriter()
Returns new MapWriter with same reference path. |
MapOutput |
writeMap(HierarchicalMap map)
Writes out a HierarchicalMap to output. |
MapOutput |
writeMap(java.lang.Object start,
HierarchicalMap map)
Writes out a HierarchicalMap to output relative to the start. |
MapOutput |
writeMap(java.lang.String path)
Writes a HierarchicalMap where each of the elements that composes the path are represented as nested nodes. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public MapWriter(MapWriter out)
out - MapOutput to where the maps are written.public MapWriter(AbstractMapOutput out)
out - MapOutput with shared output.| Method Detail |
public void init(java.lang.String config)
Configuration change is accepted until the first writing method is called. Check the specific MapOutput init method for valid configurations.
init in interface MapOutputconfig - configuration used by this class.public void init(HierarchicalMap paramMap)
init(String).
Configuration change is accepted until the first writing method is called.
init in interface MapOutputparamMap - HierarchicalMap containing the configuration.
public MapOutput writeMap(java.lang.String path)
throws MapIOException
writeMap("a/b/c") is similar to the following code:
map.add("a/b/c")
writeMap(map)
writeMap in interface MapOutputpath - each element of the key is written as node.
MapIOException - if an I/O error occurs.
public MapOutput writeMap(HierarchicalMap map)
throws MapIOException
writeMap in interface MapOutputmap - HierarchicalMap to be written to the output.
MapIOException - if an I/O error occurs.
public MapOutput writeMap(java.lang.Object start,
HierarchicalMap map)
throws MapIOException
writeMap in interface MapOutputmap - HierarchicalMap to be written to the output.start - node from where the writing starts.
MapIOException - if an I/O error occurs.
public void flush()
throws MapIOException
flush in interface MapOutputMapIOException - if an I/O error occurs.
public void close()
throws MapIOException
close in interface MapOutputMapIOException - if an I/O error occurs.public java.lang.String getReferencePath()
public java.lang.String getCurrentPath()
public boolean hasSamePath()
public MapWriter newWriter()
public MapWriter newCurrentWriter()
public MapWriter newCurrentWriter(java.lang.Object start)
start - node referred by reference path.
public MapWriter newLatestWriter()
public void flushAll()
MapOutput
flushAll in interface MapOutput
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||