serializablemodel.java

来自「一个很好的LIBSVM的JAVA源码。对于要研究和改进SVM算法的学者。可以参考」· Java 代码 · 共 72 行

JAVA
72
字号
/*
 *  YALE - Yet Another Learning Environment
 *  Copyright (C) 2001-2004
 *      Simon Fischer, Ralf Klinkenberg, Ingo Mierswa, 
 *          Katharina Morik, Oliver Ritthoff
 *      Artificial Intelligence Unit
 *      Computer Science Department
 *      University of Dortmund
 *      44221 Dortmund,  Germany
 *  email: yale-team@lists.sourceforge.net
 *  web:   http://yale.cs.uni-dortmund.de/
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License as 
 *  published by the Free Software Foundation; either version 2 of the
 *  License, or (at your option) any later version. 
 *
 *  This program is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *  General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 *  USA.
 */
package edu.udo.cs.yale.operator.learner;

import edu.udo.cs.yale.example.Attribute;

import java.io.*;

/** Superclass of all models which must be serializable to write them to a file.  
 *  All subclasses must have a zero-argument constructor which is invoked during
 *  deserialization.
 *
 *  @author ingo,simon
 *  @version $Id: SerializableModel.java,v 2.6 2004/08/27 11:57:38 ingomierswa Exp $
 */
public abstract class SerializableModel extends Model implements Serializable {

    public static final String ID = "YALE SerializableModel";

    protected SerializableModel() { super(); }

    public SerializableModel(Attribute label) {
	super(label);
    }

    /** Writes the model in the given file.
     */
    public void writeData(ObjectOutputStream out) throws IOException {
	out.writeObject(this);
    }

    public String getIdentifier() { return ID; }

    public static Model readSerializableModel(ObjectInput in) throws IOException {
	try {
	    return (SerializableModel)in.readObject();
	} catch (ClassNotFoundException e) {
	    throw new IOException("Unknown class for serializable model");
	}
    }
}





⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?