KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > coach > idltree > XmlParser


1 /***************************************************************************/
2 /* COACH: Component Based Open Source Architecture for */
3 /* Distributed Telecom Applications */
4 /* See: http://www.objectweb.org/ */
5 /* */
6 /* Copyright (C) 2003 Lucent Technologies Nederland BV */
7 /* Bell Labs Advanced Technologies - EMEA */
8 /* */
9 /* Initial developer(s): Harold Batteram */
10 /* */
11 /* This library is free software; you can redistribute it and/or */
12 /* modify it under the terms of the GNU Lesser General Public */
13 /* License as published by the Free Software Foundation; either */
14 /* version 2.1 of the License, or (at your option) any later version. */
15 /* */
16 /* This library is distributed in the hope that it will be useful, */
17 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
18 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
19 /* Lesser General Public License for more details. */
20 /* */
21 /* You should have received a copy of the GNU Lesser General Public */
22 /* License along with this library; if not, write to the Free Software */
23 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
24 /***************************************************************************/
25 package org.coach.idltree;
26
27 import java.io.*;
28 import java.util.*;
29 import javax.swing.*;
30 import javax.swing.event.*;
31 import javax.swing.tree.*;
32 import java.awt.*;
33 import java.awt.event.*;
34
35 public class XmlParser {
36     public static void main(String JavaDoc argv[]) {
37
38         IdlNode root = null;
39         try {
40             String JavaDoc xml = "";
41             if (argv.length == 1) {
42                 File f = new File(argv[0]);
43                 BufferedReader r = new BufferedReader(new FileReader(f));
44                 StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
45                 String JavaDoc s = r.readLine();
46                 while (s != null) {
47                     sb.append(s);
48                     s = r.readLine();
49                 }
50                 xml = sb.toString();
51             }
52 /*
53             else {
54                 XmlWriter w = new XmlWriter();
55                 XmlTest.MyStructXmlHelper.write(w);
56                 xml = w.toString();
57                 System.out.println(xml);
58             }
59 */

60             root = XmlNode.getIdlNodeXml(xml);
61         } catch (Exception JavaDoc e) {
62             e.printStackTrace();
63         }
64
65         IdlEditor.display("XmlEditor", root);
66     }
67 }
68
Popular Tags