From: G?nther B. <br...@us...> - 2002-05-13 06:25:25
|
Update of /cvsroot/xpg-xml/edu/iicm/xpg/transitions/cvlatex In directory usw-pr-cvs1:/tmp/cvs-serv7586 Added Files: WriteListTransition.java WritePersonalTransition.java Log Message: transitions for CV example --- NEW FILE: WriteListTransition.java --- /*********************************************************************** * * 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.cvlatex; 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.XMLElement; import edu.iicm.xpg.statemachine.DataObject; import edu.iicm.xpg.statemachine.Const; import edu.iicm.xpg.util.Debug; import java.util.Vector; import java.util.Enumeration; //---------------------------------------------------------------------- /** * @author Guenther Brand * @version $Revision: 1.1 $ */ public class WriteListTransition 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 result = (StringBuffer)data.getObject(Const.RESULT_BUFFER); Vector list_items = (Vector)data.removeObject("list items"); String list_title = ((XMLElement)data.removeObject("title")).getValue(); result.append("\n\\section{" + list_title + "}\n" + "\n\\begin{CV}\n"); for (int idx=0; idx < list_items.size(); idx++) { String[] item = (String[])list_items.get(idx); String caption = item[0]; String value = item[1]; result.append("\\item "); if ( caption != null ) result.append("[" + caption + "] "); result.append(value + "\n"); } result.append("\\end{CV}\n"); return(null); } } --- NEW FILE: WritePersonalTransition.java --- /*********************************************************************** * * 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.cvlatex; 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.XMLElement; import edu.iicm.xpg.statemachine.DataObject; import edu.iicm.xpg.statemachine.Const; import edu.iicm.xpg.util.Debug; import java.util.Vector; import java.util.Enumeration; //---------------------------------------------------------------------- /** * @author Guenther Brand * @version $Revision: 1.1 $ */ public class WritePersonalTransition 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 result = (StringBuffer)data.getObject(Const.RESULT_BUFFER); String name = ((XMLElement)data.getObject("name")).getValue(); result.append("\n\\begin{center}\n" + "\\huge{\\textsc{Curriculum Vitae}}\n" + "\\vspace{\\baselineskip}\n" + "\n\\Large{\\textsc{" + name + "}}\n" + "\\end{center}\n" + "\\vspace[1.5\\baselineskip}\n"); result.append("\n\\section{Persönliche Daten}" + "\n\\begin{CV}" + "\n\\item[Name:] " + name); result.append("\n\\item[geboren am:] " + ((XMLElement)data.getObject("birthdate")).getValue() + " in " + ((XMLElement)data.getObject("birthplace")).getValue()); XMLElement marital = (XMLElement)data.getObject("marital"); if ( marital != null ) result.append("\n\\item[Familienstand:] " + marital.getAttributes().getValue("status")); result.append("\n\\item[Adresse:] " + ((XMLElement)data.getObject("address")).getValue()); XMLElement country = (XMLElement)data.getObject("country"); if ( country != null ) result.append(", " + country.getValue()); XMLElement phone = (XMLElement)data.getObject("phone"); if ( phone != null ) result.append("\n\\item[Telefon:] " + phone.getValue()); XMLElement mobile = (XMLElement)data.getObject("mobile"); if ( mobile != null ) result.append("\n\\item[Mobil:] " + mobile.getValue()); XMLElement email = (XMLElement)data.getObject("email"); if ( email != null ) result.append("\n\\item[E-mail:] " + email.getValue()); XMLElement homepage = (XMLElement)data.getObject("homepage"); if ( homepage != null ) result.append("\n\\item[Homepage:] " + homepage.getValue()); result.append("\n\\end{CV}\n"); return(null); } } |