|
From: Stefan T. <th...@us...> - 2002-01-30 16:24:04
|
Update of /cvsroot/xpg-xml/edu/iicm/xpg/generator
In directory usw-pr-cvs1:/tmp/cvs-serv5287/generator
Modified Files:
Generator.java
Log Message:
windows auf unix
Index: Generator.java
===================================================================
RCS file: /cvsroot/xpg-xml/edu/iicm/xpg/generator/Generator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Generator.java 2002/01/29 16:25:26 1.2
--- Generator.java 2002/01/30 16:24:00 1.3
***************
*** 1,269 ****
! // $Header$
! /***********************************************************************
! * @(#)$RCSfile$ $Revision$ $Date$
! *
! * Copyright (c) 2001 IICM, Graz University of Technology
! * Schiesstattgasse 4a, A-8010 Graz, Austria.
! *
! * This program is free software; you can redistribute it and/or modify
! * it under the terms of the GNU Lesser General Public License (LGPL)
! * as published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser 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 edu.iicm.xpg.generator;
!
! import edu.iicm.xpg.statemachine.PrimitiveStateMachine;
! import edu.iicm.xpg.statemachine.Initializer;
! import edu.iicm.xpg.statemachine.InitStateMachine;
! import edu.iicm.xpg.statemachine.XMLInput;
! import edu.iicm.xpg.statemachine.Const;
!
! import edu.iicm.xpg.transitions.PrimitiveTransition;
! import edu.iicm.xpg.transitions.StoreDocContentTransition;
! import edu.iicm.xpg.transitions.WriteDocContentTransition;
! import edu.iicm.xpg.transitions.StoreDocAuthorTransition;
! import edu.iicm.xpg.transitions.StoreDocTitleTransition;
! import edu.iicm.xpg.transitions.WriteHeaderTransition;
! import edu.iicm.xpg.transitions.IgnoreCharsTransition;
! import edu.iicm.xpg.transitions.WriteGeneralFooterTransition;
! import edu.iicm.xpg.transitions.StopMachineTransition;
! import edu.iicm.xpg.transitions.WriteGeneralHeaderTransition;
!
! import java.io.FileReader;
! import java.io.File;
! import org.xml.sax.XMLReader;
! import org.xml.sax.InputSource;
! import org.xml.sax.Attributes;
! import org.xml.sax.SAXParseException;
! import org.xml.sax.helpers.XMLReaderFactory;
! import org.xml.sax.helpers.DefaultHandler;
!
! //----------------------------------------------------------------------
! /**
! * @author Klaus Schmaranz
! * @author Heimo Haub
! * @author Günther Brand
! * @author Stefan Thalauer
! * @version $revision$
! */
!
! public class Generator extends DefaultHandler
! {
! public StringBuffer result_;
! public String doc_title_;
! public String doc_author_;
! public String content_;
! protected boolean finished_;
!
! protected final static String XML_READER = "org.apache.xerces.parsers.SAXParser";
!
! // two alternatives: seperate statemachine or hardcoded parser
! protected Initializer initializer_;
!
! protected PrimitiveStateMachine doc_state_machine_;
!
! // machine states
! protected final static String STATE_TOP_LEVEL_FILE = "file top";
! protected final static String STATE_TOP_LEVEL_DOCUMENT = "doc top";
! protected final static String STATE_DOC_INFO_DEF = "doc info def";
! protected final static String STATE_DOC_TITLE_DEF = "doc title def";
! protected final static String STATE_INFO_TITLE_DEF = "info title def";
! protected final static String STATE_DOC_AUTHOR = "doc author def";
! protected final static String STATE_DOC_CONTENT = "doc content";
! protected final static String STATE_FINISHED = "finished";
!
! //----------------------------------------------------------------------
! /**
! * @param filename the filename of the form
! */
!
! public Generator(String configfile, String filename)
! {
! try
! {
! // set up the statemachine
! // two alternatives: seperate statemachine or hardcoded parser
! initializer_ = new InitStateMachine();
! //initializer_ = new InitParser();
! initializer_.initialize(configfile);
! doc_state_machine_ = initializer_.getStateMachine();
! doc_state_machine_.setUserDefinedDataObject(this);
!
! XMLReader reader = XMLReaderFactory.createXMLReader(XML_READER);
! reader.setContentHandler(this);
! reader.setErrorHandler(this);
! File input_file = new File(filename);
! if (!input_file.exists())
! {
! System.err.println("Generator: File " + filename + " not existing");
! System.exit(-1);
! }
! FileReader file_reader = new FileReader(input_file);
! // System.out.println("\n ---> start parsing document!\n");
! reader.parse(new InputSource(file_reader));
! }
! catch (Exception exc)
! {
! exc.printStackTrace();
! }
! }
!
! //----------------------------------------------------------------------
! /**
! * @return
! */
!
! public void startDocument()
! {
! result_ = new StringBuffer();
! doc_state_machine_.initializeMachine();
! }
!
! //----------------------------------------------------------------------
! /**
! * @return
! */
!
! public synchronized void endDocument()
! {
! try
! {
! doc_state_machine_.input(new XMLInput(Const.XML_END_DOCUMENT,null));
! }
! catch(Exception exc)
! {
! exc.printStackTrace();
! }
! }
!
! //----------------------------------------------------------------------
! /**
! * @param chars the character array
! * @param start start index of the char array to work with
! * @param length number of chars in the char array to work with
! * @return
! */
!
! public void characters(char[] chars,int start,int length)
! {
! try
! {
! doc_state_machine_.input(new XMLInput(Const.XML_CHARS,chars,start,length));
! }
! catch(Exception exc)
! {
! exc.printStackTrace();
! }
! }
!
! //----------------------------------------------------------------------
! /**
! * @param uri element uri
! * @param name element name
! * @param qname ???
! * @param attributes element attributes
! * @return
! */
!
! public void startElement(String uri,String name,String qname,Attributes attributes)
! {
! try
! {
! doc_state_machine_.input(new XMLInput(Const.XML_START_TAG,name));
! }
! catch(Exception exc)
! {
! exc.printStackTrace();
! }
! }
!
! //----------------------------------------------------------------------
! /**
! * @param uri element uri
! * @param name element name
! * @param qname ???
! * @return
! */
!
! public void endElement(String uri,String name,String qname)
! {
! try
! {
! doc_state_machine_.input(new XMLInput(Const.XML_END_TAG,name));
! }
! catch(Exception exc)
! {
! exc.printStackTrace();
! }
! }
!
! //----------------------------------------------------------------------
! /**
! * @param exc the error that occured
! * @return
! */
!
! public void error(SAXParseException exc)
! {
! System.err.println("SAX Error: " + exc.getMessage());
! }
!
! //----------------------------------------------------------------------
! /**
! * @param exc the error that occured
! * @return
! */
!
! public void fatalError(SAXParseException exc)
! {
! System.err.println("SAX Fatal Error: " + exc.getMessage());
! System.exit(-2);
! }
!
! //----------------------------------------------------------------------
! /**
! * @param exc the warning that occured
! * @return
! */
!
! public void warning(SAXParseException exc)
! {
! System.err.println("SAX Warning: " + exc.getMessage());
! exc.printStackTrace();
! }
!
! //----------------------------------------------------------------------
! /**
! * @param finished sets the finished variable
! * @return
! */
!
! public void setFinished(boolean finished)
! {
! finished_ = finished;
! }
!
! //----------------------------------------------------------------------
! /**
! * @return the object that has been generated
! */
!
! public synchronized Object getResult()
! {
! return(result_.toString());
! }
! }
!
!
--- 1,268 ----
! /***********************************************************************
! * @(#)$RCSfile$ $Revision$ $Date$
! *
! * Copyright (c) 2001 IICM, Graz University of Technology
! * Schiesstattgasse 4a, A-8010 Graz, Austria.
! *
! * This program is free software; you can redistribute it and/or modify
! * it under the terms of the GNU Lesser General Public License (LGPL)
! * as published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser 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 edu.iicm.xpg.generator;
!
! import edu.iicm.xpg.statemachine.PrimitiveStateMachine;
! import edu.iicm.xpg.statemachine.Initializer;
! import edu.iicm.xpg.statemachine.InitStateMachine;
! import edu.iicm.xpg.statemachine.XMLInput;
! import edu.iicm.xpg.statemachine.Const;
!
! import edu.iicm.xpg.transitions.PrimitiveTransition;
! import edu.iicm.xpg.transitions.StoreDocContentTransition;
! import edu.iicm.xpg.transitions.WriteDocContentTransition;
! import edu.iicm.xpg.transitions.StoreDocAuthorTransition;
! import edu.iicm.xpg.transitions.StoreDocTitleTransition;
! import edu.iicm.xpg.transitions.WriteHeaderTransition;
! import edu.iicm.xpg.transitions.IgnoreCharsTransition;
! import edu.iicm.xpg.transitions.WriteGeneralFooterTransition;
! import edu.iicm.xpg.transitions.StopMachineTransition;
! import edu.iicm.xpg.transitions.WriteGeneralHeaderTransition;
!
! import java.io.FileReader;
! import java.io.File;
! import org.xml.sax.XMLReader;
! import org.xml.sax.InputSource;
! import org.xml.sax.Attributes;
! import org.xml.sax.SAXParseException;
! import org.xml.sax.helpers.XMLReaderFactory;
! import org.xml.sax.helpers.DefaultHandler;
!
! //----------------------------------------------------------------------
! /**
! * @author Klaus Schmaranz
! * @author Heimo Haub
! * @author Günther Brand
! * @author Stefan Thalauer
! * @version $revision$
! */
!
! public class Generator extends DefaultHandler
! {
! public StringBuffer result_;
! public String doc_title_;
! public String doc_author_;
! public String content_;
! protected boolean finished_;
!
! protected final static String XML_READER = "org.apache.xerces.parsers.SAXParser";
!
! // two alternatives: seperate statemachine or hardcoded parser
! protected Initializer initializer_;
!
! protected PrimitiveStateMachine doc_state_machine_;
!
! // machine states
! protected final static String STATE_TOP_LEVEL_FILE = "file top";
! protected final static String STATE_TOP_LEVEL_DOCUMENT = "doc top";
! protected final static String STATE_DOC_INFO_DEF = "doc info def";
! protected final static String STATE_DOC_TITLE_DEF = "doc title def";
! protected final static String STATE_INFO_TITLE_DEF = "info title def";
! protected final static String STATE_DOC_AUTHOR = "doc author def";
! protected final static String STATE_DOC_CONTENT = "doc content";
! protected final static String STATE_FINISHED = "finished";
!
! //----------------------------------------------------------------------
! /**
! * @param filename the filename of the form
! */
!
! public Generator(String configfile, String filename)
! {
! try
! {
! // set up the statemachine
! // two alternatives: seperate statemachine or hardcoded parser
! initializer_ = new InitStateMachine();
! //initializer_ = new InitParser();
! initializer_.initialize(configfile);
! doc_state_machine_ = initializer_.getStateMachine();
! doc_state_machine_.setUserDefinedDataObject(this);
!
! XMLReader reader = XMLReaderFactory.createXMLReader(XML_READER);
! reader.setContentHandler(this);
! reader.setErrorHandler(this);
! File input_file = new File(filename);
! if (!input_file.exists())
! {
! System.err.println("Generator: File " + filename + " not existing");
! System.exit(-1);
! }
! FileReader file_reader = new FileReader(input_file);
! // System.out.println("\n ---> start parsing document!\n");
! reader.parse(new InputSource(file_reader));
! }
! catch (Exception exc)
! {
! exc.printStackTrace();
! }
! }
!
! //----------------------------------------------------------------------
! /**
! * @return
! */
!
! public void startDocument()
! {
! result_ = new StringBuffer();
! doc_state_machine_.initializeMachine();
! }
!
! //----------------------------------------------------------------------
! /**
! * @return
! */
!
! public synchronized void endDocument()
! {
! try
! {
! doc_state_machine_.input(new XMLInput(Const.XML_END_DOCUMENT,null));
! }
! catch(Exception exc)
! {
! exc.printStackTrace();
! }
! }
!
! //----------------------------------------------------------------------
! /**
! * @param chars the character array
! * @param start start index of the char array to work with
! * @param length number of chars in the char array to work with
! * @return
! */
!
! public void characters(char[] chars,int start,int length)
! {
! try
! {
! doc_state_machine_.input(new XMLInput(Const.XML_CHARS,chars,start,length));
! }
! catch(Exception exc)
! {
! exc.printStackTrace();
! }
! }
!
! //----------------------------------------------------------------------
! /**
! * @param uri element uri
! * @param name element name
! * @param qname ???
! * @param attributes element attributes
! * @return
! */
!
! public void startElement(String uri,String name,String qname,Attributes attributes)
! {
! try
! {
! doc_state_machine_.input(new XMLInput(Const.XML_START_TAG,name));
! }
! catch(Exception exc)
! {
! exc.printStackTrace();
! }
! }
!
! //----------------------------------------------------------------------
! /**
! * @param uri element uri
! * @param name element name
! * @param qname ???
! * @return
! */
!
! public void endElement(String uri,String name,String qname)
! {
! try
! {
! doc_state_machine_.input(new XMLInput(Const.XML_END_TAG,name));
! }
! catch(Exception exc)
! {
! exc.printStackTrace();
! }
! }
!
! //----------------------------------------------------------------------
! /**
! * @param exc the error that occured
! * @return
! */
!
! public void error(SAXParseException exc)
! {
! System.err.println("SAX Error: " + exc.getMessage());
! }
!
! //----------------------------------------------------------------------
! /**
! * @param exc the error that occured
! * @return
! */
!
! public void fatalError(SAXParseException exc)
! {
! System.err.println("SAX Fatal Error: " + exc.getMessage());
! System.exit(-2);
! }
!
! //----------------------------------------------------------------------
! /**
! * @param exc the warning that occured
! * @return
! */
!
! public void warning(SAXParseException exc)
! {
! System.err.println("SAX Warning: " + exc.getMessage());
! exc.printStackTrace();
! }
!
! //----------------------------------------------------------------------
! /**
! * @param finished sets the finished variable
! * @return
! */
!
! public void setFinished(boolean finished)
! {
! finished_ = finished;
! }
!
! //----------------------------------------------------------------------
! /**
! * @return the object that has been generated
! */
!
! public synchronized Object getResult()
! {
! return(result_.toString());
! }
! }
!
!
|