Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/xml In directory sc8-pr-cvs1:/tmp/cvs-serv700/src/com/babeldoc/core/pipeline/xml Modified Files: IUnmarshaller.java XmlPipelineStageFactory.java XmlPipelineStageResolver.java XmlPipelineUnmarshaller.java Log Message: reformatted and updated license header Index: IUnmarshaller.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/xml/IUnmarshaller.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IUnmarshaller.java 15 Mar 2003 21:54:36 -0000 1.2 --- IUnmarshaller.java 27 Jun 2003 02:19:59 -0000 1.3 *************** *** 1,26 **** ! /* ! * $Header$ ! * $DateTime$ * * ! * babeldoc: universal document processor * ! * 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 com.babeldoc.core.pipeline.xml; - /** * Interface that all pipeline stage configuration unmarshallers --- 1,69 ---- ! /* ==================================================================== ! * The Apache Software License, Version 1.1 * + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. * ! * Redistribution and use in source and binary forms, with or without ! * modification, are permitted provided that the following conditions ! * are met: * ! * 1. Redistributions of source code must retain the above copyright ! * notice, this list of conditions and the following disclaimer. * ! * 2. Redistributions in binary form must reproduce the above copyright ! * notice, this list of conditions and the following disclaimer in ! * the documentation and/or other materials provided with the ! * distribution. ! * ! * 3. The end-user documentation included with the redistribution, ! * if any, must include the following acknowledgment: ! * "This product includes software developed by the ! * Apache Software Foundation (http://www.apache.org/)." ! * Alternately, this acknowledgment may appear in the software itself, ! * if and wherever such third-party acknowledgments normally appear. ! * ! * 4. The names "Apache" and "Apache Software Foundation" must ! * not be used to endorse or promote products derived from this ! * software without prior written permission. For written ! * permission, please contact ap...@ap.... ! * ! * 5. Products derived from this software may not be called "Apache", ! * nor may "Apache" appear in their name, without prior written ! * permission of the Apache Software Foundation. ! * ! * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ! * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ! * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ! * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ! * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ! * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ! * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ! * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ! * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ! * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ! * SUCH DAMAGE. ! * ==================================================================== ! * ! * This software consists of voluntary contributions made by many ! * individuals on behalf of the Apache Software Foundation. For more ! * information on the Apache Software Foundation, please see ! * <http://www.apache.org/>. ! * ! * Portions of this software are based upon public domain software ! * originally written at the National Center for Supercomputing Applications, ! * University of Illinois, Urbana-Champaign. ! * ==================================================================== ! * ! * Babeldoc: The Universal Document Processor ! * ! * $Header$ ! * $DateTime$ ! * $Author$ * */ package com.babeldoc.core.pipeline.xml; /** * Interface that all pipeline stage configuration unmarshallers *************** *** 33,47 **** /** ! * Get root configuration object * ! * @return */ ! public com.babeldoc.core.pipeline.PipelineStageConfig getRootConfig(); /** ! * Get the array of pipeline stage connections * ! * @return array of connections. */ ! public com.babeldoc.core.pipeline.PipelineStageConnection[] getPipelineStageConnections(); } --- 76,90 ---- /** ! * Get the array of pipeline stage connections * ! * @return array of connections. */ ! public com.babeldoc.core.pipeline.PipelineStageConnection[] getPipelineStageConnections(); /** ! * Get root configuration object * ! * @return */ ! public com.babeldoc.core.pipeline.PipelineStageConfig getRootConfig(); } Index: XmlPipelineStageFactory.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/xml/XmlPipelineStageFactory.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** XmlPipelineStageFactory.java 8 Jun 2003 18:23:46 -0000 1.5 --- XmlPipelineStageFactory.java 27 Jun 2003 02:19:59 -0000 1.6 *************** *** 1,22 **** ! /* ! * $Header$ ! * $DateTime: 2002/07/24 18:15:55 $ * * ! * babeldoc: universal document processor * ! * 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 com.babeldoc.core.pipeline.xml; --- 1,66 ---- ! /* ==================================================================== ! * The Apache Software License, Version 1.1 * + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. * ! * Redistribution and use in source and binary forms, with or without ! * modification, are permitted provided that the following conditions ! * are met: * ! * 1. Redistributions of source code must retain the above copyright ! * notice, this list of conditions and the following disclaimer. * ! * 2. Redistributions in binary form must reproduce the above copyright ! * notice, this list of conditions and the following disclaimer in ! * the documentation and/or other materials provided with the ! * distribution. ! * ! * 3. The end-user documentation included with the redistribution, ! * if any, must include the following acknowledgment: ! * "This product includes software developed by the ! * Apache Software Foundation (http://www.apache.org/)." ! * Alternately, this acknowledgment may appear in the software itself, ! * if and wherever such third-party acknowledgments normally appear. ! * ! * 4. The names "Apache" and "Apache Software Foundation" must ! * not be used to endorse or promote products derived from this ! * software without prior written permission. For written ! * permission, please contact ap...@ap.... ! * ! * 5. Products derived from this software may not be called "Apache", ! * nor may "Apache" appear in their name, without prior written ! * permission of the Apache Software Foundation. ! * ! * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ! * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ! * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ! * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ! * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ! * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ! * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ! * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ! * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ! * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ! * SUCH DAMAGE. ! * ==================================================================== ! * ! * This software consists of voluntary contributions made by many ! * individuals on behalf of the Apache Software Foundation. For more ! * information on the Apache Software Foundation, please see ! * <http://www.apache.org/>. ! * ! * Portions of this software are based upon public domain software ! * originally written at the National Center for Supercomputing Applications, ! * University of Illinois, Urbana-Champaign. ! * ==================================================================== ! * ! * Babeldoc: The Universal Document Processor ! * ! * $Header$ ! * $DateTime$ ! * $Author$ * */ package com.babeldoc.core.pipeline.xml; *************** *** 27,48 **** import java.io.IOException; import java.util.HashMap; import java.util.Map; /** ! * A xml based pipeline stage factory. Please see the schema in the readme/readme for the ! * pipeline definition xml. This is the preferred method for large pipeline stages. The ! * main issue with XML based pipeline configurations is that it cant participate in ! * configuration merging * * @author bmcdonald * @version 1.0 */ ! public class XmlPipelineStageFactory ! extends PipelineStageFactory { ! /** constant: Configuration constants */ ! public final static String XML_FILENAME = "configFile"; ! /** --- 71,91 ---- import java.io.IOException; + import java.util.HashMap; import java.util.Map; + /** ! * A xml based pipeline stage factory. Please see the schema in the ! * readme/readme for the pipeline definition xml. This is the preferred ! * method for large pipeline stages. The main issue with XML based pipeline ! * configurations is that it cant participate in configuration merging * * @author bmcdonald * @version 1.0 */ ! public class XmlPipelineStageFactory extends PipelineStageFactory { /** constant: Configuration constants */ ! public static final String XML_FILENAME = "configFile"; /** *************** *** 53,71 **** } - /** ! * Set the options. Once the the options have been set we can do the configuration ! * loving. * * @param options the hashtable of options. */ ! public void setOptions(Map options) ! throws PipelineException { super.setOptions(options); String fileName = (String) options.get(XML_FILENAME); try { setResolver(new XmlPipelineStageResolver(fileName)); ! } catch(IOException e) { throw new PipelineException(I18n.get("002001", fileName), e); } --- 96,115 ---- } /** ! * Set the options. Once the the options have been set we can do the ! * configuration loving. * * @param options the hashtable of options. + * + * @throws PipelineException DOCUMENT ME! */ ! public void setOptions(Map options) throws PipelineException { super.setOptions(options); String fileName = (String) options.get(XML_FILENAME); + try { setResolver(new XmlPipelineStageResolver(fileName)); ! } catch (IOException e) { throw new PipelineException(I18n.get("002001", fileName), e); } Index: XmlPipelineStageResolver.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/xml/XmlPipelineStageResolver.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** XmlPipelineStageResolver.java 29 May 2003 00:38:13 -0000 1.5 --- XmlPipelineStageResolver.java 27 Jun 2003 02:19:59 -0000 1.6 *************** *** 1,37 **** ! /* ! * $Header$ ! * $DateTime: 2002/07/24 18:15:55 $ * * ! * babeldoc: universal document processor * ! * 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 com.babeldoc.core.pipeline.xml; - import java.io.InputStream; - import java.io.FileNotFoundException; - import java.io.IOException; - import com.babeldoc.core.ResourceLoader; import com.babeldoc.core.pipeline.xml.digester.DigesterPipelineUnmarshaller; /** ! * An xml pipeline stage resolver. This resolver handles pipeline configurations ! * from an xml configuration file. Most of the resolver stuff is done by the simple ! * resolver. * * @author Bmcdonald --- 1,81 ---- ! /* ==================================================================== ! * The Apache Software License, Version 1.1 * + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. * ! * Redistribution and use in source and binary forms, with or without ! * modification, are permitted provided that the following conditions ! * are met: * ! * 1. Redistributions of source code must retain the above copyright ! * notice, this list of conditions and the following disclaimer. * ! * 2. Redistributions in binary form must reproduce the above copyright ! * notice, this list of conditions and the following disclaimer in ! * the documentation and/or other materials provided with the ! * distribution. ! * ! * 3. The end-user documentation included with the redistribution, ! * if any, must include the following acknowledgment: ! * "This product includes software developed by the ! * Apache Software Foundation (http://www.apache.org/)." ! * Alternately, this acknowledgment may appear in the software itself, ! * if and wherever such third-party acknowledgments normally appear. ! * ! * 4. The names "Apache" and "Apache Software Foundation" must ! * not be used to endorse or promote products derived from this ! * software without prior written permission. For written ! * permission, please contact ap...@ap.... ! * ! * 5. Products derived from this software may not be called "Apache", ! * nor may "Apache" appear in their name, without prior written ! * permission of the Apache Software Foundation. ! * ! * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ! * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ! * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ! * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ! * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ! * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ! * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ! * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ! * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ! * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ! * SUCH DAMAGE. ! * ==================================================================== ! * ! * This software consists of voluntary contributions made by many ! * individuals on behalf of the Apache Software Foundation. For more ! * information on the Apache Software Foundation, please see ! * <http://www.apache.org/>. ! * ! * Portions of this software are based upon public domain software ! * originally written at the National Center for Supercomputing Applications, ! * University of Illinois, Urbana-Champaign. ! * ==================================================================== ! * ! * Babeldoc: The Universal Document Processor ! * ! * $Header$ ! * $DateTime$ ! * $Author$ * */ package com.babeldoc.core.pipeline.xml; import com.babeldoc.core.ResourceLoader; import com.babeldoc.core.pipeline.xml.digester.DigesterPipelineUnmarshaller; + import java.io.FileNotFoundException; + import java.io.IOException; + import java.io.InputStream; + /** ! * An xml pipeline stage resolver. This resolver handles pipeline ! * configurations from an xml configuration file. Most of the resolver stuff ! * is done by the simple resolver. * * @author Bmcdonald *************** *** 41,69 **** extends com.babeldoc.core.pipeline.PipelineStageResolver implements com.babeldoc.core.pipeline.IPipelineStageResolver { - /** * Set up the data for this resolver * * @param xmlFile */ ! public XmlPipelineStageResolver(String xmlFile) ! throws IOException { super(); InputStream resourceStream = ResourceLoader.getResourceStream(xmlFile); ! if (resourceStream == null) ! { throw new RuntimeException(new FileNotFoundException(xmlFile)); } // XmlPipelineUnmarshaller unmarshaller // = new XmlPipelineUnmarshaller(resourceStream); ! DigesterPipelineUnmarshaller unmarshaller ! = new DigesterPipelineUnmarshaller(resourceStream); setupConfigData(unmarshaller); } - /** ! * Operate on the data from the unmarshaller. This is really ! * mostly already handled. Need to create the stages hashtables too. * * @param unmarshaller --- 85,114 ---- extends com.babeldoc.core.pipeline.PipelineStageResolver implements com.babeldoc.core.pipeline.IPipelineStageResolver { /** * Set up the data for this resolver * * @param xmlFile + * + * @throws IOException DOCUMENT ME! + * @throws RuntimeException DOCUMENT ME! */ ! public XmlPipelineStageResolver(String xmlFile) throws IOException { super(); + InputStream resourceStream = ResourceLoader.getResourceStream(xmlFile); ! ! if (resourceStream == null) { throw new RuntimeException(new FileNotFoundException(xmlFile)); } + // XmlPipelineUnmarshaller unmarshaller // = new XmlPipelineUnmarshaller(resourceStream); ! DigesterPipelineUnmarshaller unmarshaller = new DigesterPipelineUnmarshaller(resourceStream); setupConfigData(unmarshaller); } /** ! * Operate on the data from the unmarshaller. This is really mostly already ! * handled. Need to create the stages hashtables too. * * @param unmarshaller *************** *** 71,77 **** protected void setupConfigData(IUnmarshaller unmarshaller) { stageConfig = unmarshaller.getRootConfig(); com.babeldoc.core.pipeline.PipelineStageConnection[] connections = unmarshaller.getPipelineStageConnections(); for (int i = 0; i < connections.length; ++i) { ! setupNextStages(connections[i].getSourceStage(), connections[i].getSinkStage()); } } --- 116,125 ---- protected void setupConfigData(IUnmarshaller unmarshaller) { stageConfig = unmarshaller.getRootConfig(); + com.babeldoc.core.pipeline.PipelineStageConnection[] connections = unmarshaller.getPipelineStageConnections(); + for (int i = 0; i < connections.length; ++i) { ! setupNextStages(connections[i].getSourceStage(), ! connections[i].getSinkStage()); } } Index: XmlPipelineUnmarshaller.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/xml/XmlPipelineUnmarshaller.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** XmlPipelineUnmarshaller.java 10 Apr 2003 15:32:23 -0000 1.3 --- XmlPipelineUnmarshaller.java 27 Jun 2003 02:19:59 -0000 1.4 *************** *** 1,22 **** ! /* ! * $Header$ ! * $DateTime: 2002/07/24 18:15:55 $ * * ! * babeldoc: universal document processor * ! * 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 com.babeldoc.core.pipeline.xml; --- 1,66 ---- ! /* ==================================================================== ! * The Apache Software License, Version 1.1 * + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. * ! * Redistribution and use in source and binary forms, with or without ! * modification, are permitted provided that the following conditions ! * are met: * ! * 1. Redistributions of source code must retain the above copyright ! * notice, this list of conditions and the following disclaimer. * ! * 2. Redistributions in binary form must reproduce the above copyright ! * notice, this list of conditions and the following disclaimer in ! * the documentation and/or other materials provided with the ! * distribution. ! * ! * 3. The end-user documentation included with the redistribution, ! * if any, must include the following acknowledgment: ! * "This product includes software developed by the ! * Apache Software Foundation (http://www.apache.org/)." ! * Alternately, this acknowledgment may appear in the software itself, ! * if and wherever such third-party acknowledgments normally appear. ! * ! * 4. The names "Apache" and "Apache Software Foundation" must ! * not be used to endorse or promote products derived from this ! * software without prior written permission. For written ! * permission, please contact ap...@ap.... ! * ! * 5. Products derived from this software may not be called "Apache", ! * nor may "Apache" appear in their name, without prior written ! * permission of the Apache Software Foundation. ! * ! * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ! * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ! * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ! * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ! * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ! * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ! * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ! * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ! * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ! * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ! * SUCH DAMAGE. ! * ==================================================================== ! * ! * This software consists of voluntary contributions made by many ! * individuals on behalf of the Apache Software Foundation. For more ! * information on the Apache Software Foundation, please see ! * <http://www.apache.org/>. ! * ! * Portions of this software are based upon public domain software ! * originally written at the National Center for Supercomputing Applications, ! * University of Illinois, Urbana-Champaign. ! * ==================================================================== ! * ! * Babeldoc: The Universal Document Processor ! * ! * $Header$ ! * $DateTime$ ! * $Author$ * */ package com.babeldoc.core.pipeline.xml; *************** *** 26,88 **** import org.xml.sax.helpers.DefaultHandler; - import javax.xml.parsers.SAXParser; - import javax.xml.parsers.SAXParserFactory; import java.io.File; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.Stack; /** * Do not use this class - use the DigesterPipelineUnmarshaller instead. ! * ! * ! * Utility class to handle the decoding of pipeline xml documents to ! * the various data structures. Uses a stack algorithm to convert the data ! * from xml document to a set of datastructures. * * @author Bmcdonald * @version 1.0 * @deprecated */ ! class XmlPipelineUnmarshaller ! extends DefaultHandler ! implements IUnmarshaller { ! /** ! * XML Constants ! */ ! public final static String ENTRY_STAGE = "entry-stage"; ! public final static String OPTION_VALUE = "option-value"; ! public final static String OPTION_NAME = "option-name"; ! public final static String OPTION = "option"; ! public final static String CONNECTION = "connection"; ! public final static String SOURCE = "source"; ! public final static String SINK = "sink"; ! public final static String SUB_OPTION = "sub-option"; ! public final static String STAGE_INST = "stage-inst"; ! public final static String STAGE_NAME = "stage-name"; ! public final static String STAGE_TYPE = "stage-type"; ! public final static String STAGE_DESC = "stage-desc"; /** long term stuff */ com.babeldoc.core.pipeline.PipelineStageConfig pipelineStageConfig; - ArrayList connections; - - /** general stuff */ - String charData; /** Stack based operation */ Stack stack; int options; int suboptions; - boolean keepChars; /** ! * ! */ public XmlPipelineUnmarshaller() { this.connections = new ArrayList(); ! this.pipelineStageConfig = new com.babeldoc.core.pipeline.PipelineStageConfig("root"); stack = new Stack(); } --- 70,130 ---- import org.xml.sax.helpers.DefaultHandler; import java.io.File; import java.io.InputStream; + import java.util.ArrayList; import java.util.HashMap; import java.util.Stack; + import javax.xml.parsers.SAXParser; + import javax.xml.parsers.SAXParserFactory; + /** * Do not use this class - use the DigesterPipelineUnmarshaller instead. ! * Utility class to handle the decoding of pipeline xml documents to the ! * various data structures. Uses a stack algorithm to convert the data from ! * xml document to a set of datastructures. * * @author Bmcdonald * @version 1.0 + * * @deprecated */ ! class XmlPipelineUnmarshaller extends DefaultHandler implements IUnmarshaller { ! /** XML Constants */ ! public static final String ENTRY_STAGE = "entry-stage"; ! public static final String OPTION_VALUE = "option-value"; ! public static final String OPTION_NAME = "option-name"; ! public static final String OPTION = "option"; ! public static final String CONNECTION = "connection"; ! public static final String SOURCE = "source"; ! public static final String SINK = "sink"; ! public static final String SUB_OPTION = "sub-option"; ! public static final String STAGE_INST = "stage-inst"; ! public static final String STAGE_NAME = "stage-name"; ! public static final String STAGE_TYPE = "stage-type"; ! public static final String STAGE_DESC = "stage-desc"; ! ArrayList connections; /** long term stuff */ com.babeldoc.core.pipeline.PipelineStageConfig pipelineStageConfig; /** Stack based operation */ Stack stack; + + /** general stuff */ + String charData; + boolean keepChars; int options; int suboptions; /** ! * ! */ public XmlPipelineUnmarshaller() { this.connections = new ArrayList(); ! this.pipelineStageConfig = new com.babeldoc.core.pipeline.PipelineStageConfig( ! "root"); stack = new Stack(); } *************** *** 111,114 **** --- 153,157 ---- /** * Parse this inputsource to datastructures + * * @param source */ *************** *** 127,131 **** * * @return ! * @throws java.lang.Exception */ public static SAXParser getSAXParser() throws Exception { --- 170,175 ---- * * @return ! * ! * @throws Exception */ public static SAXParser getSAXParser() throws Exception { *************** *** 138,173 **** /** ! * Start processing an element * ! * @param namespaceUri ! * @param localName ! * @param qName ! * @param atts ! * @throws org.xml.sax.SAXException */ ! public void startElement(String namespaceUri, String localName, ! String qName, Attributes atts) throws SAXException { ! //System.out.println("StartElement: " + localName + "-" + qName); ! if (qName.equals(OPTION_VALUE) || qName.equals(OPTION_NAME) || ! qName.equals(ENTRY_STAGE) || qName.equals(SOURCE) || ! qName.equals(SINK) || qName.equals(STAGE_NAME) || ! qName.equals(STAGE_TYPE)) { ! this.keepChars = true; ! this.charData = ""; ! //System.out.println("keeping characters"); } else { ! this.keepChars = false; } } /** ! * Finish processing an element. This is where most of the hard work happens. ! * Lots of stack operations here. * * @param namespaceUri * @param localName * @param qName ! * @throws org.xml.sax.SAXException */ public void endElement(String namespaceUri, String localName, String qName) --- 182,236 ---- /** ! * Get the array of pipeline stage connections * ! * @return array of connections. */ ! public com.babeldoc.core.pipeline.PipelineStageConnection[] getPipelineStageConnections() { ! return (com.babeldoc.core.pipeline.PipelineStageConnection[]) (connections.toArray(new com.babeldoc.core.pipeline.PipelineStageConnection[0])); ! } ! /** ! * Get root configuration object ! * ! * @return DOCUMENT ME! ! */ ! public com.babeldoc.core.pipeline.PipelineStageConfig getRootConfig() { ! return this.pipelineStageConfig; ! } ! ! /** ! * Catch characters in the input stream and remember them in the charData ! * variable ! * ! * @param ch ! * @param start ! * @param length ! * ! * @throws SAXException ! */ ! public void characters(char[] ch, int start, int length) ! throws SAXException { ! //System.out.println("characters: "+start+"-"+length+": "+ch+); ! if (!keepChars) { ! charData = new String(ch, start, length); //.trim(); } else { ! String newCharData = new String(ch, start, length); //.trim(); ! ! //System.out.println(">>"+newCharData+"<<"); ! charData += newCharData; } + + //System.out.println(">>"+charData+"<<"); } /** ! * Finish processing an element. This is where most of the hard work ! * happens. Lots of stack operations here. * * @param namespaceUri * @param localName * @param qName ! * ! * @throws SAXException */ public void endElement(String namespaceUri, String localName, String qName) *************** *** 177,183 **** pipelineStageConfig.setValue(this.charData); } else if (qName.equals(CONNECTION)) { ! HashMap hash = com.babeldoc.core.Pair.getMap(new com.babeldoc.core.Pair[]{ ! (com.babeldoc.core.Pair) stack.pop(), (com.babeldoc.core.Pair) stack.pop() ! }); String source = (String) hash.get(SOURCE); String sink = (String) hash.get(SINK); --- 240,244 ---- pipelineStageConfig.setValue(this.charData); } else if (qName.equals(CONNECTION)) { ! HashMap hash = com.babeldoc.core.Pair.getMap(new com.babeldoc.core.Pair[] { (com.babeldoc.core.Pair) stack.pop(), (com.babeldoc.core.Pair) stack.pop() }); String source = (String) hash.get(SOURCE); String sink = (String) hash.get(SINK); *************** *** 185,189 **** if (source != null) { //System.out.println("Connection from "+sourceStage+" to "+sinkStage); ! connections.add(new com.babeldoc.core.pipeline.PipelineStageConnection(source, sink)); } else { throw new SAXException(com.babeldoc.core.I18n.get("018001")); --- 246,251 ---- if (source != null) { //System.out.println("Connection from "+sourceStage+" to "+sinkStage); ! connections.add(new com.babeldoc.core.pipeline.PipelineStageConnection( ! source, sink)); } else { throw new SAXException(com.babeldoc.core.I18n.get("018001")); *************** *** 192,196 **** com.babeldoc.core.pipeline.PipelineStageConfig optionConfig = new com.babeldoc.core.pipeline.PipelineStageConfig(); HashMap hash = new HashMap(); ! suboptions += 2; // Account for the name/value for this config object while (--suboptions >= 0) { --- 254,258 ---- com.babeldoc.core.pipeline.PipelineStageConfig optionConfig = new com.babeldoc.core.pipeline.PipelineStageConfig(); HashMap hash = new HashMap(); ! suboptions += 2; // Account for the name/value for this config object while (--suboptions >= 0) { *************** *** 216,222 **** suboptions = 0; } else if (qName.equals(SUB_OPTION)) { ! HashMap hash = com.babeldoc.core.Pair.getMap(new com.babeldoc.core.Pair[]{ ! (com.babeldoc.core.Pair) stack.pop(), (com.babeldoc.core.Pair) stack.pop() ! }); String name = (String) hash.get(OPTION_NAME); String value = (String) hash.get(OPTION_VALUE); --- 278,282 ---- suboptions = 0; } else if (qName.equals(SUB_OPTION)) { ! HashMap hash = com.babeldoc.core.Pair.getMap(new com.babeldoc.core.Pair[] { (com.babeldoc.core.Pair) stack.pop(), (com.babeldoc.core.Pair) stack.pop() }); String name = (String) hash.get(OPTION_NAME); String value = (String) hash.get(OPTION_VALUE); *************** *** 251,270 **** String stageDesc = (String) hash.get(STAGE_DESC); ! if ((stageName != null) && (stageType != null) && ! (stageDesc != null)) { stageConfig.setName(stageName); stageConfig.put(com.babeldoc.core.pipeline.PipelineStageConfig.STAGE_TYPE, ! new com.babeldoc.core.pipeline.PipelineStageConfig(com.babeldoc.core.pipeline.PipelineStageConfig.STAGE_TYPE, ! stageType)); stageConfig.put(com.babeldoc.core.pipeline.PipelineStageConfig.STAGE_DESC, ! new com.babeldoc.core.pipeline.PipelineStageConfig(com.babeldoc.core.pipeline.PipelineStageConfig.STAGE_DESC, ! stageDesc)); //Add it to the this.pipelineStageConfig.put(stageName, stageConfig); } else { ! com.babeldoc.core.LogService.getInstance().logError("Stagename: " + stageName + ! " stagetype: " + stageType + " stageDesc: " + stageDesc, ! null); throw new SAXException(com.babeldoc.core.I18n.get("018002")); } --- 311,329 ---- String stageDesc = (String) hash.get(STAGE_DESC); ! if ((stageName != null) && (stageType != null) && (stageDesc != null)) { stageConfig.setName(stageName); stageConfig.put(com.babeldoc.core.pipeline.PipelineStageConfig.STAGE_TYPE, ! new com.babeldoc.core.pipeline.PipelineStageConfig( ! com.babeldoc.core.pipeline.PipelineStageConfig.STAGE_TYPE, stageType)); stageConfig.put(com.babeldoc.core.pipeline.PipelineStageConfig.STAGE_DESC, ! new com.babeldoc.core.pipeline.PipelineStageConfig( ! com.babeldoc.core.pipeline.PipelineStageConfig.STAGE_DESC, stageDesc)); //Add it to the this.pipelineStageConfig.put(stageName, stageConfig); } else { ! com.babeldoc.core.LogService.getInstance().logError("Stagename: " + ! stageName + " stagetype: " + stageType + " stageDesc: " + stageDesc, ! null); throw new SAXException(com.babeldoc.core.I18n.get("018002")); } *************** *** 272,276 **** //Do nothing for these guys else if (qName.equals("dynamic") || qName.equals("pipeline") || ! qName.equals("static") || qName.equals("stage-defn")) { } //All the rest - stack 'em --- 331,335 ---- //Do nothing for these guys else if (qName.equals("dynamic") || qName.equals("pipeline") || ! qName.equals("static") || qName.equals("stage-defn")) { } //All the rest - stack 'em *************** *** 281,327 **** /** ! * Catch characters in the input stream and remember them in the charData variable * ! * @param ch ! * @param start ! * @param length ! * @throws org.xml.sax.SAXException */ ! public void characters(char[] ch, int start, int length) ! throws SAXException { ! //System.out.println("characters: "+start+"-"+length+": "+ch+); ! if (!keepChars) { ! charData = new String(ch, start, length); //.trim(); } else { ! String newCharData = new String(ch, start, length); //.trim(); ! ! //System.out.println(">>"+newCharData+"<<"); ! charData += newCharData; } - - //System.out.println(">>"+charData+"<<"); } /** ! * Get the array of pipeline stage connections * ! * @return array of connections. ! */ ! public com.babeldoc.core.pipeline.PipelineStageConnection[] getPipelineStageConnections() { ! return (com.babeldoc.core.pipeline.PipelineStageConnection[]) (connections.toArray(new com.babeldoc.core.pipeline.PipelineStageConnection[0])); ! } ! ! /** ! * Get root configuration object */ ! public com.babeldoc.core.pipeline.PipelineStageConfig getRootConfig() { ! return this.pipelineStageConfig; ! } ! public static void main(String[] args) { ! if (args.length == 0) { ! new XmlPipelineUnmarshaller(System.in); } else { ! new XmlPipelineUnmarshaller(args[0]); } } --- 340,378 ---- /** ! * TODO: DOCUMENT ME! * ! * @param args DOCUMENT ME! */ ! public static void main(String[] args) { ! if (args.length == 0) { ! new XmlPipelineUnmarshaller(System.in); } else { ! new XmlPipelineUnmarshaller(args[0]); } } /** ! * Start processing an element * ! * @param namespaceUri ! * @param localName ! * @param qName ! * @param atts ! * ! * @throws SAXException */ ! public void startElement(String namespaceUri, String localName, String qName, ! Attributes atts) throws SAXException { ! //System.out.println("StartElement: " + localName + "-" + qName); ! if (qName.equals(OPTION_VALUE) || qName.equals(OPTION_NAME) || ! qName.equals(ENTRY_STAGE) || qName.equals(SOURCE) || ! qName.equals(SINK) || qName.equals(STAGE_NAME) || ! qName.equals(STAGE_TYPE)) { ! this.keepChars = true; ! this.charData = ""; ! //System.out.println("keeping characters"); } else { ! this.keepChars = false; } } |