Commit 9b11af21 authored by Fabien Triolet's avatar Fabien Triolet
Browse files

Added javadoc comments in FMParser and ProcessParser.

Changed some names of methods
parent dee031fa
/**
* $Id: Transmorph.java,v 1.1 2002-11-06 14:08:21 serge Exp $
* $Id: Transmorph.java,v 1.2 2003-01-23 16:06:26 triolet Exp $
*
* Transmorpher
*
......@@ -89,7 +89,7 @@ public final class Transmorph {
if (debug_mode > 0) {
System.err.println(">> Begin graph construction");
}
Transmorpher graph = iProcessParser.Newparse(arg.getFilename());
Transmorpher graph = iProcessParser.newParse(arg.getFilename());
graph.useThread(arg.getThreadMode());
if (debug_mode > 0) {
end = System.currentTimeMillis();
......
/**
* $Id: TransmorphTask.java,v 1.1 2002-11-06 14:08:21 serge Exp $
* $Id: TransmorphTask.java,v 1.2 2003-01-23 16:06:26 triolet Exp $
*
* Transmorpher
*
......@@ -134,7 +134,7 @@ public class TransmorphTask extends Task {
FMParser iProcessParser = new ProcessParser(debug_mode);
if (debug_mode > 0) System.err.println(">> Begin graph construction");
Transmorpher graph = iProcessParser.Newparse(file);
Transmorpher graph = iProcessParser.newParse(file);
if (debug_mode > 0) {
end = System.currentTimeMillis() ;
System.err.println(">> End of graph construction ("+(end-begin)+")");}
......
/**
* $Id: Transmorpher.java,v 1.5 2002-11-25 16:09:11 triolet Exp $
* $Id: Transmorpher.java,v 1.6 2003-01-23 16:06:26 triolet Exp $
*
* Transmorpher
*
......@@ -518,7 +518,7 @@ public class Transmorpher extends Observable {
public final void addImport(String i) throws ParserConfigurationException, SAXException, IOException {
// JE: The String i must be transformed in a URL that could be loaded!
FMParser iProcessParser = new ProcessParser(0);
Transmorpher timp = iProcessParser.Newparse(i);
Transmorpher timp = iProcessParser.newParse(i);
// JE: Check if there will not be a name conflict
imports.add((Object)timp);
}
......
/**
* $Id: FMParser.java,v 1.1 2002-11-06 14:08:21 serge Exp $
/*
* $Id: FMParser.java,v 1.2 2003-01-23 16:06:26 triolet Exp $
*
* Transmorpher
*
......@@ -21,90 +21,134 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
Author : Laurent Tardif
Date : 05 01 2001
Content : Define a parser for XML Document
*/
package fr.fluxmedia.transmorpher.parser ;
package fr.fluxmedia.transmorpher.parser;
//Imported Transmorpher Classes
import fr.fluxmedia.transmorpher.graph.Transmorpher;
//Imported JAVA Classes
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Stack;
//Imported JAXP Classes
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.ParserConfigurationException;
// Imported SAX Classes
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.SAXException ;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.helpers.XMLFilterImpl;
//Imported JAXP Classes
/**
* Define a parser for XML Document
*
*@Author : Laurent Tardif
*Date : 05 01 2001
*Content : Define a parser for XML Document
*/
public class FMParser extends DefaultHandler {
import javax.xml.parsers.ParserConfigurationException;
/**
* XML Parser
*/
protected SAXParser parser = null;
//Imported JAVA Classes
/**
* The current context of the parsing
*/
protected Stack iContext = null;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Stack ;
/**
* The output for a servlet
*/
protected PrintWriter output = null;
import fr.fluxmedia.transmorpher.graph.Transmorpher ;
/**
* the mode validating or not
*/
protected int debugMode = 0;
/**
Author : Laurent Tardif
Date : 05 01 2001
Content : Define a parser for XML Document
*/
public class FMParser extends DefaultHandler {
/** XML Parser */
protected javax.xml.parsers.SAXParser iParser = null;
/** The current context of the parsing*/
Stack iContext = null ;
/** The output for a servlet */
PrintWriter output=null;
/*------------------------------------------ CONSTRUCTOR ----------------------------- */
/**
* The constructor, build the XML Parser but not parse the document
*
*@param debug_mode Description of the Parameter
*@exception ParserConfigurationException Description of the Exception
*@exception SAXException Description of the Exception
*/
public FMParser(int debugMode) throws ParserConfigurationException, SAXException {
this.debugMode = debugMode;
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
if (debugMode > 0) {
parserFactory.setValidating(true);
} else {
parserFactory.setValidating(false);
}
parserFactory.setNamespaceAware(true);
parser = parserFactory.newSAXParser();
}
/* the mode validating or not*/
protected int debugMode = 0;
/*------------------------------------------- END CONSTRUCTOR ------------------------ */
/**
* Parse the document corresponding to the URI given in parameter
*
*@param uri the URI of the document to parse
*@return a graph structure
*@exception SAXException
*@exception IOException sends when an IO errors occurs
*/
public Transmorpher newParse(String uri) throws SAXException, IOException {
parser.parse(uri, this);
return new Transmorpher(debugMode);
}
/*------------------------------------------ CONSTRUCTOR -----------------------------*/
/** The constructor, build the XML Parser but not parse the document */
public FMParser(int debug_mode) throws ParserConfigurationException, SAXException {
debugMode = debug_mode;
javax.xml.parsers.SAXParserFactory iParserFactory = javax.xml.parsers.SAXParserFactory.newInstance();
if( debug_mode > 0 ) iParserFactory.setValidating(true);
else iParserFactory.setValidating(false);
iParserFactory.setNamespaceAware(true);
iParser = iParserFactory.newSAXParser();
/**
* This method is called when a warnig occurs during the parsing.
* A message with informations on the warning is printed on sdterr
*
*@param exception Description of the Parameter
*/
public void warning(SAXParseException exception) {
System.err.println("**Warning**\n"+
" URI : "+exception.getSystemId()+"\n"+
" Line : "+exception.getLineNumber()+"\n" +
" Column : "+exception.getColumnNumber()+"\n" +
" Message :"+exception.getMessage()+"\n" +
"*************");
}
}
/**
* This method is called when an error occurs during the parsing.
* A message with informations on the error is printed on sdterr
*
*@param exception Description of the Parameter
*/
public void error(SAXParseException exception) {
System.err.println("**Error**\n"+
" URI : "+exception.getSystemId()+"\n"+
" Line : "+exception.getLineNumber()+"\n" +
" Column : "+exception.getColumnNumber()+"\n" +
" Message : "+exception.getMessage()+"\n" +
"*************");
}
/*------------------------------------------- END CONSTRUCTOR ------------------------*/
/** Parse the document given in parameter */
public Transmorpher Newparse (String uri) throws SAXException, IOException {
iParser.parse(uri,this);
return new Transmorpher(debugMode);
}
public void warning(SAXParseException exception) {
System.err.println("warning");
}
public void error(SAXParseException ex)
{
System.err.print("Error!! ");
System.err.println(ex);
}
public void fatalError(SAXParseException ex) throws SAXException
{
System.err.print("Fatal Error!! ");
System.err.println(ex);
}
/**
* This method is called when an fatal error occurs during the parsing.
* A message with informations on the fatal error is printed on sdterr
* Transmorpher is stopped when this kind of errors occurs.
*
*@param exception Description of the Parameter
*@exception SAXException Description of the Exception
*/
public void fatalError(SAXParseException exception) throws SAXException {
System.err.println("**Fatal Error**\n"+
" URI : "+exception.getSystemId()+"\n"+
" Line : "+exception.getLineNumber()+"\n" +
" Column : "+exception.getColumnNumber()+"\n" +
" Message : "+exception.getMessage()+"\n"+
"*************");
throw new SAXException("Fatal Error occured during the process parsing");
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment