org.freehep.xml.io
Class XMLIOManager

java.lang.Object
  extended by org.freehep.xml.io.XMLIOManager

public class XMLIOManager
extends Object

The XMLIOManager is in charge of saving and restoring any object configuration through XML. It internally assigns objects and unique identification string used for cross-reference among xml nodes.

Version:
1.0
Author:
turri

Constructor Summary
XMLIOManager(String fileName)
          The basic constructor.
 
Method Summary
protected  XMLIOFactory getXMLIOFactory(Class objClass)
          Get the XMLIOFactory to restore the xml node param nodeEl the node to be restored
protected  XMLIOProxy getXMLIOProxy(Class objClass)
           
 XMLIORegistry getXMLIORegistry()
          Get the XMLIORegistry.
 XMLIOStreamManager getXMLIOStreamManager()
           
protected  void loadRefTable(org.jdom.Element el)
           
 void resetObjId()
          Reset the stored ids
 Object restore(org.jdom.Element nodeEl)
           
 Object restore(Object obj, org.jdom.Element nodeEl)
          Restore an object from an xml node.
 Object[] restoreFromXML()
          The main method to restore from xml.
 org.jdom.Element save(Object obj)
           
 org.jdom.Element saveAs(Object obj, Class clazz)
          Save an object to an XML node.
 void saveToXML(Object[] objs, org.jdom.Element nodeEl)
          The main method to save an array of objects to XML.
 void setClassId(Class clName, String id)
          Assign to a Class a string identifier.
protected  void setXMLIORegistry(XMLIORegistry xmlioRegistry)
           
 void setXMLIOStreamManager(XMLIOStreamManager xmlioStreamManager)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLIOManager

public XMLIOManager(String fileName)
The basic constructor.

Parameters:
xmlioRegistry - The XMLIORegistry from which the XMLIOManager gets the XMLIOFactories and the XMLIOProxies to save and restore objects.
xmlioStreamManager - The xmlioStreamManager that deals with the input/output file.
Method Detail

setXMLIORegistry

protected void setXMLIORegistry(XMLIORegistry xmlioRegistry)

getXMLIORegistry

public XMLIORegistry getXMLIORegistry()
Get the XMLIORegistry.

Returns:
the XMLIORegistry

setXMLIOStreamManager

public void setXMLIOStreamManager(XMLIOStreamManager xmlioStreamManager)

getXMLIOStreamManager

public XMLIOStreamManager getXMLIOStreamManager()

restore

public Object restore(Object obj,
                      org.jdom.Element nodeEl)
Restore an object from an xml node.

Parameters:
nodeEl - The node containing the object's information. This method should be used by the user to restore nested objects within the restore method of an object implementing the XMLIO interface.
Returns:
The restored object. The object is first created by invoking the create method on the corresponding XMLIOFactory. Once created the restore method is invoked either on the object itself (if it implements the XMLIO interface) or on the appropriate XMLIOProxy.

restore

public Object restore(org.jdom.Element nodeEl)

saveAs

public org.jdom.Element saveAs(Object obj,
                               Class clazz)
Save an object to an XML node.

Parameters:
obj - The object to be saved.
Returns:
The jdom Element containing the object's unique identification string (in the attribute "objId") and whose name is the object's identifier. The user will have to append to this node all the attributes and other jdom elemets required to save the object's configuration.

save

public org.jdom.Element save(Object obj)

saveToXML

public void saveToXML(Object[] objs,
                      org.jdom.Element nodeEl)
The main method to save an array of objects to XML.

Parameters:
objs - The array of objects to be saved.

restoreFromXML

public Object[] restoreFromXML()
The main method to restore from xml.

Returns:
The array of the restored objects.

setClassId

public void setClassId(Class clName,
                       String id)
Assign to a Class a string identifier.

Parameters:
clName - The Class.
id - The new identifier for the class.

loadRefTable

protected void loadRefTable(org.jdom.Element el)

resetObjId

public void resetObjId()
Reset the stored ids


getXMLIOFactory

protected XMLIOFactory getXMLIOFactory(Class objClass)
Get the XMLIOFactory to restore the xml node param nodeEl the node to be restored

Returns:
the XMLIOFactory

getXMLIOProxy

protected XMLIOProxy getXMLIOProxy(Class objClass)


Copyright © 2000-2007 FreeHEP. All Rights Reserved.