edu.stanford.smi.protegex.owl.jena
Class Jena

java.lang.Object
  extended byedu.stanford.smi.protegex.owl.jena.Jena

public class Jena
extends Object

A collection of static utility methods for Jena.

Author:
Holger Knublauch

Nested Class Summary
protected static class Jena.ObjectMapper
           
 
Field Summary
static String DEFAULT_NAMESPACE_SEPARATOR
           
static String DEFAULT_ONT_POLICY_FILE_PATH
           
static String ONT_POLICY_PROPERTY
           
static String OWL_DL
           
static String OWL_FULL
           
static String OWL_LITE
           
static String ROOT_FOLDER
          Deprecated. use ProtegeOWL.PLUGIN_FOLDER instead
private static Set systemClasses
           
static String XML_TAG_HIDDEN_PROPERTY
           
 
Constructor Summary
Jena()
           
 
Method Summary
static com.hp.hpl.jena.rdf.model.Model addOWLFullModel(com.hp.hpl.jena.ontology.OntModel ontModel)
          Simulates the import of the OWL/RDFS meta ontologies.
private static void addRDFTypes(Hashtable table, com.hp.hpl.jena.ontology.OntProperty property)
           
static com.hp.hpl.jena.ontology.DatatypeProperty asDatatypeProperty(com.hp.hpl.jena.rdf.model.Resource resource)
           
static com.hp.hpl.jena.ontology.ObjectProperty asObjectProperty(com.hp.hpl.jena.rdf.model.Resource resource)
           
static com.hp.hpl.jena.ontology.OntClass asOntClass(com.hp.hpl.jena.rdf.model.Resource resource)
           
static com.hp.hpl.jena.ontology.OntProperty asOntProperty(com.hp.hpl.jena.rdf.model.Resource resource)
           
static boolean canAs(com.hp.hpl.jena.rdf.model.RDFNode resource, com.hp.hpl.jena.rdf.model.Resource type)
          Checks whether a given OntResource has a certain rdf:type, or a subclass thereof.
static boolean canAsDatatypeProperty(com.hp.hpl.jena.rdf.model.RDFNode resource)
           
static boolean canAsObjectProperty(com.hp.hpl.jena.rdf.model.RDFNode resource)
           
static boolean canAsOntClass(com.hp.hpl.jena.rdf.model.RDFNode resource)
           
static boolean canAsOntProperty(com.hp.hpl.jena.rdf.model.RDFNode resource)
           
static boolean canAsOWLProperty(com.hp.hpl.jena.rdf.model.RDFNode resource)
           
static Iterator cloneIt(Iterator it)
          Just creates a cloning Iterator to avoid concurrent modification exceptions.
static com.hp.hpl.jena.ontology.OntModel cloneOntModel(com.hp.hpl.jena.ontology.OntModel oldModel)
           
static com.hp.hpl.jena.ontology.OntModel cloneOntModel(com.hp.hpl.jena.ontology.OntModel oldModel, com.hp.hpl.jena.ontology.OntModelSpec spec)
           
static Hashtable convertTypedAnnotationPropertiesIntoUntyped(com.hp.hpl.jena.ontology.OntModel ontModel)
           
static void copyPropertyValues(com.hp.hpl.jena.rdf.model.Resource from, com.hp.hpl.jena.rdf.model.Resource to)
           
static void dumpRDF(com.hp.hpl.jena.ontology.OntModel ontModel)
           
static void dumpRDF(com.hp.hpl.jena.ontology.OntModel ontModel, OutputStream stream)
           
static void dumpRDFTopLevel(com.hp.hpl.jena.ontology.OntModel ontModel)
           
static void ensureOWLFullModelIsLastModel(com.hp.hpl.jena.ontology.OntModel ontModel, com.hp.hpl.jena.rdf.model.Model owlFullModel)
           
private static com.hp.hpl.jena.rdf.model.Resource getBestType(com.hp.hpl.jena.ontology.OntResource resource)
           
static com.hp.hpl.jena.ontology.Ontology getDefaultJenaOntology(String namespace, com.hp.hpl.jena.ontology.OntModel ontModel)
           
