alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 * 
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 * 
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun
 * Microsystems, Inc. All Rights Reserved.
 */
package org.netbeans.lib.jmi.xmi;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collection;
import javax.jmi.reflect.RefPackage;
import javax.jmi.xmi.MalformedXMIException;
import javax.jmi.xmi.XmiReader;
import javax.xml.parsers.ParserConfigurationException;
import org.netbeans.lib.jmi.util.Logger;
import org.xml.sax.SAXException;

public class XMISaxReaderImpl implements XmiReader {

    /** Creates new XMISaxReaderImpl */
    public XMISaxReaderImpl () {
    }

    public Collection read (InputStream stream, String uri, RefPackage extent) throws IOException, MalformedXMIException {
        // [PENDING] correct this code to throw exceptions correctly
        try {
            // [PENDING] correct this call to use both stream and URI
            return new XmiSAXReader ().read (stream, uri, new RefPackage[] {extent}, null);
        } catch (ParserConfigurationException e) {
            MalformedXMIException ne = new MalformedXMIException(e.getMessage());
            Logger.getDefault().annotate(ne, e);
            throw ne;
        } catch (SAXException e) {
            MalformedXMIException ne = new MalformedXMIException(e.getMessage());
            Logger.getDefault().annotate(ne, e);
            throw ne;
        }
    }
    
    public Collection read (String uri, RefPackage extent) 
    throws IOException, MalformedXMIException {
        return read (new URL(uri), new RefPackage[] {extent}, null);
    }
    
    private Collection read (URL url, RefPackage[] extents, String encoding)
        throws IOException, MalformedXMIException {
        // [PENDING] correct this code to throw exceptions correctly
        try {
            return new XmiSAXReader ().read (url, extents, encoding);
        } catch (ParserConfigurationException e) {
            MalformedXMIException ne = new MalformedXMIException(e.toString());
            Logger.getDefault().annotate(ne, e);
            throw ne;
        } catch (SAXException e) {
            MalformedXMIException ne = new MalformedXMIException(e.toString());
            Logger.getDefault().annotate(ne, e);
            throw ne;
        }
    }
    
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.