KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Jt > xml > JtXMLHelper


1
2
3 package Jt.xml;
4
5 import Jt.*;
6 import java.util.*;
7 import java.lang.reflect.*;
8 import java.beans.*;
9 import java.io.*;
10 import org.xml.sax.*;
11 import org.xml.sax.helpers.*;
12
13 /**
14   * Convert Jt objects from/to the XML format
15   */

16
17 public class JtXMLHelper extends JtObject implements ContentHandler {
18
19   private XMLReader reader = null;
20   protected static final String JavaDoc DEFAULT_PARSER_NAME = "org.apache.xerces.parsers.SAXParser";
21   protected static final String JavaDoc XML_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
22   private StringBuffer JavaDoc buffer;
23   HashMap map;
24   private Object JavaDoc object = null;
25   private String JavaDoc parserName = DEFAULT_PARSER_NAME;
26   private int level = 0;
27   Vector mapTable = new Vector ();
28   Vector objTable = new Vector ();
29
30   public JtXMLHelper() {
31   }
32
33  /**
34   * Specifies the parser.
35   * @param parserName parse
36   */

37
38
39   void setParserName (String JavaDoc parserName) {
40     this.parserName = parserName;
41   
42   }
43
44
45  /**
46    * Returns the parser.
47    */

48
49   String JavaDoc getParserName () {
50     return (parserName);
51   }
52
53
54   /**
55     * Start element (SAX API).
56     */

57   public void startElement(String JavaDoc uri, String JavaDoc local, String JavaDoc raw,
58                              Attributes attrs) throws SAXException {
59
60     if ("".equals (uri)) {
61       // handleTrace ("Start element: " + raw);
62

63       if ("Object".equals (raw)) {
64         level++;
65
66         map = new HashMap ();
67         mapTable.addElement (map);
68         return;
69       }
70       
71       //elemName = raw;
72
//elemValue = null;
73
buffer = null;
74
75     } else {
76       // handleTrace ("Start element: {" + uri + "}" + local);
77
}
78   }
79
80
81   Object JavaDoc setResources (Object JavaDoc obj) {
82    Object JavaDoc args[];
83    PropertyDescriptor[] prop;
84    int i;
85    Class JavaDoc p;
86    Method m;
87    BeanInfo info = null;
88    String JavaDoc tval;
89
90
91      map = getAttributeMap (level);
92      if (obj == null || map == null)
93        return (null);
94
95      try {
96        info = Introspector.getBeanInfo(
97               obj.getClass (), obj.getClass ().getSuperclass());
98      } catch(Exception JavaDoc e) {
99         handleException (e);
100         return (null); //check
101
}
102
103      prop = info.getPropertyDescriptors();
104
105
106      for(i = 0; i < prop.length; i++) {
107
108         tval = (String JavaDoc) map.get (prop[i].getName());
109
110         if (tval != null) // check
111
setValue (obj, prop[i].getName(), tval);
112
113      }
114
115       return (null); // check
116
}
117
118
119   private Hashtable getAttributes (Object JavaDoc obj) {
120
121    Object JavaDoc args[];
122    PropertyDescriptor[] prop;
123    int i;
124    Class JavaDoc p;
125    Method m;
126    BeanInfo info = null;
127    Object JavaDoc value;
128    Hashtable attr;
129
130
131      if (obj == null)
132        return (null);
133
134      attr = new Hashtable ();
135
136
137      try {
138        info = Introspector.getBeanInfo(
139               obj.getClass (), java.lang.Object JavaDoc.class);
140      } catch(Exception JavaDoc e) {
141         handleException (e);
142         return (null);
143      }
144
145      prop = info.getPropertyDescriptors();
146      for(i = 0; i < prop.length; i++) {
147
148        p = prop[i].getPropertyType();
149        
150        try {
151          m = prop[i].getReadMethod ();
152          if (m == null) {
153            handleError
154          ("getAttributes: getReadMethod returned null");
155              return (null);
156          }
157
158          value = m.invoke (obj, null);
159          if (value == null) {
160            continue;
161          }
162
163          if (value instanceof String JavaDoc) {
164            attr.put (prop[i].getName(), value);
165            //System.out.println ("=" + value);
166
continue;
167          }
168
169          if (value instanceof Integer JavaDoc ||
170              value instanceof Long JavaDoc ||
171              value instanceof Float JavaDoc ||
172              value instanceof Byte JavaDoc ||
173              value instanceof Boolean JavaDoc ||
174              value instanceof Short JavaDoc ||
175              value instanceof Double JavaDoc) {
176            attr.put (prop[i].getName(), value.toString () );
177
178            continue;
179          } else {
180             handleWarning
181              ("JtXMLHelper.getAttributes: unable to convert attribute type to String:" + prop[i].getName());
182                 
183          }
184
185         } catch (Exception JavaDoc e) {
186          handleException(e);
187          return (null);
188         }
189       }
190
191       return (attr);
192    }
193
194
195   private Object JavaDoc createInstance () {
196   String JavaDoc classname;
197   Class JavaDoc jtclass;
198   Object JavaDoc obj;
199   String JavaDoc value;
200   String JavaDoc stmp;
201   JtRemoteException jex;
202
203     if (map == null)
204        return (null); // check
205

206
207     classname = (String JavaDoc) map.get ("classname");
208
209     if (classname == null)
210       return (null); // check
211

212     try {
213       jtclass = Class.forName ((String JavaDoc) classname);
214     } catch (Exception JavaDoc e) {
215       handleException (e);
216       return (null);
217     }
218
219
220 /*
221     try {
222       obj = jtclass.newInstance ();
223     } catch (Exception e) {
224       handleException (e);
225       return (null);
226     }
227 */

228
229
230     if (classname.equals ("Jt.JtRemoteException")) {
231       value = (String JavaDoc) map.get ("value");
232       stmp = (String JavaDoc) map.get ("trace");
233
234       //System.out.println ("stmp:" + stmp);
235

236       if (value == null) {
237         handleError ("createInstance: invalid value:" +
238          value);
239
240         return (null);
241       }
242       jex = new JtRemoteException (value);
243       jex.setTrace (stmp);
244       return (jex);
245     }
246
247     if (classname.startsWith ("Jt.")) {
248       try {
249         obj = jtclass.newInstance ();
250         setResources (obj);
251         return (obj); // check
252
} catch (Exception JavaDoc e) {
253         handleException (e);
254         return (null);
255       }
256     } else if (classname.startsWith ("java.lang")) {
257
258       value = (String JavaDoc) map.get ("value");
259     } else {
260       handleError ("createInstance: unable to handle class type:" +
261          classname);
262       return (null);
263     }
264
265
266     if (value == null) {
267       handleError ("createInstance: invalid value:" +
268          value);
269
270       return (null);
271     }
272
273     if (classname.equals ("java.lang.Byte")) {
274
275       try {
276         obj = new Byte JavaDoc (value);
277         return (obj);
278       } catch (Exception JavaDoc e) {
279         handleException (e);
280         return (null);
281       }
282
283     }
284
285
286     if (classname.equals ("java.lang.Short")) {
287
288       try {
289         obj = new Short JavaDoc (value);
290         return (obj);
291       } catch (Exception JavaDoc e) {
292         handleException (e);
293         return (null);
294       }
295
296     }
297
298
299     if (classname.equals ("java.lang.Float")) {
300
301       try {
302         obj = new Float JavaDoc (value);
303         return (obj);
304       } catch (Exception JavaDoc e) {
305         handleException (e);
306         return (null);
307       }
308
309     }
310
311     if (classname.equals ("java.lang.Double")) {
312
313       try {
314         obj = new Double JavaDoc (value);
315         return (obj);
316       } catch (Exception JavaDoc e) {
317         handleException (e);
318         return (null);
319       }
320
321     }
322
323
324     if (classname.equals ("java.lang.String")) {
325
326       try {
327         obj = new String JavaDoc (value);
328         return (obj);
329       } catch (Exception JavaDoc e) {
330         handleException (e);
331         return (null);
332       }
333
334     }
335
336     if (classname.equals ("java.lang.Integer")) {
337
338       try {
339         obj = new Integer JavaDoc (value);
340         return (obj);
341       } catch (Exception JavaDoc e) {
342         handleException (e);
343         return (null);
344       }
345
346     }
347
348     if (classname.equals ("java.lang.Long")) {
349
350       try {
351         obj = new Long JavaDoc (value);
352         return (obj);
353       } catch (Exception JavaDoc e) {
354         handleException (e);
355         return (null);
356       }
357
358     }
359
360     if (classname.equals ("java.lang.Boolean")) {
361
362       try {
363         obj = new Boolean JavaDoc (value);
364         return (obj);
365       } catch (Exception JavaDoc e) {
366         handleException (e);
367         return (null);
368       }
369
370     }
371
372     handleError ("createInstance: unable to handle class type:" +
373          classname);
374     return (null); // check
375
}
376
377   HashMap getAttributeMap (int level) {
378    if (level < 1)
379      return (null);
380
381    if (level > mapTable.size ())
382      return (null);
383
384
385    return ((HashMap) mapTable.elementAt (level - 1));
386
387   }
388  
389   /**
390     * End element (SAX API).
391     */

392
393   public void endElement(String JavaDoc uri,
394                         String JavaDoc name,
395                         String JavaDoc qName)
396                 throws SAXException {
397     JtMessage msg;
398     int i;
399
400     map = getAttributeMap (level);
401     if (qName == null || map == null)
402       return; //check
403

404     if ("".equals (uri)) {
405       // handleTrace ("End element: " + qName);
406

407       if ("Object".equals (qName)) { //check
408
//sendReply (msg);
409

410         if (map == null)
411           return; // check
412
object = createInstance ();
413         map = null;
414         buffer = null;
415         level--;
416
417         if (level > 0)
418           objTable.addElement (object);
419         else {
420
421           if (!(object instanceof JtCollection))
422             return;
423           for (i = 0; i < objTable.size (); i++) {
424             msg = new JtMessage ("JtADD");
425             msg.setMsgContent (objTable.elementAt (i));
426             ((JtObject) object).processMessage (msg);
427             //sendMessage (object, msg);
428
}
429
430         }
431         return;
432       } else {
433
434 // if (map != null && buffer != null &&
435
// qName != null) {
436

437
438          // handleTrace ("JtXMLHelper.endElement:"+ qName + ":" + buffer);
439

440          if (buffer == null)
441            return; // check
442

443          map.put (qName, buffer.toString ());
444
445          buffer = null;
446       }
447
448     } else {
449       // handleTrace ("End element: {" + uri + "}" + name);
450
}
451   }
452
453
454   /**
455     * Start document (SAX API).
456     */

457   public void startDocument() throws SAXException {
458
459   }
460
461  /**
462    * End document (SAX API).
463    */

464
465   public void endDocument()
466                  throws SAXException {
467
468   }
469
470  /**
471    * Characters (SAX API).
472    */

473
474   public void characters(char[] ch,
475                        int start,
476                        int length)
477                 throws SAXException {
478     String JavaDoc tmp;
479
480     //handleTrace ("Characters: \"");
481
if (buffer == null)
482       buffer = new StringBuffer JavaDoc ();
483
484     for (int i = start; i < start + length; i++) {
485       buffer.append (ch[i]);
486
487 /*
488       switch (ch[i]) {
489         case '\\':
490           handleTrace("\\\\");
491           break;
492     case '"':
493       handleTrace("\\\"");
494       break;
495     case '\n':
496       //handleTrace("\\n");
497       break;
498     case '\r':
499           handleTrace ("\\r");
500           break;
501         case '\t':
502           handleTrace ("\\t");
503           break;
504         default:
505           buffer.append (ch[i]);
506           break;
507       }
508 */

509     }
510
511     //handleTrace("\"\n");
512
//elemValue = buffer.toString ();
513
tmp = buffer.toString().trim ();
514
515     if (!tmp.equals ("")) {
516       //handleTrace("JtXMLMsgReader.characters:" +
517
// buffer);
518
}
519
520   }
521
522  /**
523    * endPrefixMapping - SAX API.
524    */

525   public void endPrefixMapping(String JavaDoc prefix)
526                       throws SAXException {
527
528   }
529
530  /**
531    * ignorableWhitespace - SAX API.
532    */

533   public void ignorableWhitespace(char[] ch,
534                                 int start,
535                                 int length)
536                          throws SAXException {
537
538   }
539
540  /**
541    * processingInstruction - SAX API.
542    */

543   public void processingInstruction(String JavaDoc target,
544                                     String JavaDoc data)
545                            throws SAXException {
546
547   }
548
549  /**
550    * setDocumentLocator - SAX API.
551    */

552
553   public void setDocumentLocator(Locator locator) {
554
555   }
556
557  /**
558    * skippedEntity - SAX API.
559    */

560
561   public void skippedEntity(java.lang.String JavaDoc name)
562                    throws SAXException {
563
564   }
565
566
567  /**
568    * startPrefixMapping - SAX API.
569    */

570
571   public void startPrefixMapping(String JavaDoc prefix,
572                                  String JavaDoc uri)
573                         throws SAXException
574   {
575
576   }
577
578   // realize
579
void realize () {
580
581      if (reader != null)
582        return;
583
584      try{
585        reader = XMLReaderFactory.createXMLReader (parserName);
586
587        reader.setContentHandler (this);
588        //reader.setErrorHandler (this);
589
} catch (Exception JavaDoc ex) {
590
591        handleException (ex);
592      }
593
594   }
595
596   private Object JavaDoc convertXMLToObject (String JavaDoc string) {
597
598     ByteArrayInputStream bstream;
599
600     object = null; // check
601

602     if (string == null)
603       return (null);
604
605     if (reader == null)
606       realize ();
607
608
609     try {
610
611       bstream = new ByteArrayInputStream (string.getBytes());
612       reader.parse (new InputSource ((InputStream) bstream));
613
614     } catch (Exception JavaDoc ex) {
615       handleException (ex);
616     }
617     return object;
618   }
619
620   private String JavaDoc convertJtObjectToXML (Object JavaDoc obj) {
621
622     StringBuffer JavaDoc buf = new StringBuffer JavaDoc ();
623
624     Hashtable tbl;
625     //Iterator it;
626
String JavaDoc key;
627     Enumeration keys;
628
629     if (obj == null)
630       return (null);
631
632     tbl = getAttributes (obj);
633
634 // if (tbl == null)
635
// return (null);
636

637     //it = tbl.keys().iterator ();
638

639
640 // buf.append ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
641
buf.append ("<Object>\n");
642     buf.append ("<classname>" + obj.getClass().getName() + "</classname>\n");
643
644  
645     if (tbl != null) {
646     keys = tbl.keys ();
647     while (keys.hasMoreElements()) {
648
649       key = (String JavaDoc) keys.nextElement ();
650
651       buf.append ("<" + key + ">");
652       buf.append ((String JavaDoc) tbl.get (key));
653       buf.append ("</" + key + ">\n");
654
655
656     }
657     }
658     buf.append ("</Object>\n");
659
660     //handleTrace ("convertJtObjectToXML (XML):" + buf);
661
return (buf.toString ());
662
663   }
664
665   private String JavaDoc convertJtCollectionToXML (Object JavaDoc obj) {
666
667     StringBuffer JavaDoc buf = new StringBuffer JavaDoc ();
668
669     Hashtable tbl;
670     //Iterator it;
671
String JavaDoc key;
672     JtIterator jit;
673     Object JavaDoc tmp;
674     String JavaDoc tmp1;
675
676     if (obj == null)
677       return (null);
678
679 // buf.append ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
680
buf.append ("<Object>\n");
681     buf.append ("<classname>" + obj.getClass().getName() + "</classname>\n");
682
683     jit = (JtIterator) getValue (obj, "iterator");
684
685     if (jit == null)
686       return (null); // check
687

688     for (;;) {
689       //tmp = sendMessage (jit, new JtMessage ("JtNEXT"));
690
tmp = jit.processMessage (new JtMessage ("JtNEXT"));
691       if (tmp == null)
692         break;
693       tmp1 = convertToXML (tmp);
694
695       if (tmp1 == null)
696         return (null); // check
697

698       buf.append (tmp1);
699     }
700     buf.append ("</Object>\n");
701
702     return (buf.toString ());
703
704   }
705
706
707   private String JavaDoc stackTrace (Exception JavaDoc ex ) {
708     ByteArrayOutputStream bstream;
709
710
711     if (ex == null)
712       return (null);
713
714      bstream = new ByteArrayOutputStream ();
715
716
717      //handleError ("hello");
718

719
720      //ex = (Exception) getValue (this, "objException");
721

722      ex.printStackTrace (new PrintWriter (bstream, true));
723
724      //ex.printStackTrace ();
725

726      return (bstream.toString ());
727     
728
729   }
730
731   private String JavaDoc convertToXML (Object JavaDoc obj) {
732
733     buffer = new StringBuffer JavaDoc ();
734
735     if (obj == null) {
736       buffer.append ("<Object>\n");
737       buffer.append ("</Object>\n");
738       return (buffer.toString ());
739
740     }
741
742     // handleTrace ("convertToXML ..." + obj + ":" + obj.getClass().getName());
743

744
745     if (obj instanceof Byte JavaDoc ||
746         obj instanceof Short JavaDoc ||
747         obj instanceof Integer JavaDoc ||
748         obj instanceof Long JavaDoc ||
749         obj instanceof Boolean JavaDoc ||
750         obj instanceof Float JavaDoc ||
751         obj instanceof Double JavaDoc ||
752         obj instanceof String JavaDoc) {
753 // buffer.append ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
754
buffer.append ("<Object>\n");
755       buffer.append ("<classname>" + obj.getClass().getName() + "</classname>\n");
756       buffer.append ("<value>" + obj + "</value>\n");
757       buffer.append ("</Object>\n");
758       return (buffer.toString ());
759
760     } else if (obj instanceof JtCollection) {
761
762       return (convertJtCollectionToXML (obj));
763
764     } else if (obj instanceof JtObject) {
765
766       return (convertJtObjectToXML (obj));
767     } else if (obj instanceof Exception JavaDoc) {
768       buffer.append ("<Object>\n");
769       //buffer.append ("<classname>" + obj.getClass().getName() + "</classname>\n");
770
buffer.append ("<classname>" + "Jt.JtRemoteException" + "</classname>\n");
771
772       buffer.append ("<value>" + ((Exception JavaDoc) obj).getMessage () + "</value>\n");
773       buffer.append ("<trace>" + stackTrace ((Exception JavaDoc) obj) + "</trace>\n");
774       buffer.append ("</Object>\n");
775       return (buffer.toString ());
776     }
777     
778     handleError ("convertToXML:unable to convert object class" + obj.getClass().getName());
779     return (null);
780
781   }
782
783   private void initialize () {
784     buffer = null;
785     map = null;
786     object = null;
787     level = 0;
788     mapTable = new Vector ();
789     objTable = new Vector ();
790   }
791
792   /**
793    * Process object messages.
794    * <ul>
795    * <li> JtCONVERT_OBJECT_TO_XML - Converts object to XML format
796    * <li> JtCONVERT_XML_TO_OBJECT - Converts XML to object
797    * <li> JtREMOVE - Removes this object
798    * </ul>
799    * @param event Jt Message
800    */

801
802   public Object JavaDoc processMessage (Object JavaDoc event) {
803
804    String JavaDoc msgid = null;
805    JtMessage e = (JtMessage) event;
806    Object JavaDoc content;
807
808      if (e == null)
809     return null;
810
811      msgid = (String JavaDoc) e.getMsgId ();
812
813      if (msgid == null)
814     return null;
815
816      content = e.getMsgContent();
817
818      //
819

820      if (msgid.equals ("JtCONVERT_OBJECT_TO_XML")) {
821
822              
823         return (XML_HEADER + convertToXML (content)); // check
824
}
825
826
827      if (msgid.equals ("JtCONVERT_XML_TO_OBJECT")) {
828
829         initialize ();
830         return (convertXMLToObject ((String JavaDoc) content));
831      }
832
833      if (msgid.equals ("JtREMOVE")) {
834              
835         return (null);
836      }
837
838
839           
840      handleError ("JtXMLHelper.processMessage: invalid message id:" + msgid);
841      return (null);
842
843   }
844
845
846  /**
847    * Unit tests all the messages processed by JtXMLHelper
848    */

849
850   public static void main(String JavaDoc[] args) {
851
852     JtObject main = new JtObject ();
853     JtMessage msg1, msg2;
854     Integer JavaDoc count;
855     String JavaDoc tmp;
856     Integer JavaDoc i;
857     JtXMLHelper helper;
858     JtCommand command;
859     JtList col;
860
861
862     //main.setObjTrace (1);
863
//main.setLogFile ("log.txt");
864

865     msg1 = new JtMessage ();
866     msg2 = new JtMessage ();
867
868
869     msg1.setMsgId ("JtCONVERT_OBJECT_TO_XML");
870
871     msg1.setMsgContent (new Integer JavaDoc (2));
872
873     System.out.println ("JtCONVERT_OBJECT_TO_XML: converting Integer (2) to XML ..");
874
875     helper = (JtXMLHelper) main.createObject ("Jt.xml.JtXMLHelper", "helper");
876
877
878     tmp = (String JavaDoc) main.sendMessage (helper, msg1);
879     System.out.println (tmp);
880
881
882     msg2.setMsgId ("JtCONVERT_XML_TO_OBJECT");
883     System.out.print ("JtCONVERT_XML_TO_OBJECT: converting XML to object (Integer) .. ");
884
885     msg2.setMsgContent (tmp);
886     i = (Integer JavaDoc) main.sendMessage (helper, msg2);
887
888     System.out.println (i);
889
890     if (i != null && i.intValue() == 2) {
891       System.out.println ("JtCONVERT_OBJECT_TO_XML (INTEGER): PASS");
892       System.out.println ("JtCONVERT_XML_TO_OBJECT (INTEGER): PASS");
893     } else {
894       System.out.println ("JtCONVERT_OBJECT_TO_XML (INTEGER): FAIL");
895       System.out.println ("JtCONVERT_XML_TO_OBJECT (INTEGER): FAIL");
896
897     }
898
899     msg1.setMsgId ("JtCONVERT_OBJECT_TO_XML");
900
901     msg1.setMsgContent ("My string");
902
903     System.out.println ("JtCONVERT_OBJECT_TO_XML: converting String to XML ..");
904     tmp = (String JavaDoc) main.sendMessage (helper, msg1);
905     System.out.println (tmp);
906
907
908     msg2.setMsgId ("JtCONVERT_XML_TO_OBJECT");
909     msg2.setMsgContent (tmp);
910     tmp = (String JavaDoc) main.sendMessage (helper, msg2);
911
912     System.out.print ("JtCONVERT_XML_TO_OBJECT: converting XML to object (String) .. ");
913
914     System.out.println (tmp);
915
916
917     if (tmp != null && tmp.equals("My string")) {
918       System.out.println ("JtCONVERT_OBJECT_TO_XML (String): PASS");
919       System.out.println ("JtCONVERT_XML_TO_OBJECT (String): PASS");
920     } else {
921       System.out.println ("JtCONVERT_OBJECT_TO_XML (String): FAIL");
922       System.out.println ("JtCONVERT_XML_TO_OBJECT (String): FAIL");
923
924     }
925
926
927     command = (JtCommand) main.createObject ("Jt.JtCommand", "cmd");
928     main.setValue ("cmd", "command", "notepad");
929
930     msg1.setMsgId ("JtCONVERT_OBJECT_TO_XML");
931
932     msg1.setMsgContent (command);
933
934     tmp = (String JavaDoc) main.sendMessage (helper, msg1);
935     System.out.println ("Output =" + tmp);
936
937     msg1.setMsgId ("JtCONVERT_XML_TO_OBJECT");
938
939     msg1.setMsgContent (tmp);
940
941     command = (JtCommand) main.sendMessage (helper, msg1);
942
943     msg1.setMsgId ("JtEXECUTE");
944     main.sendMessage (command, msg1);
945
946
947     col = (JtList) main.createObject ("Jt.JtList", "col");
948
949     msg1 = new JtMessage ("JtADD");
950     msg1.setMsgContent (new Integer JavaDoc (2));
951
952
953     main.sendMessage (col, msg1);
954
955     msg1.setMsgContent ("String");
956
957     main.sendMessage (col, msg1);
958
959     msg1.setMsgContent (new JtException ("JtException"));
960
961     main.sendMessage (col, msg1);
962
963     msg2.setMsgId ("JtCONVERT_OBJECT_TO_XML");
964     msg2.setMsgContent (col);
965     tmp = (String JavaDoc) main.sendMessage (helper, msg2);
966
967     System.out.println ("XtCollection=" + tmp);
968
969     msg1.setMsgId ("JtCONVERT_XML_TO_OBJECT");
970
971     msg1.setMsgContent (tmp);
972
973     col = (JtList) main.sendMessage (helper, msg1);
974
975
976     msg1 = new JtMessage ("JtADD");
977     msg1.setMsgContent (new JtException ("JtException"));
978
979     //main.sendMessage (col, msg1);
980

981     msg2.setMsgId ("JtCONVERT_OBJECT_TO_XML");
982     msg2.setMsgContent (col);
983     tmp = (String JavaDoc) main.sendMessage (helper, msg2);
984
985     System.out.println ("XtCollection=" + tmp);
986
987     main.removeObject (helper);
988
989   }
990
991 }
992
993
994
Popular Tags