static Collection getDirectSubClasses(com.hp.hpl.jena.ontology.OntClass ontClass)
          Gets the direct subclasses of a given OntClass, excluding the class itself which is usually delivered by Jena.
static Collection getDirectSuperClasses(com.hp.hpl.jena.ontology.OntClass ontClass)
          Gets the direct superclasses of a given OntClass, excluding the class itself which is usually delivered by Jena.
static com.hp.hpl.jena.graph.Graph getHomeGraph(com.hp.hpl.jena.ontology.OntModel ontModel, com.hp.hpl.jena.ontology.OntResource resource)
          Gets the Graph where the rdf:type statement of a certain resource is.
static String getImportSource(com.hp.hpl.jena.ontology.OntModel ontModel, com.hp.hpl.jena.ontology.OntResource resource)
           
static String getNamespaceFromURI(String namespace)
           
static String getNamespaceWithoutSeparator(String namespace)
           
static String getOntPolicyFilePath(edu.stanford.smi.protege.model.Project project)
          Deprecated.  
static int getOWLSpecies(com.hp.hpl.jena.ontology.OntModel ontModel)
           
static String getOWLSpeciesString(int x)
           
static com.hp.hpl.jena.rdf.model.RDFNode getPropertyValue(com.hp.hpl.jena.rdf.model.Resource resource, com.hp.hpl.jena.rdf.model.Property property)
           
static String getURIFromNamespace(String namespace)
           
static boolean isDatatypeProperty(com.hp.hpl.jena.ontology.OntModel ontModel, com.hp.hpl.jena.ontology.OntProperty ontProperty)
           
static boolean isImportedResource(com.hp.hpl.jena.ontology.OntModel ontModel, com.hp.hpl.jena.rdf.model.Model owlFullModel, com.hp.hpl.jena.ontology.OntResource ontResource)
           
static boolean isNamespaceWithSeparator(String str)
           
static boolean isObjectProperty(com.hp.hpl.jena.ontology.OntModel ontModel, com.hp.hpl.jena.ontology.OntProperty ontProperty)
           
static boolean isSystemClass(com.hp.hpl.jena.ontology.OntClass ontClass)
           
static boolean isSystemProperty(com.hp.hpl.jena.ontology.OntProperty property)
           
static boolean isSystemResource(com.hp.hpl.jena.rdf.model.Resource ontResource)
           
static boolean isValidNamespace(String text)
           
static boolean isXMLLanguage(String language)
           
static boolean isXMLTagHidden()
           
static com.hp.hpl.jena.rdf.model.NodeIterator listPropertyValues(com.hp.hpl.jena.rdf.model.Resource resource, com.hp.hpl.jena.rdf.model.Property property)
           
static boolean namespaceEndsWithSeparator(String namespace)
           
static void prepareWriter(com.hp.hpl.jena.rdf.model.RDFWriter writer, String language, String namespace)
           
static void removePropertyValue(com.hp.hpl.jena.ontology.OntResource resource, com.hp.hpl.jena.rdf.model.Property property, String value)
          A convenience method that removes a property value with a given toString serialization from an OntResource.
static void removePropertyValue(com.hp.hpl.jena.rdf.model.Resource resource, com.hp.hpl.jena.rdf.model.Property property, com.hp.hpl.jena.rdf.model.RDFNode value)
           
static com.hp.hpl.jena.rdf.model.Resource renameResource(com.hp.hpl.jena.ontology.OntModel ontModel, com.hp.hpl.jena.rdf.model.Resource old, String uri)
           
static com.hp.hpl.jena.rdf.model.Resource renameResource(com.hp.hpl.jena.rdf.model.Resource old, String uri, com.hp.hpl.jena.rdf.model.Model owlFullModel)
          Deprecated. this has a bug (it does not rename the resource in all models) - use the other renameResource method instead
static void renameResourceInGraph(com.hp.hpl.jena.graph.Graph graph, com.hp.hpl.jena.rdf.model.Resource old, com.hp.hpl.jena.rdf.model.Resource newResource)
           
static void renameResourceInModel(com.hp.hpl.jena.rdf.model.Model m, com.hp.hpl.jena.rdf.model.Resource old, com.hp.hpl.jena.rdf.model.Resource newResource)
          Deprecated. wrong
