org.dhmp.io
Interface MapInput

All Known Implementing Classes:
AbstractMapInput, MapReader

public interface MapInput

Interface for reading HierarchicalMap from input source.

Author:
hideyuki

Method Summary
 void close()
          Closes associated input source and releases any system resources associated with it.
 HierarchicalMap getBaseMap()
          Returns current base map.
 void init(HierarchicalMap paramMap)
          Initializes this class using the configuration passed.
 void init(java.lang.String config)
          Initializes this class using the configuration passed.
 HierarchicalMap readMap()
          Reads-in a HierarchicalMap from input source.
 HierarchicalMap readMap(java.lang.Object start)
          Reads-in a HierarchicalMap from input source starting at specified node.
 HierarchicalMap readMap(java.lang.Object start, java.lang.Object stop)
          Reads-in a HierarchicalMap from input source starting at specified node and finishing at stopping node.
 HierarchicalMap readMapUntil()
          Reads-in a HierarchicalMap from input source until first node is found.
 HierarchicalMap readMapUntil(java.lang.Object stop)
          Reads-in a HierarchicalMap from input source until finishing node is found.
 void setBaseMap(HierarchicalMap baseMap)
          Set the current base map.
 

Method Detail

init

public void init(HierarchicalMap paramMap)
Initializes this class using the configuration passed. The configuration must be created using HierarchicalMap. The valid configuration are the same as from init(String).

Parameters:
paramMap - HierarchicalMap containing the configuration.

init

public void init(java.lang.String config)
Initializes this class using the configuration passed. The configuration must be in XML format like "<Param compress=\"true\"/>" or "<Param compress='true\'>". Note that first element must be "Param".

Configuration change is accepted until the first reading method is called. Check the specific MapInput init method for valid configurations.

Parameters:
config - configuration used by this class.

readMap

public HierarchicalMap readMap()
                        throws MapIOException
Reads-in a HierarchicalMap from input source.

Returns:
HierarchicalMap read from input or null if EOF reached.
Throws:
MapIOException - if an I/O error occurs or input stream can not be parsed to HierarchicalMap.

readMap

public HierarchicalMap readMap(java.lang.Object start)
                        throws MapIOException
Reads-in a HierarchicalMap from input source starting at specified node.

Parameters:
start - node from where the reading starts.
Returns:
HierarchicalMap read from input or null if EOF reached.
Throws:
MapIOException - if an I/O error occurs or input stream can not be parsed to HierarchicalMap.

readMap

public HierarchicalMap readMap(java.lang.Object start,
                               java.lang.Object stop)
                        throws MapIOException
Reads-in a HierarchicalMap from input source starting at specified node and finishing at stopping node.

Parameters:
start - node from where the reading starts.
stop - finish reading when this node is found.
Returns:
HierarchicalMap read from input or null if EOF reached.
Throws:
MapIOException - if an I/O error occurs or input stream can not be parsed to HierarchicalMap.

readMapUntil

public HierarchicalMap readMapUntil()
                             throws MapIOException
Reads-in a HierarchicalMap from input source until first node is found.

Returns:
HierarchicalMap read from input or null if EOF reached.
Throws:
MapIOException - if an I/O error occurs or input stream can not be parsed to HierarchicalMap.

readMapUntil

public HierarchicalMap readMapUntil(java.lang.Object stop)
                             throws MapIOException
Reads-in a HierarchicalMap from input source until finishing node is found. Whole HierarchicalMap is read if finishing node is not found. If stop node is null stop reading at first node.

Parameters:
stop - finish reading when this node is found.
Returns:
HierarchicalMap read from input or null if EOF reached.
Throws:
MapIOException - if an I/O error occurs or input stream can not be parsed to HierarchicalMap.

close

public void close()
           throws MapIOException
Closes associated input source and releases any system resources associated with it.

Throws:
MapIOException - if an I/O error occurs.

getBaseMap

public HierarchicalMap getBaseMap()
Returns current base map.

Returns:
current base map.

setBaseMap

public void setBaseMap(HierarchicalMap baseMap)
Set the current base map. The actual map returned after read methods will be created using base map's newInstance() method.

Parameters:
baseMap - HierarchicalMap used as base for creating actual structure.