KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > modfact > metamodel_xml > test > Client


1 /*
2  * Created on 7 oct. 2003
3  *
4  * To change the template for this generated file go to
5  * Window - Preferences - Java - Code Generation - Code and Comments
6  */

7 package org.objectweb.modfact.metamodel_xml.test;
8
9 import java.io.FileInputStream JavaDoc;
10 import java.io.FileWriter JavaDoc;
11 import java.util.Collection JavaDoc;
12 import java.util.Iterator JavaDoc;
13
14 import javax.jmi.reflect.RefClass;
15 import javax.jmi.reflect.RefObject;
16 import javax.jmi.reflect.RefPackage;
17
18 import org.objectweb.modfact.metamodel_xml.io.Export;
19 import org.objectweb.modfact.metamodel_xml.io.Import;
20
21 /**
22  * @author Xavier
23  *
24  * To change the template for this generated type comment go to
25  * Window - Preferences - Java - Code Generation - Code and Comments
26  */

27 public class Client {
28     public static void main(String JavaDoc[] args) {
29         try {
30             Import imp = new Import();
31             RefPackage model = imp.parse(new FileInputStream JavaDoc(args[0]));
32             System.out.println("ok for parsing");
33
34             RefClass documentFact = model.refClass("Document");
35             Collection JavaDoc documents = documentFact.refAllOfClass();
36             //should be only one
37
Iterator JavaDoc documentsIt = documents.iterator();
38             Export exp = new Export();
39             exp.setOutput(new FileWriter JavaDoc(args[1]));
40             exp.write((RefObject) documentsIt.next());
41             System.out.println("ok for writing");
42         } catch (Exception JavaDoc ex) {
43             ex.printStackTrace();
44         }
45     }
46
47 }
48
Popular Tags