00001 /* 00002 * ObjectManagerFile.java 00003 * 00004 * Created on 29 October 2003, 14:54 00005 */ 00006 00007 package Sct.File; 00008 import Sct.*; 00009 00015 public class ObjectManagerFile extends AbstractObjectManager { 00016 00020 public static ObjectManagerFile getInstance() { 00021 if (instance == null) 00022 instance = new ObjectManagerFile(); 00023 return instance; 00024 } 00025 00029 public Streamable readObject(byte[] data, String className) throws java.io.IOException { 00030 IStreamFile s = new IStreamFile(data); 00031 return this.createObject(s, className); 00032 } 00033 00034 public Serializable readObject(String name) throws java.io.IOException { 00035 IStreamFile s = new IStreamFile(new NameFile(name)); 00036 return (Serializable)this.createObject(s, readClassName(s)); 00037 } 00038 00039 public Serializable readObject(String uniqueID, String className) throws java.io.IOException { 00040 return readObject(new NameFile(uniqueID, className).getName()); 00041 } 00042 00043 public Name writeObject(Serializable object) throws java.io.IOException { 00044 NameFile name = new NameFile(object); 00045 OStreamFile s = new OStreamFile(name); 00046 writeClassName(s, object.getClassName()); 00047 object.write(s, this); 00048 s.close(); 00049 return name; 00050 } 00051 00052 private ObjectManagerFile() {} 00053 private static ObjectManagerFile instance; 00054 }