MOA 12.03
Real Time Analytics for Data Streams
AbstractMOAObject.java
Go to the documentation of this file.
00001 /*
00002  *    AbstractMOAObject.java
00003  *    Copyright (C) 2007 University of Waikato, Hamilton, New Zealand
00004  *    @author Richard Kirkby (rkirkby@cs.waikato.ac.nz)
00005  *
00006  *    This program is free software; you can redistribute it and/or modify
00007  *    it under the terms of the GNU General Public License as published by
00008  *    the Free Software Foundation; either version 3 of the License, or
00009  *    (at your option) any later version.
00010  *
00011  *    This program is distributed in the hope that it will be useful,
00012  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *    GNU General Public License for more details.
00015  *
00016  *    You should have received a copy of the GNU General Public License
00017  *    along with this program. If not, see <http://www.gnu.org/licenses/>.
00018  *    
00019  */
00020 package moa;
00021 
00022 import moa.core.SerializeUtils;
00023 import moa.core.SizeOf;
00024 
00032 public abstract class AbstractMOAObject implements MOAObject {
00033 
00034     @Override
00035     public MOAObject copy() {
00036         return copy(this);
00037     }
00038 
00039     @Override
00040     public int measureByteSize() {
00041         return measureByteSize(this);
00042     }
00043 
00049     @Override
00050     public String toString() {
00051         StringBuilder sb = new StringBuilder();
00052         getDescription(sb, 0);
00053         return sb.toString();
00054     }
00055 
00062     public static MOAObject copy(MOAObject obj) {
00063         try {
00064             return (MOAObject) SerializeUtils.copyObject(obj);
00065         } catch (Exception e) {
00066             throw new RuntimeException("Object copy failed.", e);
00067         }
00068     }
00069 
00076     public static int measureByteSize(MOAObject obj) {
00077         return (int) SizeOf.fullSizeOf(obj);
00078     }
00079 }
 All Classes Namespaces Files Functions Variables Enumerations