static void saveOntModel(OWLModel owlModel, File file, com.hp.hpl.jena.ontology.OntModel owldlOntModel, String message)
           
static Set set(Iterator it)
          Converts an Iterator (e.g. those delivered by the Jena listXXX methods) into a List.
static void set(Set set, Iterator it)
          Converts an Iterator (e.g. those delivered by the Jena listXXX methods) into a List.
static void setOntPolicyFilePath(edu.stanford.smi.protege.model.Project project, String path)
          Deprecated.  
static void setXMLTagHidden(boolean value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NAMESPACE_SEPARATOR

public static final String DEFAULT_NAMESPACE_SEPARATOR
See Also:
Constant Field Values

OWL_DL

public static final String OWL_DL
See Also:
Constant Field Values

OWL_FULL

public static final String OWL_FULL
See Also:
Constant Field Values

OWL_LITE

public static final String OWL_LITE
See Also:
Constant Field Values

XML_TAG_HIDDEN_PROPERTY

public static final String XML_TAG_HIDDEN_PROPERTY
See Also:
Constant Field Values

systemClasses

private static final Set systemClasses

ROOT_FOLDER

public static final String ROOT_FOLDER
Deprecated. use ProtegeOWL.PLUGIN_FOLDER instead

See Also:
Constant Field Values

DEFAULT_ONT_POLICY_FILE_PATH

public static final String DEFAULT_ONT_POLICY_FILE_PATH

ONT_POLICY_PROPERTY

public static final String ONT_POLICY_PROPERTY
See Also:
Constant Field Values
Constructor Detail

Jena

public Jena()
Method Detail

addRDFTypes

private static void addRDFTypes(Hashtable table,
                                com.hp.hpl.jena.ontology.OntProperty property)

asDatatypeProperty

public static com.hp.hpl.jena.ontology.DatatypeProperty asDatatypeProperty(com.hp.hpl.jena.rdf.model.Resource resource)

asOntClass

public static com.hp.hpl.jena.ontology.OntClass asOntClass(com.hp.hpl.jena.rdf.model.Resource resource)

asObjectProperty

public static com.hp.hpl.jena.ontology.ObjectProperty asObjectProperty(com.hp.hpl.jena.rdf.model.Resource resource)

asOntProperty

public static com.hp.hpl.jena.ontology.OntProperty asOntProperty(com.hp.hpl.jena.rdf.model.Resource resource)

canAs

public static boolean canAs(com.hp.hpl.jena.rdf.model.RDFNode resource,
                            com.hp.hpl.jena.rdf.model.Resource type)
Checks whether a given OntResource has a certain rdf:type, or a subclass thereof. This is a work-around for the lack of subsumption reasoning in Jena's default model.

Parameters:
resource -
type -
Returns:
true if true, false if not true :)

canAsDatatypeProperty

public static boolean canAsDatatypeProperty(com.hp.hpl.jena.rdf.model.RDFNode resource)

canAsOntClass

public static boolean canAsOntClass(com.hp.hpl.jena.rdf.model.RDFNode resource)

canAsObjectProperty

public static boolean canAsObjectProperty(com.hp.hpl.jena.rdf.model.RDFNode resource)

canAsOntProperty

public static boolean canAsOntProperty(com.hp.hpl.jena.rdf.model.RDFNode resource)

canAsOWLProperty

public static boolean canAsOWLProperty(com.hp.hpl.jena.rdf.model.RDFNode resource)

cloneIt

public static Iterator cloneIt(Iterator it)
Just creates a cloning Iterator to avoid concurrent modification exceptions.

Parameters:
it - the source Iterator
Returns:
a new, independent Iterator

cloneOntModel

public static com.hp.hpl.jena.ontology.OntModel cloneOntModel(com.hp.hpl.jena.ontology.OntModel oldModel)

cloneOntModel

public static com.hp.hpl.jena.ontology.OntModel cloneOntModel(com.hp.hpl.jena.ontology.OntModel oldModel,
                                                              com.hp.hpl.jena.ontology.OntModelSpec spec)

