MOA 12.03
Real Time Analytics for Data Streams
AbstractTask.java
Go to the documentation of this file.
00001 /*
00002  *    AbstractTask.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.tasks;
00021 
00022 import moa.core.ObjectRepository;
00023 import moa.options.AbstractOptionHandler;
00024 
00031 public abstract class AbstractTask extends AbstractOptionHandler implements
00032         Task {
00033 
00039     public String getTaskName() {
00040         return this.getClass().getSimpleName();
00041     }
00042 
00043     @Override
00044     public Object doTask() {
00045         return doTask(new NullMonitor(), null);
00046     }
00047 
00048     @Override
00049     public Object doTask(TaskMonitor monitor, ObjectRepository repository) {
00050         monitor.setCurrentActivity("Preparing options to " + getTaskName()
00051                 + "...", -1.0);
00052         prepareClassOptions(monitor, repository);
00053         if (monitor.taskShouldAbort()) {
00054             return null;
00055         }
00056         monitor.setCurrentActivity("Doing task " + getTaskName() + "...", -1.0);
00057         Object result = doTaskImpl(monitor, repository);
00058         monitor.setCurrentActivity("Task " + getTaskName() + " complete.", 1.0);
00059         this.classOptionNamesToPreparedObjects = null; // clean up refs
00060         return result;
00061     }
00062 
00072     protected abstract Object doTaskImpl(TaskMonitor monitor,
00073             ObjectRepository repository);
00074 
00075     @Override
00076     protected void prepareForUseImpl(TaskMonitor monitor,
00077             ObjectRepository repository) {
00078         // tasks prepare themselves upon running
00079     }
00080 
00081     @Override
00082     public void getDescription(StringBuilder sb, int indent) {
00083         // TODO Auto-generated method stub
00084     }
00085 }
 All Classes Namespaces Files Functions Variables Enumerations