Commit 662f8eb8 authored by Serge Leblanc's avatar Serge Leblanc
Browse files

first update from v1-0-0 reorganisation

parent 2a307b8e
/*
* $Id: ReadCSV.java,v 1.2 2002-10-28 09:24:22 triolet Exp $
* $Id: ReadCSV.java,v 1.3 2002-11-06 14:08:21 serge Exp $
*
* Transmorpher
*
......@@ -24,10 +24,10 @@
package fr.fluxmedia.tmcontrib.generator;
// Imported TRANSMORPHER Classes
import fr.fluxmedia.transmorpher.TProcessFactory.TReader;
import fr.fluxmedia.transmorpher.TProcessFactory.XML_Port;
import fr.fluxmedia.transmorpher.Utils.Parameters;
import fr.fluxmedia.transmorpher.Utils.StringParameters;
import fr.fluxmedia.transmorpher.engine.TReader;
import fr.fluxmedia.transmorpher.engine.XML_Port;
import fr.fluxmedia.transmorpher.utils.Parameters;
import fr.fluxmedia.transmorpher.utils.StringParameters;
//Imported JAVA classes
import java.io.File;
import java.io.FileInputStream;
......
......@@ -24,10 +24,10 @@
package fr.fluxmedia.tmcontrib.generator;
// Imported TRANSMORPHER Classes
import fr.fluxmedia.transmorpher.TProcessFactory.TReader;
import fr.fluxmedia.transmorpher.TProcessFactory.XML_Port;
import fr.fluxmedia.transmorpher.Utils.Parameters;
import fr.fluxmedia.transmorpher.Utils.StringParameters;
import fr.fluxmedia.transmorpher.engine.TReader;
import fr.fluxmedia.transmorpher.engine.XML_Port;
import fr.fluxmedia.transmorpher.utils.Parameters;
import fr.fluxmedia.transmorpher.utils.StringParameters;
//Imported JAVA classes
import java.io.File;
import java.io.FileInputStream;
......
/**
* $Id: tidy.java,v 1.6 2002-11-04 08:56:59 jerome Exp $
* $Id: tidy.java,v 1.7 2002-11-06 14:08:21 serge Exp $
*
* Transmorpher
*
......@@ -26,12 +26,12 @@ package fr.fluxmedia.tmcontrib.generator;
// Imported Transmorpher classes
import fr.fluxmedia.transmorpher.TProcessFactory.TReader;
import fr.fluxmedia.transmorpher.TProcessFactory.TProcessFactory;
import fr.fluxmedia.transmorpher.Utils.Parameters;
import fr.fluxmedia.transmorpher.Utils.StringParameters;
import fr.fluxmedia.transmorpher.Utils.SystemResources;
import fr.fluxmedia.transmorpher.Utils.TMRuntimeException;
import fr.fluxmedia.transmorpher.engine.TReader;
import fr.fluxmedia.transmorpher.engine.TProcessFactory;
import fr.fluxmedia.transmorpher.utils.Parameters;
import fr.fluxmedia.transmorpher.utils.StringParameters;
import fr.fluxmedia.transmorpher.utils.SystemResources;
import fr.fluxmedia.transmorpher.utils.TMRuntimeException;
// Imported Java classes
......
/**
* $Id: PDFSerializer.java,v 1.11 2002-11-06 07:59:10 triolet Exp $
* $Id: PDFSerializer.java,v 1.12 2002-11-06 14:08:21 serge Exp $
*
* Transmorpher
*
......@@ -26,11 +26,11 @@ package fr.fluxmedia.tmcontrib.serializer;
// Imported fr.fluxmedia.transmorpher
import fr.fluxmedia.transmorpher.TProcessFactory.TSerializer;
import fr.fluxmedia.transmorpher.Utils.TMException;
import fr.fluxmedia.transmorpher.Utils.TMRuntimeException;
import fr.fluxmedia.transmorpher.Utils.Parameters;
import fr.fluxmedia.transmorpher.Utils.StringParameters;
import fr.fluxmedia.transmorpher.engine.TSerializer;
import fr.fluxmedia.transmorpher.utils.TMException;
import fr.fluxmedia.transmorpher.utils.TMRuntimeException;
import fr.fluxmedia.transmorpher.utils.Parameters;
import fr.fluxmedia.transmorpher.utils.StringParameters;
// Imported java.io classes
......
/**
* $Id: RTFSerializer.java,v 1.5 2002-11-04 08:56:59 jerome Exp $
* $Id: RTFSerializer.java,v 1.6 2002-11-06 14:08:21 serge Exp $
*
* Transmorpher
*
......@@ -26,11 +26,11 @@ package fr.fluxmedia.tmcontrib.serializer;
// Imported fr.fluxmedia.transmorpher
import fr.fluxmedia.transmorpher.TProcessFactory.TSerializer;
import fr.fluxmedia.transmorpher.Utils.Parameters;
import fr.fluxmedia.transmorpher.Utils.StringParameters;
import fr.fluxmedia.transmorpher.Utils.TMException;
import fr.fluxmedia.transmorpher.Utils.TMRuntimeException;
import fr.fluxmedia.transmorpher.engine.TSerializer;
import fr.fluxmedia.transmorpher.utils.Parameters;
import fr.fluxmedia.transmorpher.utils.StringParameters;
import fr.fluxmedia.transmorpher.utils.TMException;
import fr.fluxmedia.transmorpher.utils.TMRuntimeException;
// Imported java.io classes
......
/**
* $Id: writevcs.java,v 1.5 2002-11-04 08:56:59 jerome Exp $
* $Id: writevcs.java,v 1.6 2002-11-06 14:08:21 serge Exp $
*
* Transmorpher
*
......@@ -26,11 +26,11 @@ package fr.fluxmedia.tmcontrib.serializer;
// Imported Transmorpher Classes
import fr.fluxmedia.transmorpher.TProcessFactory.TSerializer;
import fr.fluxmedia.transmorpher.Utils.Parameters;
import fr.fluxmedia.transmorpher.Utils.StringParameters;
import fr.fluxmedia.transmorpher.Utils.TMException;
import fr.fluxmedia.transmorpher.Utils.TMRuntimeException;
import fr.fluxmedia.transmorpher.engine.TSerializer;
import fr.fluxmedia.transmorpher.utils.Parameters;
import fr.fluxmedia.transmorpher.utils.StringParameters;
import fr.fluxmedia.transmorpher.utils.TMException;
import fr.fluxmedia.transmorpher.utils.TMRuntimeException;
//Imported JAVA Classes
......
/*
* $Id: CommandLineArgument.java,v 1.1 2002-11-06 14:08:21 serge Exp $
*
* Transmorpher
*
* Copyright (C) 2001-2002 Fluxmedia and INRIA Rhne-Alpes.
*
* http://www.fluxmedia.fr - http://transmorpher.inrialpes.fr
*
* 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 fr.fluxmedia.transmorpher.application;
import fr.fluxmedia.transmorpher.utils.Parameters;
import fr.fluxmedia.transmorpher.utils.Version;
import fr.fluxmedia.transmorpher.utils.TMException;
/**
* This is an utility class for the command line analysis
*
*@author Laurent Tardif (laurent.tardif@inrialpes.fr)
*@since jdk 1.2
*/
public final class CommandLineArgument {
/**
* The filename parameter
*/
String iFilename = null;
/**
* The relocation directory
*/
String reloc = null;
/**
* True if the command line is syntaxicly correct
*/
boolean isOk = true;
/**
* True if the debug mode is activate
*/
int debug_mode = 0;
boolean roundMode = false;
boolean execMode = true;
boolean compileMode = false;
boolean testMode = false;
boolean threadMode = false;
/**
* The parameters to be passed to the main process
*/
Parameters parameters;
/**
* The commandLine constructor
*/
public CommandLineArgument() {
parameters = new Parameters();
}
/**
* Set the filename
*
*@param pFilename The new filename value
*/
public final void setFilename(String pFilename) {
iFilename = pFilename;
}
/**
* Get the filename
*
*@return The filename value
*/
public final String getFilename() {
return iFilename;
}
/**
* Set the debug mode
*
*@param mode The new debugMode value
*/
public final void setDebugMode(int mode) {
debug_mode = mode;
}
/**
* Get the filename
*
*@return The roundMode value
*/
public final boolean getRoundMode() {
return roundMode;
}
/**
* Gets the debugMode attribute of the CommandLineArgument object
*
*@return The debugMode value
*/
public final int getDebugMode() {
return debug_mode;
}
/**
* Gets the compileMode attribute of the CommandLineArgument object
*
*@return The compileMode value
*/
public final boolean getCompileMode() {
return compileMode;
}
/**
* Gets the threadMode attribute of the CommandLineArgument object
*
*@return The threadMode value
*/
public final boolean getThreadMode() {
return threadMode;
}
/**
* Gets the execMode attribute of the CommandLineArgument object
*
*@return The execMode value
*/
public final boolean getExecMode() {
return execMode;
}
/**
* Gets the testMode attribute of the CommandLineArgument object
*
*@return The testMode value
*/
public final boolean getTestMode() {
return testMode;
}
/**
* Gets the relocation attribute of the CommandLineArgument object
*
*@return The relocation value
*/
public final String getRelocation() {
return reloc;
}
/**
* Gets the parameters attribute of the CommandLineArgument object
*
*@return The parameters value
*/
public final Parameters getParameters() {
return parameters;
}
/**
* return true if the command line is syntaxicly correct
*
*@return true if is OK
*/
public final boolean IsOk() {
return isOk;
}
/**
* Set the isOk variable to false
*/
public final void setBadCommandLineArgument() {
isOk = false;
}
/**
* Prints help on the standard output.
*/
public final static void printHelp() {
printVersion();
System.out.println("Usage : java [Javaoption] fr.fluxmedia.transmorpher.application.transmorph args");
System.out.println("");
System.out.println("Where args include :");
System.out.println(" -v print the version number");
System.out.println(" -h print this help");
System.out.println(" -d <int> debug level (by default 0=quiet)");
System.out.println(" 1=time; 2=variables; 3=detailled");
System.out.println(" -reloc <dir> relocate all generated files goes to the directory <dir>");
System.out.println(" -D<var>=<val> will run the transformation with the variable <var> set to <val>");
System.out.println(" -compile compile the process given in argument");
System.out.println(" -optimize generate an optimized process on standard output");
System.out.println(" -run run the transformation (default)");
System.out.println(" -t run the transformation with threads");
System.out.println(" -test internal use");
System.out.println(" <file> the file which describe the process to process");
}
/**
* Prints version informations.
*/
public final static void printVersion() {
System.err.println(Version.NAME + " " + Version.RELEASE + " - " + Version.DATE + " - " + Version.RIGHTS);
}
/**
* Analyse the command line arguments
*
*@param pArgs Description of the Parameter
*/
public final void argsAnalyse(String[] pArgs) throws TMException {
int vI = 0;
CommandLineArgument arg = this;
boolean no_other_option = false;
while (vI < pArgs.length) {
char signe = (pArgs[vI]).charAt(0);
if ((pArgs[vI].equals("-?") || pArgs[vI].equals("-h"))
&& !(no_other_option)) {
arg.setBadCommandLineArgument();
printHelp();
vI = pArgs.length;// all other parameters after are forbidden.
} else if (pArgs[vI].startsWith("-D")) {
int ind = pArgs[vI].indexOf('=');
parameters.setParameter(pArgs[vI].substring(2, ind), pArgs[vI].substring(ind + 1));
} else if (pArgs[vI].equals("-v") && !(no_other_option)) {
printVersion();
arg.setBadCommandLineArgument();
vI = pArgs.length;// all other parameters after is forbidden.
} else if (pArgs[vI].equals("-d")) {
if (vI++ == pArgs.length) {
printHelp();
arg.setBadCommandLineArgument();
vI = pArgs.length;
} else {
// Should trap the eventual NumberFormatException
arg.setDebugMode(Integer.parseInt(pArgs[vI]));
no_other_option = true;
}
} else if (pArgs[vI].equals("-t")) {
threadMode=true;
} else if (pArgs[vI].equals("-compile")) {
execMode = false;
roundMode = false;
no_other_option = true;
} else if (pArgs[vI].equals("-optimize")) {
execMode = false;
roundMode = true;
} else if (pArgs[vI].equals("-run")) {
execMode = true;
roundMode = false;
} else if (pArgs[vI].equals("-test")) {
execMode = false;
testMode = true;
roundMode = false;
compileMode = false;
} else if (pArgs[vI].equals("-reloc")) {
if (vI + 1 == pArgs.length) {
throw new TMException(pArgs[vI] + " : -reloc must be followed by a path");
} else {
vI = vI + 1;
reloc = pArgs[vI];
}
} else if (signe == '-') {
throw new TMException(pArgs[vI] + " : bad argument");
} else {
arg.setFilename(pArgs[vI]);
}
vI++;
}//while
}
}
/**
* $Id: Transmorph.java,v 1.1 2002-11-06 14:08:21 serge Exp $
*
* Transmorpher
*
* Copyright (C) 2001-2002 Fluxmedia and INRIA Rhne-Alpes.
*
* http://www.fluxmedia.fr - http://transmorpher.inrialpes.fr
*
* 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 fr.fluxmedia.transmorpher.application;
import fr.fluxmedia.transmorpher.graph.Transmorpher;
import fr.fluxmedia.transmorpher.parser.FMParser;
import fr.fluxmedia.transmorpher.parser.ProcessParser;
import fr.fluxmedia.transmorpher.utils.TMException;
import fr.fluxmedia.transmorpher.utils.Parameters;
import fr.fluxmedia.transmorpher.utils.SystemResources;
import java.util.Enumeration;
/**
* Parse and print and XML specification for Transmorpher.
*
*@author Laurent Tardif (laurent.tardif@inrialpes.fr)
*@author Jrme Euzenat (Jerome.Euzenat@inrialpes.fr)
*@since jdk 1.2
*/
public final class Transmorph {
/**
* debug level
*/
static int debug_mode = 0;
/**
* Process a call to a function. This is the main function of the application.
*
*@param argc -the name of the XML file which describe the execution process
*/
public final static void main(String argc[]) {
//System.setErr(System.out);
boolean time = true;
double begin = System.currentTimeMillis();
double end = 0;
SystemResources vSR = new SystemResources();
if (debug_mode > 0) {
System.err.println(">> Getting parameters");
}
CommandLineArgument arg = new CommandLineArgument();
try { arg.argsAnalyse(argc);
} catch (TMException e) {
e.printStackTrace();
return;
}
debug_mode = arg.getDebugMode();
if (debug_mode > 0 && arg.IsOk()) {
arg.printVersion();
}
if (debug_mode > 1) {
for (Enumeration e = arg.getParameters().getNames(); e.hasMoreElements(); ) {
String key = (String) e.nextElement();
String val = (String) arg.getParameters().getParameter(key);
System.err.println(" +++ " + key + " = " + val);
}//end for
}
if (arg.IsOk()) {// no continuation: error detected in command line.
if (arg.getFilename() != null) {
try {
FMParser iProcessParser = new ProcessParser(debug_mode);
if (debug_mode > 0) {
System.err.println(">> Begin graph construction");
}
Transmorpher graph = iProcessParser.Newparse(arg.getFilename());
graph.useThread(arg.getThreadMode());
if (debug_mode > 0) {
end = System.currentTimeMillis();
System.err.println(">> End of graph construction (" + (end - begin) + ")");
}
if (arg.getExecMode()) {
if (debug_mode > 0) {
System.err.println(">> Begining of Execution generation");
begin = System.currentTimeMillis();
}
graph.generateExec(arg.getRelocation());
if (debug_mode > 0) {
end = System.currentTimeMillis();
System.err.println(">> End of Execution generation (" + (end - begin) + ")");
System.err.println(">> Begining of Execution");
begin = System.currentTimeMillis();
}
graph.exec(arg.getParameters());
if(arg.getThreadMode()){
ThreadGroup group=Thread.currentThread().getThreadGroup();
int nbThread=group.activeCount();
Thread[] array=new Thread[nbThread];
group.enumerate(array);
for (int i=0;i<nbThread;i++){
//System.out.println(array[i]);
if (array[i]!=null)
if (!array[i].getName().equals("main"))
array[i].join();
}
}
if (debug_mode > 0) {
end = System.currentTimeMillis();
System.err.println(">> End of execution (" + (end - begin) + ")");
}
} else if (arg.getRoundMode()) {
graph.generateXML();
} else if (arg.getTestMode()) {
//fr.fluxmedia.transmorpher.utils.CharEngine CE= new fr.fluxmedia.transmorpher.utils.CharEngine("../samples/biblio/input/bibexmo.xml");
//CE.ReadXML();
} else {// compile mode
if (debug_mode > 0) {
System.err.println(">> Begin of code generation");
begin = System.currentTimeMillis();
}
graph.generateJavaCode(arg.getRelocation());
if (debug_mode > 0) {
end = System.currentTimeMillis();
System.err.println(">> End of code generation (" + (end - begin) + ")");
}
}
} catch (TMException e) {
e.printStackTrace();
} catch (Exception e) {
System.err.println("Transmorph : Caught error [" + e + "]");
e.printStackTrace();
}//end try
} else {
System.err.println("Transmorph : missing transformation filename");
arg.printHelp();
}// end If
}// end If
}//end main
}