DLESE Tools
v1.2

org.dlese.dpc.xml
Class SimpleXMLDirectory

java.lang.Object
  extended byorg.dlese.dpc.xml.SimpleXMLDirectory
All Implemented Interfaces:
XMLDirectory

public class SimpleXMLDirectory
extends Object
implements XMLDirectory

Straightforward implementaion of the XMLDirectory interface for a file-based system, using a TreeMap for optimal sorting of keys.

Proper invocation tests init and calls setDirectory as shown in the following example.

    SimpleXMLDirectory directory = new SimpleXMLDirectory(myDirectory);

    if (directory.init()) {
       directory.setDirectory(XMLFactory.DLESE, "ID");
    }
 

The example creates a TreeMap directory of DLESE XMLMap types hashed on the DLESE "ID" metadata field.

Version:
0.9b, 05/20/02
Author:
Dave Deniman

Field Summary
protected  boolean isValid
          boolean value indicates success of initialization
protected  TreeMap map
          local map containing an XMLMap object for each well-formed XML record in directory
protected  File xmlDirectory
          file directory containing the raw XML records
 
Constructor Summary
SimpleXMLDirectory(File directory)
          Constructor for accepting a File argument.
SimpleXMLDirectory(String directoryPath)
          Constructor for accepting a String directory path argument.
 
Method Summary
 void destroy()
          Releases all resources and calls finalize method.
 XMLMap getXMLMap(Object key)
          Getter method to retrieve a specific XMLMap.
 List getXMLMapKeys()
          Retrieves a sorted list of the keys contained in the directory.
 List getXMLMaps()
          Retrieves the list of XMLMaps making up the directory.
 boolean init()
          Tests directory for validity and initialzes the local TreeMap.
 void setDirectory(int xmlMapType, String keyField)
          After successful initialization, this method creates the directory of XMLMap types using the given key.
 void setXMLMap(Object key, XMLMap values)
          Setter method for storing or updating a specific XMLMap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isValid

protected boolean isValid
boolean value indicates success of initialization


xmlDirectory

protected File xmlDirectory
file directory containing the raw XML records


map

protected TreeMap map
local map containing an XMLMap object for each well-formed XML record in directory

Constructor Detail

SimpleXMLDirectory

public SimpleXMLDirectory(File directory)
Constructor for accepting a File argument.

Parameters:
directory - The File directory containing XML records to be mapped.

SimpleXMLDirectory

public SimpleXMLDirectory(String directoryPath)
Constructor for accepting a String directory path argument.

Parameters:
directoryPath - The path to the directory containing XML records to be mapped.
Method Detail

init

public boolean init()
Tests directory for validity and initialzes the local TreeMap.

Specified by:
init in interface XMLDirectory
Returns:
true if successful, false otherwise.

destroy

public void destroy()
Releases all resources and calls finalize method.

Specified by:
destroy in interface XMLDirectory

getXMLMap

public XMLMap getXMLMap(Object key)
Getter method to retrieve a specific XMLMap.

Specified by:
getXMLMap in interface XMLDirectory
Parameters:
key - The key value identifying the specific XMLmap to retrieve.
Returns:
the requested XMLMap if it exists, null otherwise.

setXMLMap

public void setXMLMap(Object key,
                      XMLMap values)
Setter method for storing or updating a specific XMLMap.

Specified by:
setXMLMap in interface XMLDirectory
Parameters:
key - The key value identifying the specific XMLmap to update.
values - The XMLMap to store in the directory.

setDirectory

public void setDirectory(int xmlMapType,
                         String keyField)
After successful initialization, this method creates the directory of XMLMap types using the given key. The xmlMapType is identified by the static constants in XMLMapFactory. This requires the map type be predefined.

Specified by:
setDirectory in interface XMLDirectory
Parameters:
xmlMapType - integer constant references predefined mapping in XMLMapFactory.
keyField - Name of field used in the XMLMaps being created, to use as map key in directory.

getXMLMapKeys

public List getXMLMapKeys()
Retrieves a sorted list of the keys contained in the directory.

Specified by:
getXMLMapKeys in interface XMLDirectory
Returns:
the sorted list of keys used to hash the directory.

getXMLMaps

public List getXMLMaps()
Retrieves the list of XMLMaps making up the directory.

Specified by:
getXMLMaps in interface XMLDirectory
Returns:
the list of XMLMaps in the directory.

DLESE Tools
v1.2