convertTypedAnnotationPropertiesIntoUntyped

public static Hashtable convertTypedAnnotationPropertiesIntoUntyped(com.hp.hpl.jena.ontology.OntModel ontModel)

copyPropertyValues

public static void copyPropertyValues(com.hp.hpl.jena.rdf.model.Resource from,
                                      com.hp.hpl.jena.rdf.model.Resource to)

dumpRDF

public static void dumpRDF(com.hp.hpl.jena.ontology.OntModel ontModel)

dumpRDF

public static void dumpRDF(com.hp.hpl.jena.ontology.OntModel ontModel,
                           OutputStream stream)

dumpRDFTopLevel

public static void dumpRDFTopLevel(com.hp.hpl.jena.ontology.OntModel ontModel)

addOWLFullModel

public static com.hp.hpl.jena.rdf.model.Model addOWLFullModel(com.hp.hpl.jena.ontology.OntModel ontModel)
Simulates the import of the OWL/RDFS meta ontologies. This method returns a new Model which can be added as subgraph to an ontology, so that the system properties and classes can be safely casted into OntProperty and OntClass.

Parameters:
ontModel - the OntModel to add a new sub model
Returns:
the sub model that has been added

ensureOWLFullModelIsLastModel

public static void ensureOWLFullModelIsLastModel(com.hp.hpl.jena.ontology.OntModel ontModel,
                                                 com.hp.hpl.jena.rdf.model.Model owlFullModel)

getHomeGraph

public static com.hp.hpl.jena.graph.Graph getHomeGraph(com.hp.hpl.jena.ontology.OntModel ontModel,
                                                       com.hp.hpl.jena.ontology.OntResource resource)
Gets the Graph where the rdf:type statement of a certain resource is.

Parameters:
ontModel - the OntModel
resource - the Resource to look up
Returns:
a sub graph of ontModel

getImportSource

public static String getImportSource(com.hp.hpl.jena.ontology.OntModel ontModel,
                                     com.hp.hpl.jena.ontology.OntResource resource)

getOWLSpecies

public static int getOWLSpecies(com.hp.hpl.jena.ontology.OntModel ontModel)

getOWLSpeciesString

public static String getOWLSpeciesString(int x)

getNamespaceFromURI

public static String getNamespaceFromURI(String namespace)

getNamespaceWithoutSeparator

public static String getNamespaceWithoutSeparator(String namespace)

getURIFromNamespace

public static String getURIFromNamespace(String namespace)

isDatatypeProperty

public static boolean isDatatypeProperty(com.hp.hpl.jena.ontology.OntModel ontModel,
                                         com.hp.hpl.jena.ontology.OntProperty ontProperty)

isImportedResource

public static boolean isImportedResource(com.hp.hpl.jena.ontology.OntModel ontModel,
                                         com.hp.hpl.jena.rdf.model.Model owlFullModel,
                                         com.hp.hpl.jena.ontology.OntResource ontResource)

getBestType

private static com.hp.hpl.jena.rdf.model.Resource getBestType(com.hp.hpl.jena.ontology.OntResource resource)

isNamespaceWithSeparator

public static boolean isNamespaceWithSeparator(String str)

isObjectProperty

public static boolean isObjectProperty(com.hp.hpl.jena.ontology.OntModel ontModel,
                                       com.hp.hpl.jena.ontology.OntProperty ontProperty)

isSystemProperty

public static boolean isSystemProperty(com.hp.hpl.jena.ontology.OntProperty property)

isSystemResource

public static boolean isSystemResource(com.hp.hpl.jena.rdf.model.Resource ontResource)

isSystemClass

public static boolean isSystemClass(com.hp.hpl.jena.ontology.OntClass ontClass)

isValidNamespace

public static boolean isValidNamespace(String text)

isXMLLanguage

public static boolean isXMLLanguage(String language)

isXMLTagHidden

public static boolean isXMLTagHidden()

namespaceEndsWithSeparator

public static boolean namespaceEndsWithSeparator(String namespace)

prepareWriter

public static void prepareWriter(com.hp.hpl.jena.rdf.model.RDFWriter writer,
                                 String language,
                                 String namespace)

