de.kleopatra.persistence
Interface IOHandler

All Known Implementing Classes:
AbstractIOHandler

public interface IOHandler

Generic handler for storing/loading objects to/from files and loading form a resource.

It's responsible for one class - clients can rely on safely doing a type-cast on a read Object like:

 	Class myClass = getHandledClass();
 	MyObject myObject = (MyObject) myClass.newInstance(); 
 
file/resourcenames are forced to the fileExtension on read/write.

Version:
$Revision: 1.1.1.1 $ - $Date: 2003/12/02 14:45:40 $
Author:
(C) Jeanette Winzenburg, Berlin

Method Summary
 java.lang.String ensureExtension(java.lang.String filename)
          returns the given filename with getFileExtension.
 java.lang.String getDescription()
          a description for use in FileFilters.
 java.lang.String getExtension()
          the fileExtension that should be used to read/write this type.
 java.lang.Class getHandledClass()
          returns the class this handler feels responsible for.
 java.lang.Object read(java.lang.String filename)
          read on object of type getHandledClass() to file with filename returns null if object's type is incompatible or an error occured.
 java.lang.Object readResource(java.lang.String resourceName, java.lang.Class targetClass)
          read on object of type getHandledClass() to file with filename returns null if object's type is incompatible or an error occured.
 void write(java.lang.Object object, java.lang.String filename)
          tries to write the given object to a file with filename.
 

Method Detail

getHandledClass

public java.lang.Class getHandledClass()
returns the class this handler feels responsible for.


getExtension

public java.lang.String getExtension()
the fileExtension that should be used to read/write this type.


ensureExtension

public java.lang.String ensureExtension(java.lang.String filename)
returns the given filename with getFileExtension.


getDescription

public java.lang.String getDescription()
a description for use in FileFilters.


write

public void write(java.lang.Object object,
                  java.lang.String filename)
tries to write the given object to a file with filename. if object's type is incompatible or an error occurs nothing is done PENDING: use exceptions in production version?


read

public java.lang.Object read(java.lang.String filename)
read on object of type getHandledClass() to file with filename returns null if object's type is incompatible or an error occured.


readResource

public java.lang.Object readResource(java.lang.String resourceName,
                                     java.lang.Class targetClass)
read on object of type getHandledClass() to file with filename returns null if object's type is incompatible or an error occured.

Parameters:
resourceName -
targetClass - class to use for resolving relative resource location locations are resolved as defined by ResourceManager.


Copyright © 2003, 2004 SwingEmpire Jeanette Winzenburg. All Rights Reserved.