From: G?nther B. <br...@us...> - 2002-02-07 09:38:15
|
Update of /cvsroot/xpg-xml/edu/iicm/xpg/statemachine In directory usw-pr-cvs1:/tmp/cvs-serv7440 Modified Files: DataObject.java InitStateMachine.java PrimitiveStateMachine.java StateMachine.java Transition.java Log Message: DataObject and Stacks included Index: DataObject.java =================================================================== RCS file: /cvsroot/xpg-xml/edu/iicm/xpg/statemachine/DataObject.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DataObject.java 31 Jan 2002 07:33:37 -0000 1.1 --- DataObject.java 7 Feb 2002 09:38:12 -0000 1.2 *************** *** 23,27 **** --- 23,29 ---- package edu.iicm.xpg.statemachine; + import org.xml.sax.Attributes; import java.util.HashMap; + import java.util.Stack; //---------------------------------------------------------------------- *************** *** 35,42 **** --- 37,58 ---- protected boolean finished_ = false; + protected Stack element_stack_ = new Stack(); + protected Stack attribute_stack_ = new Stack(); + + protected StringBuffer result_ = new StringBuffer(); + protected HashMap data_map_ = new HashMap(); //---------------------------------------------------------------------- /** + * @param finished + */ + public void setFinished(boolean finished) + { + finished_ = finished; + } + + //---------------------------------------------------------------------- + /** * @return */ *************** *** 44,47 **** --- 60,126 ---- { return finished_; + } + + //---------------------------------------------------------------------- + /** + * @return + */ + public StringBuffer getResult() + { + return result_; + } + + //---------------------------------------------------------------------- + /** + * @param element the element that should be pushed on the stack + */ + public void pushElement(String element) + { + element_stack_.push(element); + } + + //---------------------------------------------------------------------- + /** + * @return the top element + */ + public String topElement() + { + return (String)element_stack_.peek(); + } + + //---------------------------------------------------------------------- + /** + * @return the top element and removes it + */ + public String popElement() + { + return (String)element_stack_.pop(); + } + + //---------------------------------------------------------------------- + /** + * @param attributes the attributes that should be pushed on the stack + */ + public void pushAttributes(Attributes attributes) + { + attribute_stack_.push(attributes); + } + + //---------------------------------------------------------------------- + /** + * @return the top attributes + */ + public Attributes topAttributes() + { + return (Attributes)attribute_stack_.peek(); + } + + //---------------------------------------------------------------------- + /** + * @return the top attributes and removes it + */ + public Attributes popAttributes() + { + return (Attributes)attribute_stack_.pop(); } Index: InitStateMachine.java =================================================================== RCS file: /cvsroot/xpg-xml/edu/iicm/xpg/statemachine/InitStateMachine.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** InitStateMachine.java 3 Feb 2002 22:10:57 -0000 1.3 --- InitStateMachine.java 7 Feb 2002 09:38:12 -0000 1.4 *************** *** 102,110 **** { data_ = new DataObject(); doc_state_machine_ = new PrimitiveStateMachine(); data_.putObject("doc_state_machine", doc_state_machine_); DFactory transition_factory = new DFactory(); - // FIXXME: searchpath should be read from configfile - // transition_factory.setSearchPath(new String[]{"edu.iicm.xpg.transitions"}); data_.putObject("transition_factory", transition_factory); --- 102,110 ---- { data_ = new DataObject(); + doc_state_machine_ = new PrimitiveStateMachine(); data_.putObject("doc_state_machine", doc_state_machine_); + DFactory transition_factory = new DFactory(); data_.putObject("transition_factory", transition_factory); *************** *** 160,164 **** try { ! dtd_state_machine_.input(new XMLInput(Const.XML_CHARS,chars,start,length)); } catch(Exception exc) --- 160,166 ---- try { ! data_.popElement(); ! data_.pushElement(new String(chars)); ! dtd_state_machine_.input(new XMLInput(Const.XML_CHARS,chars,start,length)); } catch(Exception exc) *************** *** 181,199 **** try { ! // FIXXME: attribute-handling in statemachine! ! //System.out.println("startElement: " + name); ! if ( attributes.getLength() > 0 ) ! { ! // whole attribtes should be copied into dataObject ! // putting attributes into dataObject doesn't work ! // because parser is modifying them afterwards ! // System.out.println("storing Attributes: " + attributes); ! // System.out.println(" " + name + "attributes: type = " + attributes.getValue("type")); ! ! // data_.putObject(name + "attributes", attributes); ! ! data_.putObject("type", attributes.getValue("type")); ! } ! dtd_state_machine_.input(new XMLInput(Const.XML_START_TAG,name)); } --- 183,188 ---- try { ! data_.pushElement(name); ! data_.pushAttributes(attributes); dtd_state_machine_.input(new XMLInput(Const.XML_START_TAG,name)); } *************** *** 217,220 **** --- 206,211 ---- { dtd_state_machine_.input(new XMLInput(Const.XML_END_TAG,name)); + data_.popAttributes(); + data_.popElement(); } catch(Exception exc) Index: PrimitiveStateMachine.java =================================================================== RCS file: /cvsroot/xpg-xml/edu/iicm/xpg/statemachine/PrimitiveStateMachine.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** PrimitiveStateMachine.java 29 Jan 2002 10:43:14 -0000 1.1.1.1 --- PrimitiveStateMachine.java 7 Feb 2002 09:38:12 -0000 1.2 *************** *** 38,42 **** protected State start_state_; protected State current_state_; ! protected Object user_data_; protected int status_; --- 38,42 ---- protected State start_state_; protected State current_state_; ! protected DataObject user_data_; protected int status_; *************** *** 219,223 **** */ ! public void setUserDefinedDataObject(Object data) { user_data_ = data; --- 219,223 ---- */ ! public void setUserDefinedDataObject(DataObject data) { user_data_ = data; Index: StateMachine.java =================================================================== RCS file: /cvsroot/xpg-xml/edu/iicm/xpg/statemachine/StateMachine.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** StateMachine.java 29 Jan 2002 10:43:14 -0000 1.1.1.1 --- StateMachine.java 7 Feb 2002 09:38:12 -0000 1.2 *************** *** 144,148 **** */ ! public void setUserDefinedDataObject(Object data); //---------------------------------------------------------------------- --- 144,148 ---- */ ! public void setUserDefinedDataObject(DataObject data); //---------------------------------------------------------------------- Index: Transition.java =================================================================== RCS file: /cvsroot/xpg-xml/edu/iicm/xpg/statemachine/Transition.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Transition.java 29 Jan 2002 10:43:12 -0000 1.1.1.1 --- Transition.java 7 Feb 2002 09:38:12 -0000 1.2 *************** *** 44,48 **** public String transitionTriggered(Input input,State from_state,State to_state, ! StateMachine machine,Object data) throws Exception; } --- 44,48 ---- public String transitionTriggered(Input input,State from_state,State to_state, ! StateMachine machine,DataObject data) throws Exception; } |