Commit 00ff37c7 authored by Fabien Triolet's avatar Fabien Triolet
Browse files

First Version of this dispatcher.

parent 8285cdac
/*
* $Id: TestingDispatcher.java,v 1.1 2002-10-16 08:16:16 triolet Exp $
*
* Transmorpher
*
* Copyright (C) 2001-2002 Fluxmedia and INRIA Rhône-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.stdlib ;
// Imported transmorpher classes
import fr.fluxmedia.transmorpher.TProcessFactory.*;
import fr.fluxmedia.transmorpher.Files.ReadWrite;
import fr.fluxmedia.transmorpher.Utils.Parameters;
// Imported SAX classes
import org.xml.sax.ContentHandler;
import org.xml.sax.Attributes;
import org.xml.sax.Locator ;
import org.xml.sax.SAXException;
import java.util.Hashtable;
public final class TestingDispatcher extends TDispatcher {
String test="";
String value="";
boolean then=false;
/** the constructor */
public TestingDispatcher(String[] pIn, String[] pOut,Parameters pParam){
super(pIn,pOut,pParam);
}
/** the start element method of content handler interface */
public final void startElement(String ns,String localName,String name, Attributes atts) throws SAXException {
if (then)
contentHandlers[0].startElement( ns, localName, name, atts);
else
contentHandlers[1].startElement( ns, localName, name, atts);
}
/** the endElement method of content handler interface */
public final void endElement(String ns,String localName,String name) throws SAXException {
if (then)
contentHandlers[0].endElement( ns, localName, name);
else
contentHandlers[1].endElement( ns, localName, name);
}
/** the setDocumentLocator method of content handler interface */
public final void setDocumentLocator(Locator locator) {
if (then)
contentHandlers[0].setDocumentLocator( locator);
else
contentHandlers[1].setDocumentLocator( locator);
}
/** the startDocument method of content handler interface */
public final void startDocument() throws SAXException {
test=(String)getParameters().getParameter("test");
value=(String)getParameters().getParameter("value");
if (test.equals(value))
then=true;
contentHandlers[0].startDocument();
contentHandlers[1].startDocument();
}
/** the endDocument method of content handler interface */
public final void endDocument() throws SAXException {
contentHandlers[0].endDocument();
contentHandlers[1].endDocument();
}
/** the skippedEntity method of content handler interface */
public final void skippedEntity(java.lang.String name) throws SAXException {
if (then)
contentHandlers[0].skippedEntity( name);
else
contentHandlers[1].skippedEntity( name);
}
/** the processingInstruction method of content handler interface */
public final void processingInstruction(java.lang.String target, java.lang.String data) throws SAXException {
if (then)
contentHandlers[0].processingInstruction(target, data);
else
contentHandlers[1].processingInstruction(target, data);
}
/** the ignorableWhitespace method of content handler interface */
public final void ignorableWhitespace(char[] ch, int start, int length) throws SAXException{
if (then)
contentHandlers[0].ignorableWhitespace( ch, start, length);
else
contentHandlers[1].ignorableWhitespace( ch, start, length);
}
/** the characters method of content handler interface */
public final void characters(char[] ch, int start, int length) throws SAXException{
/* char[] tmp = null;
tmp=new char[length + start];
for (int j = start; j < length + start; j++) {
tmp[j] = ch[j];
} */
if (then)
contentHandlers[0].characters( ch, start, length);
else
contentHandlers[1].characters( ch, start, length);
}
/** the startPrefixMapping method of content handler interface */
public final void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws SAXException{
if (then)
contentHandlers[0].startPrefixMapping( prefix,uri);
else
contentHandlers[1].startPrefixMapping( prefix,uri);
}
/** the endPrefixMapping method of content handler interface */
public final void endPrefixMapping(java.lang.String prefix) throws SAXException{
if (then)
contentHandlers[0].endPrefixMapping( prefix);
else
contentHandlers[1].endPrefixMapping( prefix);
}
} //end class
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