From: G?nther B. <br...@us...> - 2002-02-07 09:42:21
|
Update of /cvsroot/xpg-xml/edu/iicm/xpg/transitions/simple In directory usw-pr-cvs1:/tmp/cvs-serv8789 Added Files: StoreDocAuthorTransition.java StoreDocContentTransition.java StoreDocTitleTransition.java WriteDocContentTransition.java WriteGeneralFooterTransition.java WriteGeneralHeaderTransition.java WriteHeaderTransition.java Log Message: files moved --- NEW FILE: StoreDocAuthorTransition.java --- /*********************************************************************** * @(#)$RCSfile: StoreDocAuthorTransition.java,v $ $Revision: 1.1 $ $Date: 2002/02/07 09:42:18 $ * * 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.transitions.simple; import edu.iicm.xpg.statemachine.Transition; import edu.iicm.xpg.statemachine.State; import edu.iicm.xpg.statemachine.StateMachine; import edu.iicm.xpg.statemachine.Input; import edu.iicm.xpg.statemachine.XMLInput; import edu.iicm.xpg.statemachine.DataObject; //---------------------------------------------------------------------- /** * @author Klaus Schmaranz * @author Günther Brand * @version $Revision: 1.1 $ */ public class StoreDocAuthorTransition implements Transition { //---------------------------------------------------------------------- /** * @param input the input that triggered this transition * @param from_state the start state for this transition * @param to_state the destination state for this transition * @param machine the state machine that this transition belongs to * @param data user defined data * @return * @exception Exception whatever an implementation can throw */ public String transitionTriggered(Input input,State from_state,State to_state, StateMachine machine,DataObject data) throws Exception { String doc_author = (String)data.getObject("doc_author"); if (doc_author == null) data.putObject("doc_author", ((XMLInput)input).getValue()); else doc_author = doc_author + ((XMLInput)input).getValue(); // FIXXME: should be obsolete // ((Generator)data).doc_author_ = doc_author; return(null); } } --- NEW FILE: StoreDocContentTransition.java --- /*********************************************************************** * @(#)$RCSfile: StoreDocContentTransition.java,v $ $Revision: 1.1 $ $Date: 2002/02/07 09:42:18 $ * * 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.transitions.simple; import edu.iicm.xpg.statemachine.Transition; import edu.iicm.xpg.statemachine.State; import edu.iicm.xpg.statemachine.StateMachine; import edu.iicm.xpg.statemachine.Input; import edu.iicm.xpg.statemachine.XMLInput; import edu.iicm.xpg.statemachine.DataObject; //---------------------------------------------------------------------- /** * @author Günther Brand * @version $Revision: 1.1 $ */ public class StoreDocContentTransition implements Transition { //---------------------------------------------------------------------- /** * @param input the input that triggered this transition * @param from_state the start state for this transition * @param to_state the destination state for this transition * @param machine the state machine that this transition belongs to * @param data user defined data * @return * @exception Exception whatever an implementation can throw */ public String transitionTriggered(Input input,State from_state,State to_state, StateMachine machine,DataObject data) throws Exception { String content = (String)data.getObject("content"); if (content == null) data.putObject("content", ((XMLInput)input).getValue()); else content += ((XMLInput)input).getValue(); return(null); } } --- NEW FILE: StoreDocTitleTransition.java --- /*********************************************************************** * @(#)$RCSfile: StoreDocTitleTransition.java,v $ $Revision: 1.1 $ $Date: 2002/02/07 09:42:18 $ * * 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.transitions.simple; import edu.iicm.xpg.statemachine.Transition; import edu.iicm.xpg.statemachine.State; import edu.iicm.xpg.statemachine.StateMachine; import edu.iicm.xpg.statemachine.Input; import edu.iicm.xpg.statemachine.XMLInput; import edu.iicm.xpg.statemachine.DataObject; //---------------------------------------------------------------------- /** * @author Klaus Schmaranz * @version $Revision: 1.1 $ */ public class StoreDocTitleTransition implements Transition { //---------------------------------------------------------------------- /** * @param input the input that triggered this transition * @param from_state the start state for this transition * @param to_state the destination state for this transition * @param machine the state machine that this transition belongs to * @param data user defined data * @return * @exception Exception whatever an implementation can throw */ public String transitionTriggered(Input input,State from_state,State to_state, StateMachine machine,DataObject data) throws Exception { String doc_title = (String)data.getObject("doc_title"); if (doc_title == null) data.putObject("doc_title", ((XMLInput)input).getValue()); else doc_title = doc_title + ((XMLInput)input).getValue(); // ((Generator)data).doc_title_ = doc_title; return(null); } } --- NEW FILE: WriteDocContentTransition.java --- /*********************************************************************** * @(#)$RCSfile: WriteDocContentTransition.java,v $ $Revision: 1.1 $ $Date: 2002/02/07 09:42:18 $ * * 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.transitions.simple; import edu.iicm.xpg.statemachine.Transition; import edu.iicm.xpg.statemachine.State; import edu.iicm.xpg.statemachine.StateMachine; import edu.iicm.xpg.statemachine.Input; import edu.iicm.xpg.statemachine.XMLInput; import edu.iicm.xpg.statemachine.DataObject; import java.util.Vector; import java.util.Enumeration; //---------------------------------------------------------------------- /** * @author Günther Brand * @version $Revision: 1.1 $ */ public class WriteDocContentTransition implements Transition { protected int field_counter_; protected static int coll_counter_; // don't use underlines in the labels, only at the end! protected final static String COLL_LABEL = "collection_"; protected final static String COURSE_LABEL = "course_"; protected final static String TITLE_NEW_LABEL = "newTitle_"; protected final static String TITLE_OLD_LABEL = "oldTitle_"; protected final static String TITLE_ANY_LABEL = "anyTitle_"; protected final static String TYPE_NEW_LABEL = "newType_"; protected final static String TYPE_OLD_LABEL = "oldType_"; protected final static String TYPE_ANY_LABEL = "anyType_"; protected final static String HOURS_NEW_LABEL = "newHours_"; protected final static String HOURS_OLD_LABEL = "oldHours_"; protected final static String HOURS_ANY_LABEL = "anyHours_"; protected final static String MARK_NEW_LABEL = "newMark_"; protected final static String MARK_OLD_LABEL = "oldMark_"; protected final static String MARK_ANY_LABEL = "anyMark_"; protected final static String REMARK_NEW_LABEL = "newRemark_"; protected final static String REMARK_OLD_LABEL = "oldRemark_"; protected final static String REMARK_ANY_LABEL = "anyRemark_"; protected final static String DATE_NEW_LABEL = "newDate_"; protected final static String DATE_OLD_LABEL = "oldDate_"; protected final static String DATE_ANY_LABEL = "anyDate_"; //---------------------------------------------------------------------- /** * @param input the input that triggered this transition * @param from_state the start state for this transition * @param to_state the destination state for this transition * @param machine the state machine that this transition belongs to * @param data user defined data * @return * @exception Exception whatever an implementation can throw */ public String transitionTriggered(Input input,State from_state,State to_state, StateMachine machine,DataObject data) throws Exception { StringBuffer html_form = data.getResult(); String content = (String)data.getObject("content"); if (content != null) html_form.append(content); else System.err.println("Error (printing to form): document has no content"); // writeCourseList(html_form,collection.getCourses()); return(null); } //---------------------------------------------------------------------- /** * @param html_form the form to write to * @param course_list the list of courses * @return */ /* protected synchronized void writeCourseList(StringBuffer html_form,Vector course_list) { if (course_list == null) { System.err.println("Error (printing to form): collection has no courses"); return; } html_form.append("<table border=\"1\" cellspacing=\"2\">\n"); field_counter_ = 0; Enumeration courses = course_list.elements(); while(courses.hasMoreElements()) { CourseEquivalence course = (CourseEquivalence)courses.nextElement(); writeCourse(html_form,course); } html_form.append("</table>\n"); } */ //---------------------------------------------------------------------- /** * @param html_form the form to write to * @param course the course to write * @return */ /* protected void writeCourse(StringBuffer html_form,CourseEquivalence course) { field_counter_++; int alternative_counter = 0; boolean groupwise = false; Vector entries = course.getAllNew(); // ------------------------------ "any" Course if (entries.isEmpty()) { html_form.append("<tr>\n"); html_form.append(" <td><input type=\"hidden\" name=\"" + COURSE_LABEL + coll_counter_ + "_" + field_counter_ + "_1" + "\">\n<input type=\"text\" size=\"20\" maxlength=\"60\" name=\"" + TITLE_ANY_LABEL + coll_counter_ + "_" + field_counter_ + "_1" + "\"></td>\n"); html_form.append("<td>Typ: <input type=\"text\" size=\"4\" maxlength=\"4\" name=\"" + TYPE_ANY_LABEL + coll_counter_ + "_" + field_counter_ + "_1" + "\"></td>\n"); html_form.append("<td>Std: <input type=\"text\" size=\"4\" maxlength=\"4\" name=\"" + HOURS_ANY_LABEL + coll_counter_ + "_" + field_counter_ + "_1" + "\"></td>\n"); html_form.append("<td>Dat: <input type=\"text\" size=\"10\" maxlength=\"10\" name=\"" + DATE_ANY_LABEL + coll_counter_ + "_" + field_counter_ + "_1" + "\"></td>\n"); html_form.append("<td>Note: <input type=\"text\" size=\"2\" maxlength=\"1\" name=\"" + MARK_ANY_LABEL + coll_counter_ + "_" + field_counter_ + "_1" + "\"></td>\n"); html_form.append("<td>Bem.: <input type=\"text\" size=\"13\" maxlength=\"200\" name=\"" + REMARK_ANY_LABEL + coll_counter_ + "_" + field_counter_ + "_1" + "\"></td>\n"); html_form.append("</tr>\n"); return; } // ------------------------------ new course Enumeration entry_enum = entries.elements(); if (entries.size() > 1) // multiple alternatives { groupwise = true; html_form.append("<tr><td colspan=\"6\" align=\"center\"><strong><i>" + "Folgende Veranstaltungen werden gruppenweise angerechnet</i></strong></td></tr>"); } while(entry_enum.hasMoreElements()) { CourseEntry entry = (CourseEntry)entry_enum.nextElement(); alternative_counter++; html_form.append("<tr>\n"); html_form.append(" <td><input type=\"hidden\" name=\"" + COURSE_LABEL + coll_counter_ + "_" + field_counter_ + "_" + alternative_counter + "\">\n<strong>"); html_form.append(entry.getTitle()); html_form.append("<input type=\"hidden\" name=\"" + TITLE_NEW_LABEL + coll_counter_ + "_" + field_counter_ + "_" + alternative_counter + "\" value=\"" + entry.getTitle() + "\">\n"); html_form.append("</strong></td><td>"); html_form.append("Typ: "); html_form.append(entry.getType()); html_form.append("<input type=\"hidden\" name=\"" + TYPE_NEW_LABEL + coll_counter_ + "_" + field_counter_ + "_" + alternative_counter + "\" value=\"" + entry.getType() + "\">\n"); html_form.append("</td><td>"); html_form.append("Std: "); html_form.append(entry.getHours()); html_form.append("<input type=\"hidden\" name=\"" + HOURS_NEW_LABEL + coll_counter_ + "_" + field_counter_ + "_" + alternative_counter + "\" value=\"" + entry.getHours() + "\">\n"); html_form.append("</td>"); html_form.append("<td>Dat: <input type=\"text\" size=\"10\" maxlength=\"10\" name=\"" + DATE_NEW_LABEL + coll_counter_ + "_" + field_counter_ + "_" + alternative_counter + "\"></td>\n"); html_form.append("<td>Note: <input type=\"text\" size=\"2\" maxlength=\"1\" name=\"" + MARK_NEW_LABEL + coll_counter_ + "_" + field_counter_ + "_" + alternative_counter + "\"></td>\n"); html_form.append("<td>Bem.: <input type=\"text\" size=\"13\" maxlength=\"200\" name=\"" + REMARK_NEW_LABEL + coll_counter_ + "_" + field_counter_ + "_" + alternative_counter + "\"></td>\n"); html_form.append("</tr>\n"); } // ------------------------------ old course alternative_counter = 0; entries = course.getAllOld(); if (entries.isEmpty()) return; entry_enum = entries.elements(); while(entry_enum.hasMoreElements()) { CourseEntry entry = (CourseEntry)entry_enum.nextElement(); alternative_counter++; html_form.append("<tr>\n"); html_form.append(" <td> <i>"); html_form.append(entry.getTitle()); html_form.append("<input type=\"hidden\" name=\"" + TITLE_OLD_LABEL + coll_counter_ + "_" + field_counter_ + "_" + alternative_counter + "\" value=\"" + entry.getTitle() + "\">\n"); html_form.append("</i></td><td>"); html_form.append("Typ: "); html_form.append(entry.getType()); html_form.append("<input type=\"hidden\" name=\"" + TYPE_OLD_LABEL + coll_counter_ + "_" + field_counter_ + "_" + alternative_counter + "\" value=\"" + entry.getType() + "\">\n"); html_form.append("</td><td>"); html_form.append("Std: "); html_form.append(entry.getHours()); html_form.append("<input type=\"hidden\" name=\"" + HOURS_OLD_LABEL + coll_counter_ + "_" + field_counter_ + "_" + alternative_counter + "\" value=\"" + entry.getHours() + "\">\n"); html_form.append("</td>"); html_form.append("<td>Dat: <input type=\"text\" size=\"10\" maxlength=\"10\" name=\"" + DATE_OLD_LABEL + coll_counter_ + "_" + field_counter_ + "_" + alternative_counter + "\"></td>\n"); html_form.append("<td>Note: <input type=\"text\" size=\"2\" maxlength=\"1\" name=\"" + MARK_OLD_LABEL + coll_counter_ + "_" + field_counter_ + "_" + alternative_counter + "\"></td>\n"); html_form.append("<td>Bem.: <input type=\"text\" size=\"13\" maxlength=\"200\" name=\"" + REMARK_OLD_LABEL + coll_counter_ + "_" + field_counter_ + "_" + alternative_counter + "\"></td>\n"); html_form.append("</tr>\n"); } if (groupwise) // multiple alternatives { html_form.append("<tr><td colspan=\"6\" align=\"center\"><strong><i>" + "Ende der Anrechnungsgruppe</i></strong></td></tr>"); } } */ } --- NEW FILE: WriteGeneralFooterTransition.java --- /*********************************************************************** * @(#)$RCSfile: WriteGeneralFooterTransition.java,v $ $Revision: 1.1 $ $Date: 2002/02/07 09:42:18 $ * * 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.transitions.simple; import edu.iicm.xpg.statemachine.Transition; import edu.iicm.xpg.statemachine.State; import edu.iicm.xpg.statemachine.StateMachine; import edu.iicm.xpg.statemachine.Input; import edu.iicm.xpg.statemachine.XMLInput; import edu.iicm.xpg.statemachine.DataObject; //---------------------------------------------------------------------- /** * @author Klaus Schmaranz * @author Günther Brand * @version $Revision: 1.1 $ */ public class WriteGeneralFooterTransition implements Transition { //---------------------------------------------------------------------- /** * @param input the input that triggered this transition * @param from_state the start state for this transition * @param to_state the destination state for this transition * @param machine the state machine that this transition belongs to * @param data user defined data * @return * @exception Exception whatever an implementation can throw */ public String transitionTriggered(Input input,State from_state,State to_state, StateMachine machine,DataObject data) throws Exception { StringBuffer html_form = data.getResult(); html_form.append("\n<p><hr></p><input type=\"submit\" value=\"abschicken\">\n</form>" + "\n</body>\n</html>"); // html_form.append("\n</body>\n</html>"); return(null); } } --- NEW FILE: WriteGeneralHeaderTransition.java --- /*********************************************************************** * @(#)$RCSfile: WriteGeneralHeaderTransition.java,v $ $Revision: 1.1 $ $Date: 2002/02/07 09:42:18 $ * * 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.transitions.simple; import edu.iicm.xpg.statemachine.Transition; import edu.iicm.xpg.statemachine.State; import edu.iicm.xpg.statemachine.StateMachine; import edu.iicm.xpg.statemachine.Input; import edu.iicm.xpg.statemachine.XMLInput; import edu.iicm.xpg.statemachine.DataObject; //---------------------------------------------------------------------- /** * @author Klaus Schmaranz * @version $Revision: 1.1 $ */ public class WriteGeneralHeaderTransition implements Transition { //---------------------------------------------------------------------- /** * @param input the input that triggered this transition * @param from_state the start state for this transition * @param to_state the destination state for this transition * @param machine the state machine that this transition belongs to * @param data user defined data * @return * @exception Exception whatever an implementation can throw */ public String transitionTriggered(Input input,State from_state,State to_state, StateMachine machine,DataObject data) throws Exception { StringBuffer html_form = data.getResult(); html_form.append("<html>\n<head>\n"); return(null); } } --- NEW FILE: WriteHeaderTransition.java --- /*********************************************************************** * @(#)$RCSfile: WriteHeaderTransition.java,v $ $Revision: 1.1 $ $Date: 2002/02/07 09:42:18 $ * * 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.transitions.simple; import edu.iicm.xpg.statemachine.Transition; import edu.iicm.xpg.statemachine.Input; import edu.iicm.xpg.statemachine.State; import edu.iicm.xpg.statemachine.StateMachine; import edu.iicm.xpg.statemachine.DataObject; //---------------------------------------------------------------------- /** * @author Klaus Schmaranz * @author Günther Brand * @version $Revision: 1.1 $ */ public class WriteHeaderTransition implements Transition { //---------------------------------------------------------------------- /** * @param input the input that triggered this transition * @param from_state the start state for this transition * @param to_state the destination state for this transition * @param machine the state machine that this transition belongs to * @param data user defined data * @return * @exception Exception whatever an implementation can throw */ public String transitionTriggered(Input input,State from_state,State to_state, StateMachine machine,DataObject data) throws Exception { StringBuffer html_form = data.getResult(); String doc_title = (String)data.getObject("doc_title"); String doc_author = (String)data.getObject("doc_author"); if (doc_title == null) System.err.println("Error (printing to form): document has no title"); html_form.append("<title>" + doc_title + "</title>\n"); if (doc_author != null) html_form.append("<meta name=\"author\" content=\"" + doc_author + "\">\n"); html_form.append("</head>\n<body>\n<h1>" + doc_title + "</h1>\n"); return(null); } } |