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

Added javadoc comments.

parent 28dd91e5
/*
* $Id: ApplyProcess.java,v 1.4 2003-01-28 15:40:53 triolet Exp $
* $Id: ApplyProcess.java,v 1.5 2003-01-29 15:59:16 triolet Exp $
*
* Transmorpher
*
......@@ -36,6 +36,8 @@ import java.io.IOException;
import java.util.ListIterator;
/**
* This class allows to create an object able to call a transformation defined in a Process
*
*@author Jerome.Euzenat@inrialpes.fr
*@since jdk 1.3 / SAX 2.0
*/
......@@ -43,62 +45,62 @@ import java.util.ListIterator;
public class ApplyProcess extends ApplyImpl {
/**
*Constructor for the ApplyProcess object
*Creates an instance of ApplyProcess with an id and a type
*
*@param n Description of the Parameter
*@param t Description of the Parameter
*@param id The id of the instance to create
*@param type The type of the instance to create
*/
public ApplyProcess(String n, String t) {
this(n, t, null, null);
public ApplyProcess(String id, String type) {
this(id, type, null, null);
}
/**
*Constructor for the ApplyProcess object
*Creates an instance of ApplyProcess with an id, a type and a process
*
*@param n Description of the Parameter
*@param t Description of the Parameter
*@param pr Description of the Parameter
*@param id The id of the instance to create
*@param type The type of the instance to create
*@param reference The reference of the process to apply
*/
public ApplyProcess(String n, String t, String pr) {
this(n, t, null, pr);
public ApplyProcess(String id, String type, String reference) {
this(id, type, null, reference);
}
/**
*Constructor for the ApplyProcess object
*
*@param n Description of the Parameter
*@param t Description of the Parameter
*@param p Description of the Parameter
*@param id The id of the instance to create
*@param type The type of the instance to create
*@param process The process that owns this instance
*/
public ApplyProcess(String n, String t, Process p) {
this(n, t, p, null, 0, 0);
public ApplyProcess(String id, String type, Process process) {
this(id, type, process, null, 0, 0);
}
/**
*Constructor for the ApplyProcess object
*
*@param n Description of the Parameter
*@param t Description of the Parameter
*@param p Description of the Parameter
*@param pr Description of the Parameter
*@param id The id of the instance to create
*@param type The type of the instance to create
*@param process The process that owns this instance
*@param reference The reference of the process to apply
*/
public ApplyProcess(String n, String t, Process p, String pr) {
this(n, t, p, pr, 0, 0);
public ApplyProcess(String id, String type, Process process, String reference) {
this(id, type, process, reference, 0, 0);
}
/**
*Constructor for the ApplyProcess object
*
*@param n Description of the Parameter
*@param t Description of the Parameter
*@param p Description of the Parameter
*@param pr Description of the Parameter
*@param in Description of the Parameter
*@param out Description of the Parameter
*@param id The id of the instance to create
*@param type The type of the instance to create
*@param process The process that owns this instance
*@param reference The reference of the process to apply
*@param in The number of in ports
*@param out The number of out ports
*/
public ApplyProcess(String n, String t, Process p, String pr, int in, int out) {
super(n, t, p, pr, in, out);
public ApplyProcess(String id, String type, Process process, String reference, int in, int out) {
super(id, type, process, reference ,in, out);
}
/**
......@@ -135,9 +137,10 @@ public class ApplyProcess extends ApplyImpl {
}//end generate XML
/**
* Description of the Method
* Creates a TApplyProcess corresponding to this ApplyProcess object and adds it to the composite
* process in the execution structure.
*
*@param currentProcess Description of the Parameter
*@param currentProcess the container for this serializer
*/
public final void createProcess(TProcessComposite currentProcess) {
try {
......
/**
* $Id: ApplyQuery.java,v 1.3 2002-11-25 16:09:11 triolet Exp $
/*
* $Id: ApplyQuery.java,v 1.4 2003-01-29 15:59:16 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,113 +22,163 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* Transmorpher graph call node interface
*
* @author Jerome.Euzenat@inrialpes.fr
* @since jdk 1.3 / SAX 2.0
*/
package fr.fluxmedia.transmorpher.graph ;
package fr.fluxmedia.transmorpher.graph;
import fr.fluxmedia.transmorpher.engine.TProcess;
import fr.fluxmedia.transmorpher.engine.TProcessComposite;
import fr.fluxmedia.transmorpher.utils.Parameters;
import fr.fluxmedia.transmorpher.utils.Writer;
import fr.fluxmedia.transmorpher.engine.TProcessComposite;
import fr.fluxmedia.transmorpher.engine.TProcess;
import java.io.IOException;
/**
*The ApplyQuery Class introduces the use of a query in a process body. Its structure is the following:
* <br/><code><i>
* &lt;apply-query type="type" ref="name" id="id" in="channel"&gt;<br/>
* {&lt;with-param&gt;}<br/>
* &lt;/apply-query&gt;<br/>
* </i></code><br/>
*@author Jerome.Euzenat@inrialpes.fr
*@since jdk 1.3 / SAX 2.0
*/
public class ApplyQuery extends ApplyImpl {
public ApplyQuery(){
this((String)null,(String)null);
}
public ApplyQuery(String n, String t){
this(n,t,null);
}
public ApplyQuery(String n, String t,Process p){
this(n,t,p,null);
}
public ApplyQuery (String n, String t, Process p, String q){
super(n, t, p, q, 1/*NbIn */, 1/*NbOut */);
}
/** Propagate the nullify of its sole output to all the input. */
public void retroNull( PortList out, PortList in) {
nullified = out.getPort(0).getChannel().nullifiedP();
in.getPort(0).getChannel().setVisited();
if ( nullified ) in.getPort(0).getChannel().nullify();
visited = true;
update(null);
}
public void generateXML (){
System.out.print(" <apply-query id=\""+id+"\" type=\""+getType()+"\" ref=\""+getRef()+"\" ");
System.out.print("in=\"");
inPorts.generateXML();
System.out.print("\" out=\"");
outPorts.generateXML();
if ( parameters.isEmpty() ){
System.out.println("\"/>");
} else {
System.out.println("\">");
parameters.generateXMLCalls();
System.out.println(" </apply-query>");
/**
*Creates a simple instance of ApplyQuery
*/
public ApplyQuery() {
this((String)null, (String)null);
}
/**
*Creates an instance of ApplyQuery with an id and a type
*
*@param id The id of the instance to create
*@param type The type of the instance to create
*/
public ApplyQuery(String id, String type) {
this(id, type, null);
}
/**
*Creates an instance of ApplyQuery with an id ,a type and a process
*
*@param id The id of the instance to create
*@param type The type of the instance to create
*@param process The process that owns this instance
*/
public ApplyQuery(String id, String type, Process process) {
this(id, type, process, null);
}
/**
*Creates an instance of ApplyQuery with an id ,a type, a process and a reference
*
*@param id The id of the instance to create
*@param type The type of the instance to create
*@param process The process that owns this instance
*@param reference The name of the Query called by this instance
*/
public ApplyQuery(String id, String type, Process process, String reference) {
super(id, type, process,reference, 1 /*NbIn */, 1 /*NbOut */);
}
}
public final void createProcess(TProcessComposite currentProcess)
//throws TransformerException, TransformerConfigurationException, SAXException, IOException
{
String[] vPortIn = inPorts().toStringList();
String[] vPortOut = outPorts().toStringList();
String className = this.getProcess().getTransmorpher().getClassForType(getType());
// get the name corresponding to the generated stylesheet and pass it in parameter
String ref = getAttributes().getStringParameter("ref");
Transmorpher tr = getProcess().getTransmorpher() ;
String f = tr.findTransformation(ref).getAttributes().getStringParameter("file");
// static because generated by Transmorpher from the query name
// NOTE: this is specific from tmq and not the query constructor...
getParameters().setParameter("file",f);
Object [] params = {(Object)vPortIn,(Object)vPortOut, (Object)getParameters(), (Object)getAttributes()};
TProcess vCurrent = this.newProcess(className,params);
currentProcess.addProcess(vCurrent);
update(vCurrent);
} //end proc
public void setUp(){
if( getProcess().getTransmorpher().findTransformation(getRef()) == null ){
System.err.println("warning : unknown query : "+getRef());
} //end if
update(null);
} //end proc
public void generateJavaCode(Writer file) throws IOException {
file.writeln("");
file.writeln(4,"//------------------Generation of ApplyQuery: "+getId()+" -------------------");
generatePorts(file);
// Fetch the file to be processed by XSLT (this is very xsltish)
String ref = getAttributes().getStringParameter("ref");
Transmorpher tr = getProcess().getTransmorpher() ;
String f = tr.findTransformation(ref).getAttributes().getStringParameter("file");
// Added just for being generated afterwards
getParameters().setParameter("file",f);
generateParameters(file);
String className = this.getProcess().getTransmorpher().getClassForType(getType());
file.writeln(4,"tmCurrentProcess = new "+className+"(portIn,portOut,tmParameters,tmAttributes);");
file.writeln(4,"tmCurrentProcess.setName(\""+getId()+"\");");
file.writeln("");
file.writeln(4,"tmCurrentCompositeProcess.addProcess(tmCurrentProcess);");
} //end proc
} //end class
/**
* Propagate the nullify of its sole output to all the input.
*
*@param out Description of the Parameter
*@param in Description of the Parameter
*/
public void retroNull(PortList out, PortList in) {
nullified = out.getPort(0).getChannel().nullifiedP();
in.getPort(0).getChannel().setVisited();
if (nullified) {
in.getPort(0).getChannel().nullify();
}
visited = true;
update(null);
}
/**
* Prints an XML description of this ApplyQuery instance
*/
public void generateXML() {
System.out.print(" <apply-query id=\"" + id + "\" type=\"" + getType() + "\" ref=\"" + getRef() + "\" ");
System.out.print("in=\"");
inPorts.generateXML();
System.out.print("\" out=\"");
outPorts.generateXML();
if (parameters.isEmpty()) {
System.out.println("\"/>");
} else {
System.out.println("\">");
parameters.generateXMLCalls();
System.out.println(" </apply-query>");
}
}
/**
* Creates a TApplyQuery corresponding to this ApplyQuery object and adds it to the composite
* process in the execution structure.
*
*@param currentProcess the container for this serializer
*/
public final void createProcess(TProcessComposite currentProcess) {//throws TransformerException, TransformerConfigurationException, SAXException, IOException
String[] vPortIn = inPorts().toStringList();
String[] vPortOut = outPorts().toStringList();
String className = this.getProcess().getTransmorpher().getClassForType(getType());
// get the name corresponding to the generated stylesheet and pass it in parameter
String ref = getAttributes().getStringParameter("ref");
Transmorpher tr = getProcess().getTransmorpher();
String f = tr.findTransformation(ref).getAttributes().getStringParameter("file");
// static because generated by Transmorpher from the query name
// NOTE: this is specific from tmq and not the query constructor...
getParameters().setParameter("file", f);
Object[] params = {(Object)vPortIn, (Object)vPortOut, (Object)getParameters(), (Object)getAttributes()};
TProcess vCurrent = this.newProcess(className, params);
currentProcess.addProcess(vCurrent);
update(vCurrent);
}//end proc
/**
*
*/
public void setUp() {
if (getProcess().getTransmorpher().findTransformation(getRef()) == null) {
System.err.println("warning : unknown query : " + getRef());
}//end if
update(null);
}//end proc
/**
* Prints a java code description of this ApplyQuery instance
*
*@param file A writer used for printing in afile
*@exception IOException when an IO errors occur
*/
public void generateJavaCode(Writer file) throws IOException {
file.writeln("");
file.writeln(4, "//------------------Generation of ApplyQuery: " + getId() + " -------------------");
generatePorts(file);
// Fetch the file to be processed by XSLT (this is very xsltish)
String ref = getAttributes().getStringParameter("ref");
Transmorpher tr = getProcess().getTransmorpher();
String f = tr.findTransformation(ref).getAttributes().getStringParameter("file");
// Added just for being generated afterwards
getParameters().setParameter("file", f);
generateParameters(file);
String className = this.getProcess().getTransmorpher().getClassForType(getType());
file.writeln(4, "tmCurrentProcess = new " + className + "(portIn,portOut,tmParameters,tmAttributes);");
file.writeln(4, "tmCurrentProcess.setName(\"" + getId() + "\");");
file.writeln("");
file.writeln(4, "tmCurrentCompositeProcess.addProcess(tmCurrentProcess);");
}//end proc
}
/*
* $Id: ApplyRuleset.java,v 1.4 2003-01-28 15:40:53 triolet Exp $
* $Id: ApplyRuleset.java,v 1.5 2003-01-29 15:59:16 triolet Exp $
*
* Transmorpher
*
......@@ -23,132 +23,202 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* Transmorpher graph call node interface
*
* @author Jerome.Euzenat@inrialpes.fr
* @since jdk 1.3 / SAX 2.0
*/
package fr.fluxmedia.transmorpher.graph;
package fr.fluxmedia.transmorpher.graph ;
import fr.fluxmedia.transmorpher.engine.*;
import fr.fluxmedia.transmorpher.utils.Writer;
import java.io.IOException;
import fr.fluxmedia.transmorpher.utils.Writer;
import fr.fluxmedia.transmorpher.engine.*;
/**
*The ApplyRuleset Class introduces the use of a ruleset in a process body. Its structure is the following:
* <br/><code><i>
* &lt;apply-ruleset type="type" ref="name" id="id" in="channel"&gt;<br/>
* {&lt;with-param&gt;}<br/>
* &lt;/apply-ruleset&gt;<br/>
* </i></code><br/>
*@since jdk 1.3 / SAX 2.0
*@author Jerome.Euzenat@inrialpes.fr
*/
public class ApplyRuleset extends ApplyImpl {
public ApplyRuleset(){
this((String)null,(String)null);
}
public ApplyRuleset(String n, String t){
this(n,t,null,null,null);
}
public ApplyRuleset (String n, String t, Process p){
this(n,t,p,null,null);
}
public ApplyRuleset (String n, String t, Process p, String r){
this(n, t, p, r, "one-pass/top-down/apply-once");
}
public ApplyRuleset (String n, String t, Process p, String r, String s){
super(n, t, p, r, 1, 1);
// JE I still do not like to have these attributes in parameters
if(s!=null)
attributes.setParameter("strategy",s);
}
/** Propagate the nullify of its sole output to all the input. */
public void retroNull( PortList out, PortList in) {
nullified = out.getPort(0).getChannel().nullifiedP();
in.getPort(0).getChannel().setVisited();
if ( nullified ) in.getPort(0).getChannel().nullify();
visited = true;
update(null);
}
public final void setStrategy( String s ){
attributes.setParameter("strategy",s);
update(null);
}
public final String getStrategy(){
return attributes.getStringParameter("strategy");
}
public final void generateXML (){
System.out.print(" <apply-ruleset id=\""+id+"\" ref=\""+getRef()+"\" strategy=\""+getStrategy()+"\" ");
System.out.print("in=\"");
inPorts.generateXML();
System.out.print("\" out=\"");
outPorts.generateXML();
if ( parameters.isEmpty() ){
System.out.println("\"/>");
} else {
System.out.println("\">");
parameters.generateXMLCalls();
System.out.println(" </apply-ruleset>");
}
}
public final void createProcess(TProcessComposite currentProcess)
{
try{
String[] vPortIn = inPorts().toStringList();
String[] vPortOut = outPorts().toStringList();
// get the name corresponding to the generated stylesheet and pas it in parameter
String ref = getAttributes().getStringParameter("ref");
Transmorpher t = getProcess().getTransmorpher() ;
String f = t.findTransformation(ref).getAttributes().getStringParameter("file");
// static because generate by Transmorpher from the ruleset name
getParameters().setParameter("file",f);
TProcess vCurrent = new TApplyRuleset(vPortIn,vPortOut,
getParameters(),
getAttributes());
currentProcess.addProcess(vCurrent);
update(vCurrent);
/**
*Creates a simple instance of ApplyRuleset
*/
public ApplyRuleset() {
this((String)null, (String)null);
}
/**
*Creates an instance of ApplyRuleset with an id and a type
*
*@param id The id of the instance to create
*@param type The type of the instance to create
*/
public ApplyRuleset(String id, String type) {
this(id, type, null, null, null);
}
/**
*Creates an instance of ApplyRuleset with an id, a type, a process
*
*@param id The id of the instance to create
*@param type The type of the instance to create
*@param process The process that owns this instance
*/
public ApplyRuleset(String id, String type, Process process) {
this(id, type, process, null, null);
}
/**
*Creates an instance of ApplyRuleset with an id , a type, a process and a reference
*
*@param id The id of the instance to create
*@param type The type of the instance to create
*@param process The process that owns this instance
*@param reference The name of the Ruleset called by this instance
*/
public ApplyRuleset(String id, String type, Process process, String reference) {
this(id, type, process, reference, "one-pass/top-down/apply-once");
}
/**
*Creates an instance of ApplyRuleset with an id , a type, a process, a reference and a strategy
*
*@param id The id of the instance to create
*@param type The type of the instance to create
*@param process The process that owns this instance
*@param reference The name of the Ruleset called by this instance
*@param strategy Description of the Parameter
*/
public ApplyRuleset(String id, String type, Process process, String reference, String strategy) {
super(id, type, process, reference, 1, 1);
// JE I still do not like to have these attributes in parameters
if (strategy != null) {
attributes.setParameter("strategy", strategy);
}
}
/**
* Propagate the nullify of its sole output to all the input.
*
*@param out Description of the Parameter
*@param in Description of the Parameter
*/
public void retroNull(PortList out, PortList in) {
nullified = out.getPort(0).getChannel().nullifiedP();
in.getPort(0).getChannel().setVisited();
if (nullified) {
in.getPort(0).getChannel().nullify();
}
catch (Exception e){