|
From: G?nther B. <br...@us...> - 2002-02-07 09:29:10
|
Update of /cvsroot/xpg-xml/edu/iicm/xpg/generator
In directory usw-pr-cvs1:/tmp/cvs-serv4126
Modified Files:
Generator.java
Log Message:
DataObject included; Stacks included
Index: Generator.java
===================================================================
RCS file: /cvsroot/xpg-xml/edu/iicm/xpg/generator/Generator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Generator.java 30 Jan 2002 16:24:00 -0000 1.3
--- Generator.java 7 Feb 2002 09:29:07 -0000 1.4
***************
*** 29,43 ****
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;
--- 29,33 ----
import edu.iicm.xpg.statemachine.XMLInput;
import edu.iicm.xpg.statemachine.Const;
! import edu.iicm.xpg.statemachine.DataObject;
import java.io.FileReader;
***************
*** 61,70 ****
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";
--- 51,54 ----
***************
*** 74,90 ****
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
*/
--- 58,67 ----
protected PrimitiveStateMachine doc_state_machine_;
! protected DataObject data_;
//----------------------------------------------------------------------
/**
! * @param configfile the filename of the configfile
! * @param filename the filename of the inputfile
*/
***************
*** 94,103 ****
{
// 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);
--- 71,79 ----
{
// set up the statemachine
initializer_ = new InitStateMachine();
initializer_.initialize(configfile);
+ data_ = new DataObject();
doc_state_machine_ = initializer_.getStateMachine();
! doc_state_machine_.setUserDefinedDataObject(data_);
XMLReader reader = XMLReaderFactory.createXMLReader(XML_READER);
***************
*** 127,131 ****
public void startDocument()
{
! result_ = new StringBuffer();
doc_state_machine_.initializeMachine();
}
--- 103,107 ----
public void startDocument()
{
! // result_ = new StringBuffer();
doc_state_machine_.initializeMachine();
}
***************
*** 160,164 ****
try
{
! doc_state_machine_.input(new XMLInput(Const.XML_CHARS,chars,start,length));
}
catch(Exception exc)
--- 136,142 ----
try
{
! data_.popElement();
! data_.pushElement(new String(chars));
! doc_state_machine_.input(new XMLInput(Const.XML_CHARS,chars,start,length));
}
catch(Exception exc)
***************
*** 181,185 ****
try
{
! doc_state_machine_.input(new XMLInput(Const.XML_START_TAG,name));
}
catch(Exception exc)
--- 159,165 ----
try
{
! data_.pushElement(name);
! data_.pushAttributes(attributes);
! doc_state_machine_.input(new XMLInput(Const.XML_START_TAG,name));
}
catch(Exception exc)
***************
*** 202,205 ****
--- 182,187 ----
{
doc_state_machine_.input(new XMLInput(Const.XML_END_TAG,name));
+ data_.popAttributes();
+ data_.popElement();
}
catch(Exception exc)
***************
*** 246,260 ****
//----------------------------------------------------------------------
/**
- * @param finished sets the finished variable
- * @return
- */
-
- public void setFinished(boolean finished)
- {
- finished_ = finished;
- }
-
- //----------------------------------------------------------------------
- /**
* @return the object that has been generated
*/
--- 228,231 ----
***************
*** 262,268 ****
public synchronized Object getResult()
{
! return(result_.toString());
}
}
-
--- 233,238 ----
public synchronized Object getResult()
{
! return(data_.getResult().toString());
}
}
|