Commit 20864619 authored by Fabien Triolet's avatar Fabien Triolet
Browse files

Added javadoc comments, new copyright mention for 2003.

parent ccbb4ad0
/*
* $Id: Call.java,v 1.4 2003-01-28 15:40:53 triolet Exp $
* $Id: Call.java,v 1.5 2003-01-30 15:47:46 triolet Exp $
*
* Transmorpher
*
......@@ -35,7 +35,7 @@ import java.io.Serializable;
/**
* An object that implements the Call interface is a basic component
* of a tranmorpher graph. It can not contain other compononents.
* of a transmorpher graph. It can not contain other compononents .
* Methods are provided to generate an XML or a Java code representation
* of the Call.
*
......
/**
* $Id: Main.java,v 1.4 2003-01-22 09:34:07 triolet Exp $
/*
* $Id: Main.java,v 1.5 2003-01-30 15:47:46 triolet Exp $
*
* Transmorpher
*
* Copyright (C) 2001-2002 Fluxmedia and INRIA Rhône-Alpes.
* Copyright (C) INRIA Rhône-Alpes, 2003.
*
* http://www.fluxmedia.fr - http://transmorpher.inrialpes.fr
*
......@@ -21,107 +22,155 @@
* 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.graph;
import fr.fluxmedia.transmorpher.engine.*;
import fr.fluxmedia.transmorpher.utils.LinearIndexedStruct;
import fr.fluxmedia.transmorpher.utils.Parameters;
/**
* Transmorpher graph main process definitions
*
* @author Jerome.Euzenat@inrialpes.fr
* @since jdk 1.3 / SAX 2.0
*/
package fr.fluxmedia.transmorpher.graph ;
import fr.fluxmedia.transmorpher.utils.Writer;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.ListIterator;
import java.io.IOException;
import fr.fluxmedia.transmorpher.utils.Writer;
import fr.fluxmedia.transmorpher.utils.Parameters;
import fr.fluxmedia.transmorpher.utils.LinearIndexedStruct;
import fr.fluxmedia.transmorpher.engine.*;
/**
* A Main instance is a graph component that can contains calls
*
*@author Jerome.Euzenat@inrialpes.fr
*@since jdk 1.3 / SAX 2.0
*/
public class Main extends MainProcess {
public Main(String name,Transmorpher t){
super(name,t,0,0);
}
/**
*Constructor for the Main object
*
*@param name The name of the Main instance to create
*@param owner The transmorpher which owns this instance
*/
public Main(String name, Transmorpher owner) {
super(name, owner, 0, 0);
}
/** Prints the XML expression of the main */
public void generateXML(){
System.out.println(" <main name=\""+getName()+"\">");
parameters.generateXMLDeclarations();
for( ListIterator l = calls.listIterator(); l.hasNext() ; ){
((Call)l.next()).generateXML();
} //end for
System.out.println(" </main>");
System.out.println();
}
/**
* Prints the XML expression of the main
*/
public void generateXML() {
System.out.println(" <main name=\"" + getName() + "\">");
parameters.generateXMLDeclarations();
for (ListIterator l = calls.listIterator(); l.hasNext(); ) {
((Call)l.next()).generateXML();
}//end for
System.out.println(" </main>");
System.out.println();
}
public TProcessComposite createMainProcess(){
// String[] vPortIn = inPorts().toStringList();
// String[] vPortOut = outPorts().toStringList();
try{
/**
* Creates an execution component corresponding to this Main and starts the creation
* of execution components of each calls of this Main
*
*@return an execution component
*/
public TProcessComposite createMainProcess() {
try {
TProcessComposite vCurrent = new TMain(getParameters());
for( ListIterator l = calls.listIterator(); l.hasNext() ; ){
for (ListIterator l = calls.listIterator(); l.hasNext(); ) {
Call call = (Call)l.next();
call.createProcess(vCurrent);
}
return vCurrent ;
}
catch (Exception e){
return vCurrent;
} catch (Exception e) {
System.out.println("[Main] Error : cannot create Process");
System.out.println("[Main] "+e);
System.out.println("[Main] " + e);
return null;
}
}
}
/**
* Generates java code for import
*
*@param file The writer used for printing in a file
*@param externs Description of the Parameter
*@exception IOException When IO errors occur
*/
public void generateImport(Writer file, LinearIndexedStruct externs) throws IOException {
file.writeln("import fr.fluxmedia.transmorpher.application.CommandLineArgument;");
}
/**
* Generates java code for class header
*
*@param file The writer used for printing in a file
*@exception IOException When IO errors occur
*/
public void generateClassHeader(Writer file) throws IOException {
file.writeln();
file.writeln("public class " + getName() + " {");
}
public void generateImport(Writer iFile,LinearIndexedStruct externs) throws IOException {
iFile.writeln("import fr.fluxmedia.transmorpher.application.CommandLineArgument;");
}
public void generateClassHeader(Writer iFile) throws IOException {
iFile.writeln();
iFile.writeln("public class "+getName()+" {");
}
public void generateMainHeader(Writer iFile) throws IOException {
iFile.writeln(2,"public static void main(String[] argc) throws Exception {");
iFile.writeln(4,"tmProcessStack = new Stack();");
//iFile.writeln(4,"vSR = new SystemResources();");
}
public void generateReadParameters(Writer iFile) throws IOException {
iFile.writeln(4,"CommandLineArgument arg = new CommandLineArgument();");
iFile.writeln(4,"arg.argsAnalyse(argc);");
iFile.writeln(4,"debug_mode = arg.getDebugMode();");
iFile.writeln(4,"boolean thread_mode = arg.getThreadMode();");
iFile.writeln(4,"tmParameters = arg.getParameters();");
}
/**
* Generates java code for main header
*
*@param file The writer used for printing in a file
*@exception IOException When IO errors occur
*/
public void generateMainHeader(Writer file) throws IOException {
file.writeln(2, "public static void main(String[] argc) throws Exception {");
file.writeln(4, "tmProcessStack = new Stack();");
//iFile.writeln(4,"vSR = new SystemResources();");
}
public final void generateBody(Writer iFile,LinearIndexedStruct externs) throws IOException {
Parameters param = getParameters();
iFile.writeln(4,"Parameters p = new Parameters();");
for( Enumeration e = param.getNames() ; e.hasMoreElements(); ){
String key = (String)e.nextElement();
iFile.writeln(4,"p.setParameter(\""+key+"\", \""+(String)param.getParameter(key)+"\");");
/**
* Generates java code for command line parameters
*
*@param file The writer used for printing in a file
*@exception IOException When IO errors occur
*/
public void generateReadParameters(Writer file) throws IOException {
file.writeln(4, "CommandLineArgument arg = new CommandLineArgument();");
file.writeln(4, "arg.argsAnalyse(argc);");
file.writeln(4, "debug_mode = arg.getDebugMode();");
file.writeln(4, "boolean thread_mode = arg.getThreadMode();");
file.writeln(4, "tmParameters = arg.getParameters();");
}
iFile.writeln(4,"p.setParameters(tmParameters);");
iFile.writeln(4,"tmCurrentCompositeProcess = (TMain)new TMain(p);");
for( ListIterator l = getCalls().listIterator(); l.hasNext() ; ){
((Call)l.next()).generateJavaCode(iFile);
/**
* Generates java code for body
*
*@param file The writer used for printing in a file
*@param externs Description of the Parameter
*@exception IOException When IO errors occur
**/
public final void generateBody(Writer file, LinearIndexedStruct externs) throws IOException {
Parameters param = getParameters();
file.writeln(4, "Parameters p = new Parameters();");
for (Enumeration e = param.getNames(); e.hasMoreElements(); ) {
String key = (String)e.nextElement();
file.writeln(4, "p.setParameter(\"" + key + "\", \"" + (String)param.getParameter(key) + "\");");
}
file.writeln(4, "p.setParameters(tmParameters);");
file.writeln(4, "tmCurrentCompositeProcess = (TMain)new TMain(p);");
for (ListIterator l = getCalls().listIterator(); l.hasNext(); ) {
((Call)l.next()).generateJavaCode(file);
}
// JE: warning, reuse of parameters
file.writeln(4, "tmCurrentCompositeProcess.bindParameters(p);");
file.writeln(4, "tmCurrentCompositeProcess.execProcess(thread_mode);");
}//end proc
/**
* Generates java code for end
*
*@param file The writer used for printing in a file
*@exception IOException When IO errors occur
*/
public void generateEnd(Writer file) throws IOException {
file.writeln(4, "if (debug_mode>0) {");
file.writeln(6, "end = System.currentTimeMillis();");
file.writeln(6, "System.err.println(\">> End of execution (\"+(end-begin)+\")\");}");
file.writeln(2, "} //end main");
file.writeln("} //end class");
}
// JE: warning, reuse of parameters
iFile.writeln(4,"tmCurrentCompositeProcess.bindParameters(p);");
iFile.writeln(4,"tmCurrentCompositeProcess.execProcess(thread_mode);");
} //end proc
public void generateEnd(Writer iFile) throws IOException {
iFile.writeln(4,"if (debug_mode>0) {");
iFile.writeln(6,"end = System.currentTimeMillis();");
iFile.writeln(6,"System.err.println(\">> End of execution (\"+(end-begin)+\")\");}");
iFile.writeln(2,"} //end main");
iFile.writeln("} //end class");
}
}
} //end class
/**
* $Id: MainProcess.java,v 1.3 2002-11-25 16:09:11 triolet Exp $
/*
* $Id: MainProcess.java,v 1.4 2003-01-30 15:47:46 triolet Exp $
*
* Transmorpher
*
* Copyright (C) 2001-2002 Fluxmedia and INRIA Rhne-Alpes.
* Copyright (C) INRIA Rhne-Alpes, 2003.
*
* http://www.fluxmedia.fr - http://transmorpher.inrialpes.fr
*
......@@ -21,100 +22,160 @@
* 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.graph;
/**
* Transmorpher graph processes definitions
*
* @author Jerome.Euzenat@inrialpes.fr
* @since jdk 1.3 / SAX 2.0
*/
package fr.fluxmedia.transmorpher.graph ;
import fr.fluxmedia.transmorpher.engine.TApplyProcess;
import fr.fluxmedia.transmorpher.engine.TMain;
import fr.fluxmedia.transmorpher.engine.TProcess;
import fr.fluxmedia.transmorpher.engine.TProcessComposite;
import fr.fluxmedia.transmorpher.utils.LinearIndexedStruct;
import fr.fluxmedia.transmorpher.utils.Version;
import fr.fluxmedia.transmorpher.utils.Writer;
import java.util.Hashtable;
import java.io.IOException;
import java.util.Date;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.ListIterator;
import java.util.Stack;
import java.util.Date;
import java.io.IOException;
import fr.fluxmedia.transmorpher.utils.LinearIndexedStruct;
import fr.fluxmedia.transmorpher.utils.Version;
import fr.fluxmedia.transmorpher.utils.Writer;
import fr.fluxmedia.transmorpher.engine.TProcessComposite;
import fr.fluxmedia.transmorpher.engine.TApplyProcess;
import fr.fluxmedia.transmorpher.engine.TProcess;
import fr.fluxmedia.transmorpher.engine.TMain;
/**
* The MainProcess class is an helper class which provides methods to create an execution structure
* and methods to produce the java code corresponding to its type.
*
* MainProcess can be :
* <ul>
* <li>a Main, which can be executed or compiled</li>
* <li>a Servlet, which can only be compiled</li>
* <li>a Transformer, which can only be compiled</li>
* </ul>
*
*@author Jerome.Euzenat@inrialpes.fr
*@since jdk 1.3 / SAX 2.0
*/
public abstract class MainProcess extends fr.fluxmedia.transmorpher.graph.Process {
public MainProcess(String n, Transmorpher t, int nin, int nout){
super(n,t,nin,nout);
}
public abstract TProcessComposite createMainProcess();
public void generateJavaCode(Writer iFile,LinearIndexedStruct externs) throws IOException {
iFile.writeln("/** Generated by "+Version.NAME+" "+Version.RELEASE);
iFile.writeln(" See "+Version.URL);
Date date = new Date();
iFile.writeln(" "+date+" **/");
iFile.writeln();
iFile.writeln("// import Java classes");
iFile.writeln("import java.util.Stack;");
iFile.writeln();
generateImport(iFile,externs);
iFile.writeln("// import transmorpher classes");
iFile.writeln("import fr.fluxmedia.transmorpher.engine.*;");
iFile.writeln("import fr.fluxmedia.transmorpher.utils.*;");
iFile.writeln();
generateClassHeader(iFile);
iFile.writeln(4," // ressource manager");
//iFile.writeln(4,"static SystemResources vSR = null;");
iFile.writeln();
iFile.writeln(4,"//global variables for port");
iFile.writeln(4,"static String[] portIn = null ;");
iFile.writeln(4,"static String[] portOut = null;");
iFile.writeln(4,"static String[] LocIn = null ;");
iFile.writeln(4,"static String[] LocOut = null;");
iFile.writeln();
iFile.writeln(4," // global variable for the processFactory");
// BUG: This is not really compiling since stuff are created at runtime!
iFile.writeln();
// iFile.writeln(4,"private static LinearIndexedStruct newDefexterns(){");
// iFile.writeln(6,"LinearIndexedStruct defs = new LinearIndexedStruct();");
// Enumeration keys = externs.getKeys();
// while(keys.hasMoreElements()){
// String name = (String) keys.nextElement();
// iFile.writeln(6,"defs.add(\""+name+"\", (Object)\""+(String)externs.get(name)+"\");");
// };
// iFile.writeln(6,"return defs;");
// iFile.writeln(4,"}");
iFile.writeln(4," // stack of composite processes");
iFile.writeln(4,"static Stack tmProcessStack = null;");
iFile.writeln();
iFile.writeln(4," // global variables for attributes and parameters");
// Default values should be that of Transmorpher
iFile.writeln(4,"static int debug_mode = 0;");
iFile.writeln(4,"static Parameters tmParameters = null ;");
iFile.writeln(4,"static StringParameters tmAttributes = null;");
iFile.writeln();
generateMainHeader(iFile);
//temporaire
iFile.writeln(4,"double begin = System.currentTimeMillis();");
iFile.writeln(4,"double end = 0;");
iFile.writeln(4,"TProcessComposite tmCurrentCompositeProcess = null;");
iFile.writeln(4,"TProcess tmCurrentProcess = null;");
generateReadParameters(iFile);
generateBody(iFile,externs);
generateEnd(iFile);
}
public abstract void generateImport(Writer iFile,LinearIndexedStruct externs) throws IOException;
public abstract void generateClassHeader(Writer iFile) throws IOException;
public abstract void generateMainHeader(Writer iFile) throws IOException;
public abstract void generateReadParameters(Writer iFile) throws IOException;
public abstract void generateBody(Writer iFile,LinearIndexedStruct externs) throws IOException;
public abstract void generateEnd(Writer iFile) throws IOException;
/**
* Constructor for the MainProcess object.
*
*@param name The name of the MainProcess instance
*@param owner The transmorpher that owns this instance
*@param nbIn The number of in ports of this instance (should be 0)
*@param nbOut The number of out ports of this instance (should be 0)
*/
public MainProcess(String name, Transmorpher owner, int nbIn, int nbOut) {
super(name, owner , nbIn, nbOut);
}
/**
* Create an execution components that can contain others
*
*@return Description of the Return Value
*/
public abstract TProcessComposite createMainProcess();
/**
* Prints a java code description of this MainProcess instance
*
*@param file The writer used for printing in a file
*@param externs Description of the Parameter
*@exception IOException When IO errors occur
*/
public void generateJavaCode(Writer file, LinearIndexedStruct externs) throws IOException {
file.writeln("/** Generated by " + Version.NAME + " " + Version.RELEASE);
file.writeln(" See " + Version.URL);
Date date = new Date();
file.writeln(" " + date + " **/");
file.writeln();
file.writeln("// import Java classes");
file.writeln("import java.util.Stack;");
file.writeln();
generateImport(file, externs);
file.writeln("// import transmorpher classes");
file.writeln("import fr.fluxmedia.transmorpher.engine.*;");
file.writeln("import fr.fluxmedia.transmorpher.utils.*;");
file.writeln();
generateClassHeader(file);
file.writeln(4, " // ressource manager");
//iFile.writeln(4,"static SystemResources vSR = null;");
file.writeln();
file.writeln(4, "//global variables for port");
file.writeln(4, "static String[] portIn = null ;");
file.writeln(4, "static String[] portOut = null;");
file.writeln(4, "static String[] LocIn = null ;");
file.writeln(4, "static String[] LocOut = null;");
file.writeln();
file.writeln(4, " // global variable for the processFactory");
file.writeln();
file.writeln(4, " // stack of composite processes");
file.writeln(4, "static Stack tmProcessStack = null;");
file.writeln();
file.writeln(4, " // global variables for attributes and parameters");
// Default values should be that of Transmorpher
file.writeln(4, "static int debug_mode = 0;");
file.writeln(4, "static Parameters tmParameters = null ;");
file.writeln(4, "static StringParameters tmAttributes = null;");
file.writeln();
generateMainHeader(file);
//temporaire
file.writeln(4, "double begin = System.currentTimeMillis();");
file.writeln(4, "double end = 0;");
file.writeln(4, "TProcessComposite tmCurrentCompositeProcess = null;");
file.writeln(4, "TProcess tmCurrentProcess = null;");
generateReadParameters(file);
generateBody(file, externs);
generateEnd(file);
}
/**
* Generates java code for import
*
*@param file The writer used for printing in a file
*@param externs Description of the Parameter
*@exception IOException When IO errors occur
*/
public abstract void generateImport(Writer file, LinearIndexedStruct externs) throws IOException;
/**
* Generates java code for class header
*
*@param file The writer used for printing in a file
*@exception IOException When IO errors occur
*/
public abstract void generateClassHeader(Writer file) throws IOException;
/**
* Generates java code for main header
*
*@param file The writer used for printing in a file
*@exception IOException When IO errors occur
*/
public abstract void generateMainHeader(Writer file) throws IOException;
/**
* Generates java code for commmand line parameters
*
*@param file The writer used for printing in a file
*@exception IOException When IO errors occur
*/
public abstract void generateReadParameters(Writer file) throws IOException;
/**
* Generates java code for body
*
*@param file The writer used for printing in a file
*@param externs Description of the Parameter
*@exception IOException When IO errors occur
*/
public abstract void generateBody(Writer file, LinearIndexedStruct externs) throws IOException;
/**
* Generates java code for end
*
*@param file The writer used for printing in a file
*@exception IOException When IO errors occur
*/
public abstract void generateEnd(Writer file) throws IOException;
}
} //end class
/**
* $Id: Namespaced.java,v 1.2 2003-01-16 13:37:41 triolet Exp $
/*
* $Id: Namespaced.java,v 1.3 2003-01-30 15:47:46 triolet Exp $
*
* Transmorpher
*
* Copyright (C) 2002 Fluxmedia and INRIA Rhône-Alpes.
* Copyright (C) INRIA Rhône-Alpes, 2003.
*
* http://www.fluxmedia.fr - http://transmorpher.inrialpes.fr
*
......@@ -21,23 +22,25 @@
* 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.graph;
/**
* Transmorpher graph namespaced components interface
*
* @author Jerome.Euzenat@inrialpes.fr
* @since jdk 1.3 / SAX 2.0
*/
package fr.fluxmedia.transmorpher.graph ;
import fr.fluxmedia.transmorpher.graph.rules.Namespace ;
import fr.fluxmedia.transmorpher.graph.rules.Namespace;
/**
* Transmorpher graph namespaced components interface
*
*@author Jerome.Euzenat@inrialpes.fr
*@since jdk 1.3 / SAX 2.0
*/
public interface Namespaced {
/** Add the namespace to the component */
/**
* Add the namespace to the component
*
*@param nameSpace The namespace to add
*/
public void addNamespace(Namespace n);
public void addNamespace(Namespace nameSpace);
}
/**
* $Id: Null.java,v 1.1 2002-11-06 14:08:21 serge Exp $
/*
* $Id: Null.java,v 1.2 2003-01-30 15:47:46 triolet Exp $
*
* Transmorpher