Mercurial > hg > RemoteEditor > REPSessionManager
view test/XMLTest.java @ 468:b800b33c6988
check quit2 and ackList
author | one |
---|---|
date | Mon, 11 Oct 2010 19:57:34 +0900 |
parents | 6f356d160e58 |
children |
line wrap: on
line source
package test; import java.io.IOException; import org.xml.sax.SAXException; import rep.Session; import rep.SessionList; import rep.handler.Editor; import rep.xml.SessionXMLDecoder; import rep.xml.SessionXMLEncoder; public class XMLTest { public static void main(String[] args){ Editor editor = new Editor(0,null,null); editor.setEID(1); editor.setHost("firefly.cr.ie.u-ryukyu.ac.jp"); //editor.setPort("56789"); editor.setName("Test.java"); Editor editor2 = new Editor(1,null,null); editor2.setEID(2); editor2.setHost("teto.cr.ie.u-ryukyu.ac.jp"); //editor2.setPort("45678"); Session session = new Session(1,editor); session.addEditor(editor); session.addEditor(editor2); SessionList sessionlist = new SessionList(); //sessionlist.setMaxHost("naha.ie.u-ryukyu.ac.jp"); sessionlist.put(session.getSID(),session); /*** SessionList から XML へ ***/ //SessionXMLEncoder encoder = new SessionXMLEncoder(sessionlist.getList()); SessionXMLEncoder encoder = new SessionXMLEncoder(); System.out.println(encoder.sessionListToXML(sessionlist)); /*** XML から SessionList へ ***/ String t1 = encoder.sessionListToXML(sessionlist); System.out.println(t1); SessionList sessionlist2; SessionXMLDecoder decoder = new SessionXMLDecoder(); try { sessionlist2 = decoder.decode(t1); } catch (SAXException e) { return; } catch (IOException e) { return; } /*** SessionList から XML へ ***/ //SessionXMLEncoder encoder2 = new SessionXMLEncoder(sessionlist2.getList()); System.out.println(encoder.sessionListToXML(sessionlist2)); /*** TestSAX ***/ String[] string = {encoder.sessionListToXML(sessionlist2),}; TestSax.main(string); } }