KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > modfact > jmi > xmi > XmiReaderImpl


1 package org.objectweb.modfact.jmi.xmi;
2
3 import javax.jmi.reflect.*;
4 import java.util.*;
5 import java.io.*;
6 import java.net.URL JavaDoc;
7
8 import javax.jmi.xmi.*;
9
10 public class XmiReaderImpl implements javax.jmi.xmi.XmiReader {
11     
12     
13     public boolean ignoreError = true;
14     public boolean verbose = false;
15     
16     public Collection read(String JavaDoc url, RefPackage p)
17                 throws IOException, javax.jmi.xmi.MalformedXMIException {
18
19
20         XmiParser parser;
21         try {
22             InputStream in = new URL JavaDoc(url).openStream();
23             parser = new XmiParser(this, p, in);
24             parser.run();
25             in.close();
26             return parser.getOuterMostObjects();
27                         
28         } catch(RuntimeException JavaDoc e) {
29             MalformedXMIException xmiE = new DetailedXmiException(e, "url='" +url +"' package=" +p);
30             throw xmiE;
31         }
32     }
33
34     public Collection read(InputStream in, String JavaDoc url, RefPackage p)
35                 throws IOException, javax.jmi.xmi.MalformedXMIException {
36        if(in==null) {
37          return read(url,p);
38        }
39        XmiParser parser;
40        try {
41             parser = new XmiParser(this, p, in);
42             parser.run();
43        } catch(Exception JavaDoc e) {
44          MalformedXMIException xmiE = new DetailedXmiException(e, " package=" +p);
45          throw xmiE;
46        }
47        return parser.getOuterMostObjects();
48     }
49     
50 }
51
Popular Tags