org.topbraid.sparqlmotion.util
Class AbstractSMGraphStore

java.lang.Object
  extended by org.topbraid.sparqlmotion.util.AbstractSMGraphStore
All Implemented Interfaces:
IGraphStore
Direct Known Subclasses:
AbstractSesameGraphStore

public abstract class AbstractSMGraphStore
extends java.lang.Object
implements IGraphStore

A generic IGraphStore implementation that operates on SparqlMotion modules. The module must be stored in the config file in N3 format. When opened, this graph store uses the first instance of a given SparqlMotion module type. The URI of that resource is the base URI of the resulting graph.

Author:
Holger Knublauch

Constructor Summary
AbstractSMGraphStore(com.hp.hpl.jena.rdf.model.Resource moduleType, boolean buffering)
           
 
Method Summary
 void close(org.eclipse.core.resources.IFile file)
          Closes any resources allocated by a given file.
 java.net.URI getBaseURI(org.eclipse.core.resources.IFile file, java.util.Set<java.net.URI> imports)
          Gets the declared base URI and the owl:imports of a given file.
protected  com.hp.hpl.jena.rdf.model.Resource getConfig(org.eclipse.core.resources.IFile file)
           
 java.lang.String[] getFileExtensions()
          Returns an (optional) array of file extensions that this graph store can handle.
 com.hp.hpl.jena.graph.Graph getGraph(org.eclipse.core.resources.IFile file, org.eclipse.core.runtime.IProgressMonitor monitor)
           
 ImageMetadata getImageMetadata()
          Gets a (base) image to display files of this type in the Navigator (and potentially elsewhere).
 boolean isReadOnly(org.eclipse.core.resources.IFile file)
          Checks if a given IFile is read-only.
 com.hp.hpl.jena.graph.Graph load(org.eclipse.core.resources.IFile file, org.eclipse.core.runtime.IProgressMonitor monitor)
          Creates a new Jena Graph for a given IFile.
 void save(org.eclipse.core.resources.IFile file, com.hp.hpl.jena.graph.Graph graph, java.lang.String baseURI)
           
 boolean saveAs(org.eclipse.core.resources.IFile file, com.hp.hpl.jena.graph.Graph graph, java.lang.String baseURI)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSMGraphStore

public AbstractSMGraphStore(com.hp.hpl.jena.rdf.model.Resource moduleType,
                            boolean buffering)
Method Detail

close

public void close(org.eclipse.core.resources.IFile file)
           throws java.lang.Exception
Description copied from interface: IGraphStore
Closes any resources allocated by a given file.

Specified by:
close in interface IGraphStore
Parameters:
file - the file representing the store
Throws:
java.lang.Exception

getBaseURI

public java.net.URI getBaseURI(org.eclipse.core.resources.IFile file,
                               java.util.Set<java.net.URI> imports)
                        throws java.lang.Exception
Description copied from interface: IGraphStore
Gets the declared base URI and the owl:imports of a given file. For example, in the standard file back-end this would use file introspection to check the declared xml:base and the owl:imports of the owl:Ontology.

Specified by:
getBaseURI in interface IGraphStore
Parameters:
file - the file to get the base URI of
imports - an initially empty Set that will contain imported URIs
Returns:
the base URI
Throws:
java.lang.Exception

getConfig

protected com.hp.hpl.jena.rdf.model.Resource getConfig(org.eclipse.core.resources.IFile file)
                                                throws java.lang.Exception
Throws:
java.lang.Exception

getFileExtensions

public java.lang.String[] getFileExtensions()
Description copied from interface: IGraphStore
Returns an (optional) array of file extensions that this graph store can handle. This can be used by graph stores that cannot be fully configured through the string attribute of the extension point.

Specified by:
getFileExtensions in interface IGraphStore
Returns:
a list of extensions or null for none

getGraph

public com.hp.hpl.jena.graph.Graph getGraph(org.eclipse.core.resources.IFile file,
                                            org.eclipse.core.runtime.IProgressMonitor monitor)
                                     throws java.lang.Throwable
Throws:
java.lang.Throwable

getImageMetadata

public ImageMetadata getImageMetadata()
Description copied from interface: IGraphStore
Gets a (base) image to display files of this type in the Navigator (and potentially elsewhere).

Specified by:
getImageMetadata in interface IGraphStore
Returns:
the IImage or null to use the default image

isReadOnly

public boolean isReadOnly(org.eclipse.core.resources.IFile file)
Description copied from interface: IGraphStore
Checks if a given IFile is read-only. This is typically used for graph stores that just provide a view on some external data source, such as a D2RQ database (here: all files would be read-only), or for stores like the Sesame remote back-end where selected files may be read-only.

Specified by:
isReadOnly in interface IGraphStore
Returns:
true if this is a read-only store

load

public com.hp.hpl.jena.graph.Graph load(org.eclipse.core.resources.IFile file,
                                        org.eclipse.core.runtime.IProgressMonitor monitor)
                                 throws java.lang.Exception
Description copied from interface: IGraphStore
Creates a new Jena Graph for a given IFile. This method is only called after the system has determined whether this engine is actually responsible for the file's extension.

Specified by:
load in interface IGraphStore
Parameters:
file - the file to load
monitor - the monitor for status reports or null
Returns:
a new Graph
Throws:
java.lang.Exception - if something went wrong

save

public void save(org.eclipse.core.resources.IFile file,
                 com.hp.hpl.jena.graph.Graph graph,
                 java.lang.String baseURI)
          throws java.io.IOException
Specified by:
save in interface IGraphStore
Throws:
java.io.IOException

saveAs

public boolean saveAs(org.eclipse.core.resources.IFile file,
                      com.hp.hpl.jena.graph.Graph graph,
                      java.lang.String baseURI)
               throws java.lang.Exception
Specified by:
saveAs in interface IGraphStore
Returns:
true if the new IFile shall be the editor's input
Throws:
java.lang.Exception