View Javadoc
1 // re/mind - Remote Reminder Software 2 // Copyright (C) 2002 Moritz Petersen 3 // 4 // This program is free software; you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation; either version 2 of the License, or 7 // (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with this program; if not, write to the Free Software 16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 // 18 // $Id: Serializer.java,v 1.1.1.1 2002/09/29 17:26:04 powerpete Exp $ 19 package de.jface.remind.io; 20 21 import de.jface.remind.Config; 22 23 import java.io.InputStream; 24 import java.io.OutputStream; 25 26 import java.util.Collection; 27 28 import org.apache.log4j.Logger; 29 30 /*** 31 * Class <code>Serializer</code> 32 * of project RemotePostIt. 33 * 34 * @author Moritz Petersen 35 * @version $Revision: 1.1.1.1 $ 36 */ 37 public abstract class Serializer 38 { 39 /*** 40 * The Logger. 41 */ 42 private static final Logger log4j = Logger.getLogger(Serializer.class); 43 44 /*** 45 * Decodes the data, read from the InputStream into a Collection. 46 * The created Collection only contains elements of type Note. 47 * 48 * @param in the InputStream that is decoded into the Collection of 49 * Note objects. 50 * @return a Collection containing only Note objects. 51 */ 52 public abstract Collection deserialize(InputStream in) 53 throws SerializerException; 54 55 /*** 56 * Returns a Stream, containing the serialized notes. The stream is an 57 * InputStream, from which the serialized notes can be read. 58 * 59 * @param notes A Collection. Only Note objects are considered in 60 * writing to the InputStream. 61 * @return an InputStream from which the serialized notes can be read. 62 */ 63 public abstract InputStream serialize(Collection notes) 64 throws SerializerException; 65 66 /*** 67 * Returns a new instance of the Serializer. 68 * 69 * @return a new instance of the Serializer or <code>null</code> if the 70 * Serializer could not be created. 71 */ 72 public static Serializer getInstance() 73 { 74 try 75 { 76 return (Serializer) Class.forName(Config.SERIALIZER_CLASS) 77 .newInstance(); 78 } 79 catch (Exception e) 80 { 81 log4j.fatal("Unable to create instance", e); 82 83 // TODO: Throw an exception? 84 return null; 85 } 86 } 87 }

This page was automatically generated by Maven