removePropertyValue

public static void removePropertyValue(com.hp.hpl.jena.ontology.OntResource resource,
                                       com.hp.hpl.jena.rdf.model.Property property,
                                       String value)
A convenience method that removes a property value with a given toString serialization from an OntResource. This method was introduced to overcome the lack of a similar method in Jena.

Parameters:
resource - the OntResource to remove the property value from
property - the Property to remove a value of
value - the toString value to remove

renameResource

public static com.hp.hpl.jena.rdf.model.Resource renameResource(com.hp.hpl.jena.rdf.model.Resource old,
                                                                String uri,
                                                                com.hp.hpl.jena.rdf.model.Model owlFullModel)
Deprecated. this has a bug (it does not rename the resource in all models) - use the other renameResource method instead


renameResource

public static com.hp.hpl.jena.rdf.model.Resource renameResource(com.hp.hpl.jena.ontology.OntModel ontModel,
                                                                com.hp.hpl.jena.rdf.model.Resource old,
                                                                String uri)

renameResourceInGraph

public static void renameResourceInGraph(com.hp.hpl.jena.graph.Graph graph,
                                         com.hp.hpl.jena.rdf.model.Resource old,
                                         com.hp.hpl.jena.rdf.model.Resource newResource)

renameResourceInModel

public static void renameResourceInModel(com.hp.hpl.jena.rdf.model.Model m,
                                         com.hp.hpl.jena.rdf.model.Resource old,
                                         com.hp.hpl.jena.rdf.model.Resource newResource)
Deprecated. wrong


saveOntModel

public static void saveOntModel(OWLModel owlModel,
                                File file,
                                com.hp.hpl.jena.ontology.OntModel owldlOntModel,
                                String message)

set

public static Set set(Iterator it)
Converts an Iterator (e.g. those delivered by the Jena listXXX methods) into a List.

Parameters:
it - the Iterator to convert
Returns:
a List with the same elements

set

public static void set(Set set,
                       Iterator it)
Converts an Iterator (e.g. those delivered by the Jena listXXX methods) into a List.

Parameters:
it - the Iterator to convert

setXMLTagHidden

public static void setXMLTagHidden(boolean value)

getPropertyValue

public static com.hp.hpl.jena.rdf.model.RDFNode getPropertyValue(com.hp.hpl.jena.rdf.model.Resource resource,
                                                                 com.hp.hpl.jena.rdf.model.Property property)

listPropertyValues

public static com.hp.hpl.jena.rdf.model.NodeIterator listPropertyValues(com.hp.hpl.jena.rdf.model.Resource resource,
                                                                        com.hp.hpl.jena.rdf.model.Property property)

getDirectSubClasses

public static Collection getDirectSubClasses(com.hp.hpl.jena.ontology.OntClass ontClass)
Gets the direct subclasses of a given OntClass, excluding the class itself which is usually delivered by Jena.

Parameters:
ontClass - the OntClass to get the subclasses of
Returns:
a Collection of subclasses (OntClass instances)

getDirectSuperClasses

public static Collection getDirectSuperClasses(com.hp.hpl.jena.ontology.OntClass ontClass)
Gets the direct superclasses of a given OntClass, excluding the class itself which is usually delivered by Jena.

Parameters:
ontClass - the OntClass to get the superclasses of
Returns:
a Collection of superclasses (OntClass instances)

getDefaultJenaOntology

public static com.hp.hpl.jena.ontology.Ontology getDefaultJenaOntology(String namespace,
                                                                       com.hp.hpl.jena.ontology.OntModel ontModel)

getOntPolicyFilePath

public static String getOntPolicyFilePath(edu.stanford.smi.protege.model.Project project)
Deprecated.  


setOntPolicyFilePath

public static void setOntPolicyFilePath(edu.stanford.smi.protege.model.Project project,
                                        String path)
Deprecated.  


removePropertyValue

public static void removePropertyValue(com.hp.hpl.jena.rdf.model.Resource resource,
                                       com.hp.hpl.jena.rdf.model.Property property,
                                       com.hp.hpl.jena.rdf.model.RDFNode value)