public Document readDocument(InputStream is, 
                                 ProvFormat format,
                                 ProvFactory pFactory,
                                 String baseuri) {
        try {

            switch (format) {
            case DOT:
            case JPEG:
            case PNG:
            case SVG:
                throw new UnsupportedOperationException(); // we don't load PROV
                // from these
                // formats
            case JSON: {
                return new org.openprovenance.prov.json.Converter(pFactory)
                        .readDocument(is);
            }
            case PROVN: {
                Utility u = new Utility();
                CommonTree tree = u.convertASNToTree(is);
                Object o = u.convertTreeToJavaBean(tree, pFactory);
                Document doc = (Document) o;
                // Namespace ns=Namespace.gatherNamespaces(doc);
                // doc.setNamespace(ns);
                return doc;
            }
            case RDFXML: {
                org.openprovenance.prov.rdf.Utility rdfU = new org.openprovenance.prov.rdf.Utility(
                        pFactory, onto);
                return rdfU.parseRDF(is, RDFFormat.RDFXML, baseuri);
            }
            case TRIG: {
                org.openprovenance.prov.rdf.Utility rdfU = new org.openprovenance.prov.rdf.Utility(
                        pFactory, onto);
                return rdfU.parseRDF(is, RDFFormat.TRIG,baseuri);
            }
            case TURTLE: {
                org.openprovenance.prov.rdf.Utility rdfU = new org.openprovenance.prov.rdf.Utility(
                        pFactory, onto);
                return rdfU.parseRDF(is, RDFFormat.TURTLE,baseuri);
            }
            case XML: {
                ProvDeserialiser deserial = ProvDeserialiser
                        .getThreadProvDeserialiser();
                Document doc = deserial.deserialiseDocument(is);
                return doc;
            }
            default: {
                System.out.println("Unknown format " + format);
                throw new UnsupportedOperationException();
            }
            }
        } catch (IOException e) {
            throw new InteropException(e);
        } catch (JAXBException e) {
            throw new InteropException(e);
        } catch (RecognitionException e) {
            throw new InteropException(e);
        } catch (RDFParseException e) {
            throw new InteropException(e);
        } catch (RDFHandlerException e) {
            throw new InteropException(e);
        }

    }
public Document readDocument ( InputStream is , ProvFormat format , ProvFactory pFactory , String baseuri ) { try { switch ( format ) { case DOT : case JPEG : case PNG : case SVG : throw new UnsupportedOperationException ( ) ; case JSON : { return new org . openprovenance . prov . json . Converter ( pFactory ) . readDocument ( is ) ; } case PROVN : { Utility u = new Utility ( ) ; CommonTree tree = u . convertASNToTree ( is ) ; Object o = u . convertTreeToJavaBean ( tree , pFactory ) ; Document doc = ( Document ) o ; return doc ; } case RDFXML : { org . openprovenance . prov . rdf . Utility rdfU = new org . openprovenance . prov . rdf . Utility ( pFactory , onto ) ; return rdfU . parseRDF ( is , RDFFormat . RDFXML , baseuri ) ; } case TRIG : { org . openprovenance . prov . rdf . Utility rdfU = new org . openprovenance . prov . rdf . Utility ( pFactory , onto ) ; return rdfU . parseRDF ( is , RDFFormat . TRIG , baseuri ) ; } case TURTLE : { org . openprovenance . prov . rdf . Utility rdfU = new org . openprovenance . prov . rdf . Utility ( pFactory , onto ) ; return rdfU . parseRDF ( is , RDFFormat . TURTLE , baseuri ) ; } case XML : { ProvDeserialiser deserial = ProvDeserialiser . getThreadProvDeserialiser ( ) ; Document doc = deserial . deserialiseDocument ( is ) ; return doc ; } default : { System . out . println ( "Unknown format " + format ) ; throw new UnsupportedOperationException ( ) ; } } } catch ( IOException e ) { throw new InteropException ( e ) ; } catch ( JAXBException e ) { throw new InteropException ( e ) ; } catch ( RecognitionException e ) { throw new InteropException ( e ) ; } catch ( RDFParseException e ) { throw new InteropException ( e ) ; } catch ( RDFHandlerException e ) { throw new InteropException ( e ) ; } }
Reads a Document from an input stream, using the parser specified by the format argument.
@param is an input stream
@param format one of the input formats supported by ProvToolbox
@param pFactory a provenance factory used to construct the Document
@param baseuri a base uri for the input stream document
@return a Document