public class InteropFramework extends Object implements InteropMediaType
InteropFramework.ProvFormat
). The class also provides helper functions to support content
negotiation.Modifier and Type | Class and Description |
---|---|
static class |
InteropFramework.ProvFormat
An enumerated type for all the PROV serializations supported by ProvToolbox.
|
static class |
InteropFramework.ProvFormatType |
Modifier and Type | Field and Description |
---|---|
Hashtable<InteropFramework.ProvFormat,String> |
extensionMap |
Hashtable<String,InteropFramework.ProvFormat> |
extensionRevMap |
Hashtable<InteropFramework.ProvFormat,String> |
mimeTypeMap |
Hashtable<String,InteropFramework.ProvFormat> |
mimeTypeRevMap |
Hashtable<InteropFramework.ProvFormat,InteropFramework.ProvFormatType> |
provTypeMap |
static String |
UNKNOWN |
ALL_PROV_INPUT_MEDIA_TYPES, ALL_PROV_OUTPUT_MEDIA_TYPES, EXTENSION_DOT, EXTENSION_JPEG, EXTENSION_JPG, EXTENSION_JSON, EXTENSION_PDF, EXTENSION_PROVN, EXTENSION_PROVX, EXTENSION_RDF, EXTENSION_SVG, EXTENSION_TRIG, EXTENSION_TTL, EXTENSION_XML, MEDIA_APPLICATION_FORM_URLENCODED, MEDIA_APPLICATION_JSON, MEDIA_APPLICATION_PDF, MEDIA_APPLICATION_PROVENANCE_XML, MEDIA_APPLICATION_RDF_XML, MEDIA_APPLICATION_TRIG, MEDIA_APPLICATION_XML, MEDIA_IMAGE_JPEG, MEDIA_IMAGE_SVG_XML, MEDIA_TEXT_HTML, MEDIA_TEXT_PLAIN, MEDIA_TEXT_PROVENANCE_NOTATION, MEDIA_TEXT_TURTLE, MEDIA_TEXT_VND_GRAPHVIZ, MEDIA_TEXT_XML
Constructor and Description |
---|
InteropFramework()
Default constructor for the ProvToolbox interoperability framework.
|
InteropFramework(ProvFactory pFactory) |
InteropFramework(String verbose,
String debug,
String logfile,
String infile,
String outfile,
String namespaces,
String title,
String layout,
String bindings,
String generator,
ProvFactory pFactory) |
Modifier and Type | Method and Description |
---|---|
String |
buildAcceptHeader()
Create a list of mime types supported by ProvToolbox in view of constructing an Accept Header.
|
URLConnection |
connectWithRedirect(URL theURL)
A method to connect to a URL and follow redirects if any.
|
String |
convertExtensionToMediaType(String extension)
Maps an file extension to a Media type
|
String |
getExtension(InteropFramework.ProvFormat format)
Returns an extension for a given type of serialization of PROV
|
InteropFramework.ProvFormat |
getTypeForFile(String filename)
Get a
InteropFramework.ProvFormat given the file's exetension |
List<javax.ws.rs.core.Variant> |
getVariants()
Support for content negotiation, jax-rs style.
|
void |
initializeExtensionMap(Hashtable<InteropFramework.ProvFormat,String> extensionMap,
Hashtable<String,InteropFramework.ProvFormat> extensionRevMap)
Initialization function
|
Boolean |
isInputFormat(InteropFramework.ProvFormat format)
Determines whether this format received as argument is an input format.
|
Boolean |
isOutputFormat(InteropFramework.ProvFormat format)
Determines whether this format received as argument is an output format.
|
Object |
loadProvUnknownGraph(String filename)
Experimental code, trying to load a document without knowing its serialization format.
|
static ProvFactory |
newXMLProvFactory()
Creates a factory for the XML Java beans.
|
void |
provn2html(String file,
String file2) |
Document |
readDocument(InputStream is,
InteropFramework.ProvFormat format)
Reads a Document from an input stream, using the parser specified by the format argument.
|
Document |
readDocument(InputStream is,
InteropFramework.ProvFormat format,
ProvFactory pFactory)
Reads a Document from an input stream, using the parser specified by the format argument.
|
Document |
readDocument(String url)
Reads a document from a URL.
|
Document |
readDocumentFromFile(String filename)
Reads a document from a file, using the file extension to decide which parser to read the file with.
|
void |
run()
Top level entry point of this class, when called from the command line.
|
void |
setNamespaces(Document doc)
Initializes a Document's namespace.
|
void |
writeDocument(OutputStream os,
InteropFramework.ProvFormat format,
Document document)
Write a
Document to output stream, according to specified InteropFramework.ProvFormat |
void |
writeDocument(OutputStream os,
javax.ws.rs.core.MediaType mt,
Document document)
Write a
Document to output stream, according to specified Internet Media Type |
void |
writeDocument(String filename,
Document document)
Write a
Document to file, serialized according to the file extension |
public static final String UNKNOWN
public final Hashtable<InteropFramework.ProvFormat,String> extensionMap
public final Hashtable<String,InteropFramework.ProvFormat> extensionRevMap
public final Hashtable<InteropFramework.ProvFormat,String> mimeTypeMap
public final Hashtable<String,InteropFramework.ProvFormat> mimeTypeRevMap
public final Hashtable<InteropFramework.ProvFormat,InteropFramework.ProvFormatType> provTypeMap
public InteropFramework()
ProvFactory
as its default factory.public InteropFramework(ProvFactory pFactory)
public String buildAcceptHeader()
public URLConnection connectWithRedirect(URL theURL) throws IOException
theURL
- a URL to connect toURLConnection
IOException
- if connection cannot be opened and no response is received.public String convertExtensionToMediaType(String extension)
extension
- the extension of a file containing a serialization of PROVpublic String getExtension(InteropFramework.ProvFormat format)
format
- InteropFramework.ProvFormat
for which file extension is soughtpublic InteropFramework.ProvFormat getTypeForFile(String filename)
InteropFramework.ProvFormat
given the file's exetensionfilename
- the file for which the InteropFramework.ProvFormat
is soughtInteropFramework.ProvFormat
public List<javax.ws.rs.core.Variant> getVariants()
public void initializeExtensionMap(Hashtable<InteropFramework.ProvFormat,String> extensionMap, Hashtable<String,InteropFramework.ProvFormat> extensionRevMap)
extensionMap
- mapping of InteropFramework.ProvFormat
to extensionsextensionRevMap
- reverse mapping of extensions to InteropFramework.ProvFormat
public Boolean isInputFormat(InteropFramework.ProvFormat format)
format
- a InteropFramework.ProvFormat
public Boolean isOutputFormat(InteropFramework.ProvFormat format)
format
- a InteropFramework.ProvFormat
public Object loadProvUnknownGraph(String filename)
filename
- a file to load the provenance document frompublic static ProvFactory newXMLProvFactory()
ProvFactory
public void provn2html(String file, String file2) throws IOException, JAXBException, org.antlr.runtime.RecognitionException
IOException
JAXBException
org.antlr.runtime.RecognitionException
public Document readDocument(InputStream is, InteropFramework.ProvFormat format)
is
- an input streamformat
- one of the input formats supported by ProvToolboxpublic Document readDocument(InputStream is, InteropFramework.ProvFormat format, ProvFactory pFactory)
is
- an input streamformat
- one of the input formats supported by ProvToolboxpFactory
- a provenance factory used to construct the Documentpublic Document readDocument(String url)
url
- a URLpublic Document readDocumentFromFile(String filename)
filename
- the file to read a document frompublic void run()
See method CommandLineArguments.main(String[])
public void setNamespaces(Document doc)
public void writeDocument(OutputStream os, javax.ws.rs.core.MediaType mt, Document document)
Document
to output stream, according to specified Internet Media Typeos
- an OutputStream
to write the Document tomt
- a MediaType
document
- a Document
to serializepublic void writeDocument(OutputStream os, InteropFramework.ProvFormat format, Document document)
Document
to output stream, according to specified InteropFramework.ProvFormat
os
- an OutputStream
to write the Document toformat
- a InteropFramework.ProvFormat
document
- a Document
to serializeCopyright © 2014. All Rights Reserved.