yawn.io.xml
Class XmlStorage

java.lang.Object
  extended by yawn.io.xml.XmlStorage
All Implemented Interfaces:
IStorage

public class XmlStorage
extends java.lang.Object
implements IStorage

Implementation of INeuralNetworkConfigStorage backed by xml files, one per neural network configuration. The xml file names follow the pattern ${networkConfigId}-config.xml $Id: XmlStorage.java,v 1.3 2005/04/07 17:28:28 supermarti Exp $

Version:
$Revision: 1.3 $
Author:
Alexei Guevara

Constructor Summary
XmlStorage()
           
XmlStorage(XmlContext context)
           
 
Method Summary
protected  java.lang.Object deSerializeObject(java.io.File file)
           
 void flush()
           
 java.lang.String generateKey(java.lang.Object object)
           
 java.lang.Object get(java.lang.String key)
          Returns the object stored in the file named as the key.
 java.lang.Object[] getAll()
          Returns all objects in the repository.
 IContext getContext()
           
 void insert(java.lang.Object object, java.lang.String key)
          Inserts an instance of a IPersistent implementor in the underlying storage.
protected  java.io.File prepareFile(java.lang.String key)
           
protected  void serializeObject(java.lang.Object object, java.io.File file)
           
 void setContext(IContext context)
           
 void update(java.lang.Object object, java.lang.String key)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlStorage

public XmlStorage(XmlContext context)

XmlStorage

public XmlStorage()
Method Detail

setContext

public void setContext(IContext context)
Specified by:
setContext in interface IStorage
See Also:
IStorage.setContext(yawn.io.IContext)

getContext

public IContext getContext()
Specified by:
getContext in interface IStorage
See Also:
IStorage.getContext()

insert

public void insert(java.lang.Object object,
                   java.lang.String key)
            throws StorageException,
                   DuplicateKeyException
Description copied from interface: IStorage
Inserts an instance of a IPersistent implementor in the underlying storage.

Specified by:
insert in interface IStorage
Parameters:
object - The IPersistent implementor instance to store.
Throws:
StorageException
DuplicateKeyException
See Also:
IStorage.insert(java.lang.Object, java.lang.String)

serializeObject

protected void serializeObject(java.lang.Object object,
                               java.io.File file)
                        throws StorageException
Throws:
StorageException

generateKey

public java.lang.String generateKey(java.lang.Object object)
Specified by:
generateKey in interface IStorage
See Also:
IStorage.generateKey(java.lang.Object)

prepareFile

protected java.io.File prepareFile(java.lang.String key)

update

public void update(java.lang.Object object,
                   java.lang.String key)
            throws KeyNotPresentException,
                   StorageException
Specified by:
update in interface IStorage
Throws:
KeyNotPresentException
StorageException
See Also:
IStorage.update(java.lang.Object, java.lang.String)

get

public java.lang.Object get(java.lang.String key)
                     throws StorageException,
                            KeyNotPresentException
Returns the object stored in the file named as the key. The base class of this object is specified in XmlContext.getRootSerializationClass().

Specified by:
get in interface IStorage
Returns:
The IPersistent implementor instance that matches the provided id, or null if not matching instance is found.
Throws:
StorageException
KeyNotPresentException
See Also:
XmlContext.getRootSerializationClass(), IStorage.get(java.lang.String)

deSerializeObject

protected java.lang.Object deSerializeObject(java.io.File file)
                                      throws StorageException
Throws:
StorageException

getAll

public java.lang.Object[] getAll()
                          throws StorageException
Returns all objects in the repository.

Specified by:
getAll in interface IStorage
Returns:
All the retrieved instances.
Throws:
StorageException
See Also:
IStorage.getAll()

flush

public void flush()
Specified by:
flush in interface IStorage
See Also:
IStorage.flush()


Copyright © 2003-2005 GIAA, Universidad Carlos III de Madrid. All Rights Reserved.