MOA 12.03
Real Time Analytics for Data Streams
MakeObject.java
Go to the documentation of this file.
00001 /*
00002  *    MakeObject.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 java.io.File;
00023 import java.io.Serializable;
00024 
00025 import moa.core.Globals;
00026 import moa.core.SerializeUtils;
00027 import moa.options.ClassOption;
00028 
00035 public class MakeObject {
00036 
00042     public static void main(String[] args) {
00043         try {
00044             System.err.println();
00045             System.err.println(Globals.getWorkbenchInfoString());
00046             System.err.println();
00047             if (args.length < 2) {
00048                 System.err.println("usage: java " + MakeObject.class.getName()
00049                         + " outputfile.moa \"<object name> <options>\"");
00050                 System.err.println();
00051             } else {
00052                 String filename = args[0];
00053                 // build a single string by concatenating cli options
00054                 StringBuilder cliString = new StringBuilder();
00055                 for (int i = 1; i < args.length; i++) {
00056                     cliString.append(" " + args[i]);
00057                 }
00058                 // parse options
00059                 System.err.println("Making object...");
00060                 Object result = ClassOption.cliStringToObject(cliString.toString(), Object.class, null);
00061                 System.err.println("Writing object to file: " + filename);
00062                 SerializeUtils.writeToFile(new File(filename),
00063                         (Serializable) result);
00064                 System.err.println("Done.");
00065             }
00066         } catch (Exception ex) {
00067             ex.printStackTrace();
00068         }
00069     }
00070 }
 All Classes Namespaces Files Functions Variables Enumerations