edu.stanford.smi.protegex.owl.model.impl
Class OWLUtil

java.lang.Object
  extended byedu.stanford.smi.protegex.owl.model.impl.OWLUtil

public class OWLUtil
extends Object

A collection of static utility methods for OWL classes. Many of them are used to "simulate" the multiple inheritance between the various implementations of RDFResource.

Author:
Holger Knublauch

Constructor Summary
OWLUtil()
           
 
Method Summary
static void addComment(RDFResource resource, String comment)
           
static void addDifferentFrom(RDFResource resource, RDFResource differentFrom)
           
static void addIsDefinedBy(edu.stanford.smi.protege.model.Instance source, edu.stanford.smi.protege.model.Instance instance)
           
static void addLabel(RDFResource source, String label, String language)
           
static void addPropertyValue(RDFResource resource, RDFProperty property, Object value)
           
static void addPropertyValueListener(RDFResource resource, PropertyValueListener listener)
           
static void addProtegeType(RDFResource resource, RDFSClass type)
           
static void addRDFType(RDFResource resource, RDFSClass type)
           
static void addResourceListener(RDFResource resource, ResourceListener listener)
           
static void addSameAs(edu.stanford.smi.protege.model.Instance source, edu.stanford.smi.protege.model.Instance instance)
           
static void addVersionInfo(edu.stanford.smi.protege.model.Instance source, String versionInfo)
           
static RDFResource as(RDFResource resource, Class javaInterface)
           
static void assignUniqueURI(RDFUntypedResource eri)
           
static boolean canAs(RDFResource resource, Class javaInterface)
           
static boolean confirmSaveAndReload()
          Deprecated. use the version with project parameter instead
static boolean confirmSaveAndReload(edu.stanford.smi.protege.model.Project project)
           
static boolean containsAnonymousClass(Collection clses)
           
static void convertEquivalentClsIntoSuperClses(RDFSClass ownerClass, RDFSClass equivalentClass)
           
static void convertSuperClsIntoEquivalentCls(OWLNamedClass ownerCls, RDFSClass superClass)
           
static void convertSuperClsIntoEquivalentCls(OWLNamedClass ownerCls, RDFSClass superClass, RDFSClass definition)
           
static void copyAnnotations(edu.stanford.smi.protege.model.Instance source, edu.stanford.smi.protege.model.Instance target)
           
static edu.stanford.smi.protege.model.Cls createClone(edu.stanford.smi.protege.model.Cls cls)
          Creates a copy of a given class and also copies the annotation property values.
static RDFSClass createClone(OWLModel owlModel, String expression)
           
static void ensureSubclassesDisjoint(OWLNamedClass cls)
           
static boolean equalsStructurally(Collection collection1, Collection collection2)
           
static RDFResource getAllValuesFromOnTypes(RDFResource resource, RDFProperty property)
           
static Collection getComments(RDFResource resource)
           
static Collection getDifferentFrom(RDFResource resource)
           
static RDFSClass getDirectRDFType(RDFResource resource)
           
static Collection getDirectRDFTypes(RDFResource resource)
           
static Collection getDocumentation(edu.stanford.smi.protege.model.Instance source)
           
static Collection getHasValuesOnTypes(RDFResource resource, RDFProperty property)
           
static Collection getInferredDirectTypes(RDFResource resource)
           
static Collection getIsDefinedBy(edu.stanford.smi.protege.model.Instance source)
           
static Collection getLabels(RDFResource source)
           
static Collection getPathsToRoot(edu.stanford.smi.protege.model.Cls cls)
          Gets all paths from a given class to the root.
private static List getPathToRoot(edu.stanford.smi.protege.model.Cls cls, LinkedList list, Collection lists)
           
static Collection getPossibleRDFProperties(RDFResource resource)
           
static List getPotentiallyDisjointSubclasses(OWLNamedClass cls)
           
static Object getPropertyValue(RDFResource resource, RDFProperty property, boolean includingSubproperties)
           
static RDFResource getPropertyValueAs(RDFResource resource, RDFProperty property, Class javaInterface)
           
static int getPropertyValueCount(RDFResource resource, RDFProperty property)
           
static RDFSLiteral getPropertyValueLiteral(RDFResource resource, RDFProperty property)
           
static Collection getPropertyValueLiterals(RDFResource resource, RDFProperty property)
           
static Collection getPropertyValues(RDFResource resource, RDFProperty property, boolean includingSubproperties)
           
static Collection getPropertyValuesAs(RDFResource resource, RDFProperty property, Class javaInterface)
           
static Collection getRDFProperties(RDFResource resource)
           
static RDFSClass getRDFType(RDFResource resource)
           
static Collection getRDFTypes(RDFResource resource)
           
static Set getReferringAnonymousClses(RDFResource instance)
           
static void getReferringLogicalClasses(RDFList list, Set set)
           
static Collection getSameAs(edu.stanford.smi.protege.model.Instance source)
           
static Collection getSelectableNamedClses(OWLModel owlModel)
           
static Collection getVersionInfo(edu.stanford.smi.protege.model.Instance source)
           
static boolean hasDirectRestriction(edu.stanford.smi.protege.model.Cls cls, edu.stanford.smi.protege.model.Slot slot, edu.stanford.smi.protege.model.Cls metaCls)
           
static boolean hasOWLDLProfile(OWLModel owlModel)
           
static boolean hasOWLFullProfile(OWLModel owlModel)
           
static boolean hasPropertyValue(RDFResource resource, RDFProperty property)
           
static boolean hasPropertyValue(RDFResource resource, RDFProperty property, boolean includingSubproperties)
           
static boolean hasPropertyValue(RDFResource resource, RDFProperty property, Object value, boolean includingSubproperties)
           
static boolean hasProtegeType(RDFResource resource, RDFSClass type)
           
static boolean hasProtegeType(RDFResource resource, RDFSClass type, boolean includingSuperclasses)
           
static boolean hasRDFProfile(OWLModel owlModel)
           
static boolean hasRDFType(RDFResource resource, RDFSClass type)
           
static boolean hasRDFType(RDFResource resource, RDFSClass type, boolean includingSuperclasses)
           
static boolean isInconsistent(edu.stanford.smi.protege.model.Cls cls)
           
static boolean isSystem(edu.stanford.smi.protege.model.Frame resource)
           
static boolean isValidPropertyValue(RDFResource resource, RDFProperty property, Object object)
           
static Iterator listPropertyValues(RDFResource resource, RDFProperty property, boolean includingSubproperties)
           
static Iterator listPropertyValuesAs(RDFResource resource, RDFProperty property, Class javaInterface)
           
static void printStackTrace()
           
static void removeComment(RDFResource resource, String comment)
           
static void removeDifferentFrom(RDFResource resource, RDFResource differentFrom)
           
static List removeInvisibleResources(Iterator it)
           
static void removeIsDefinedBy(edu.stanford.smi.protege.model.Instance source, edu.stanford.smi.protege.model.Instance instance)
           
static void removeLabel(RDFResource source, String label, String language)
           
static void removePropertyValue(RDFResource resource, RDFProperty property, Object value)
           
static void removePropertyValueListener(RDFResource resource, PropertyValueListener listener)
           
static void removeProtegeType(RDFResource resource, RDFSClass type)
           
static void removeRDFType(RDFResource resource, RDFSClass type)
           
static void removeResourceListener(RDFResource resource, ResourceListener listener)
           
static void removeSameAs(edu.stanford.smi.protege.model.Instance source, edu.stanford.smi.protege.model.Instance instance)
           
static void removeSubclassesDisjoint(OWLNamedClass cls)
           
static void removeVersionInfo(edu.stanford.smi.protege.model.Instance source, String versionInfo)
           
static void resetComputedSuperclasses(OWLModel owlModel)
           
static void resetComputedSuperclasses(OWLModel owlModel, Collection clses)
           
static boolean saveAndReloadProject()
           
static void setComment(RDFResource resource, String comment)
           
static void setComments(RDFResource resource, Collection comments)
           
static void setConsistentClassificationStatus(OWLNamedClass namedCls)
           
static void setDocumentation(edu.stanford.smi.protege.model.Instance source, Collection values)
           
static void setInferredTypes(RDFResource resource, Collection types)
           
static void setPropertyValue(RDFResource resource, RDFProperty property, Object value)
           
static void setPropertyValues(RDFResource resource, RDFProperty property, Collection values)
           
static void setProtegeType(RDFResource resource, RDFSClass type)
           
static void setProtegeTypes(RDFResource resource, Collection types)
           
static void setRDFType(RDFResource resource, RDFSClass type)
           
static void setRDFTypes(RDFResource resource, Collection types)
           
static void sortSubclasses(edu.stanford.smi.protege.model.Cls superCls)
           
static void sortSubclasses(OWLModel owlModel)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OWLUtil

public OWLUtil()
Method Detail

addIsDefinedBy

public static void addIsDefinedBy(edu.stanford.smi.protege.model.Instance source,
                                  edu.stanford.smi.protege.model.Instance instance)

addLabel

public static void addLabel(RDFResource source,
                            String label,
                            String language)

addSameAs

public static void addSameAs(edu.stanford.smi.protege.model.Instance source,
                             edu.stanford.smi.protege.model.Instance instance)

addVersionInfo

public static void addVersionInfo(edu.stanford.smi.protege.model.Instance source,
                                  String versionInfo)

assignUniqueURI

public static void assignUniqueURI(RDFUntypedResource eri)

confirmSaveAndReload

public static boolean confirmSaveAndReload()
Deprecated. use the version with project parameter instead


confirmSaveAndReload

public static boolean confirmSaveAndReload(edu.stanford.smi.protege.model.Project project)

copyAnnotations

public static void copyAnnotations(edu.stanford.smi.protege.model.Instance source,
                                   edu.stanford.smi.protege.model.Instance target)

convertEquivalentClsIntoSuperClses

public static void convertEquivalentClsIntoSuperClses(RDFSClass ownerClass,
                                                      RDFSClass equivalentClass)

convertSuperClsIntoEquivalentCls

public static void convertSuperClsIntoEquivalentCls(OWLNamedClass ownerCls,
                                                    RDFSClass superClass)

convertSuperClsIntoEquivalentCls

public static void convertSuperClsIntoEquivalentCls(OWLNamedClass ownerCls,
                                                    RDFSClass superClass,
                                                    RDFSClass definition)

createClone

public static edu.stanford.smi.protege.model.Cls createClone(edu.stanford.smi.protege.model.Cls cls)
Creates a copy of a given class and also copies the annotation property values.

Parameters:
cls - the class to clone
Returns:
a clone of cls or cls itself if it is a named class

createClone

public static RDFSClass createClone(OWLModel owlModel,
                                    String expression)

ensureSubclassesDisjoint

public static void ensureSubclassesDisjoint(OWLNamedClass cls)

equalsStructurally

public static boolean equalsStructurally(Collection collection1,
                                         Collection collection2)

getDocumentation

public static Collection getDocumentation(edu.stanford.smi.protege.model.Instance source)

getInferredDirectTypes

public static Collection getInferredDirectTypes(RDFResource resource)

getIsDefinedBy

public static Collection getIsDefinedBy(edu.stanford.smi.protege.model.Instance source)

getLabels

public static Collection getLabels(RDFResource source)

getPathsToRoot

public static Collection getPathsToRoot(edu.stanford.smi.protege.model.Cls cls)
Gets all paths from a given class to the root. This is needed if the user requests to see all occurances of a class in a tree.

Parameters:
cls - the Cls to find all paths to
Returns:
a Collection of List objects, with each List starting at cls

getPathToRoot

private static List getPathToRoot(edu.stanford.smi.protege.model.Cls cls,
                                  LinkedList list,
                                  Collection lists)

getPotentiallyDisjointSubclasses

public static List getPotentiallyDisjointSubclasses(OWLNamedClass cls)

getReferringAnonymousClses

public static Set getReferringAnonymousClses(RDFResource instance)

getReferringLogicalClasses

public static void getReferringLogicalClasses(RDFList list,
                                              Set set)

getSameAs

public static Collection getSameAs(edu.stanford.smi.protege.model.Instance source)

getSelectableNamedClses

public static Collection getSelectableNamedClses(OWLModel owlModel)

getVersionInfo

public static Collection getVersionInfo(edu.stanford.smi.protege.model.Instance source)

hasDirectRestriction

public static boolean hasDirectRestriction(edu.stanford.smi.protege.model.Cls cls,
                                           edu.stanford.smi.protege.model.Slot slot,
                                           edu.stanford.smi.protege.model.Cls metaCls)

hasOWLDLProfile

public static boolean hasOWLDLProfile(OWLModel owlModel)

hasOWLFullProfile

public static boolean hasOWLFullProfile(OWLModel owlModel)

hasRDFProfile

public static boolean hasRDFProfile(OWLModel owlModel)

isInconsistent

public static boolean isInconsistent(edu.stanford.smi.protege.model.Cls cls)

printStackTrace

public static void printStackTrace()

removeIsDefinedBy

public static void removeIsDefinedBy(edu.stanford.smi.protege.model.Instance source,
                                     edu.stanford.smi.protege.model.Instance instance)

removeLabel

public static void removeLabel(RDFResource source,
                               String label,
                               String language)

removeSameAs

public static void removeSameAs(edu.stanford.smi.protege.model.Instance source,
                                edu.stanford.smi.protege.model.Instance instance)

removeSubclassesDisjoint

public static void removeSubclassesDisjoint(OWLNamedClass cls)

removeVersionInfo

public static void removeVersionInfo(edu.stanford.smi.protege.model.Instance source,
                                     String versionInfo)

resetComputedSuperclasses

public static void resetComputedSuperclasses(OWLModel owlModel)

resetComputedSuperclasses

public static void resetComputedSuperclasses(OWLModel owlModel,
                                             Collection clses)

saveAndReloadProject

public static boolean saveAndReloadProject()

setDocumentation

public static void setDocumentation(edu.stanford.smi.protege.model.Instance source,
                                    Collection values)

setConsistentClassificationStatus

public static void setConsistentClassificationStatus(OWLNamedClass namedCls)

sortSubclasses

public static void sortSubclasses(edu.stanford.smi.protege.model.Cls superCls)

addProtegeType

public static void addProtegeType(RDFResource resource,
                                  RDFSClass type)

getDirectRDFType

public static RDFSClass getDirectRDFType(RDFResource resource)

getDirectRDFTypes

public static Collection getDirectRDFTypes(RDFResource resource)

hasProtegeType

public static boolean hasProtegeType(RDFResource resource,
                                     RDFSClass type)

hasProtegeType

public static boolean hasProtegeType(RDFResource resource,
                                     RDFSClass type,
                                     boolean includingSuperclasses)

removeProtegeType

public static void removeProtegeType(RDFResource resource,
                                     RDFSClass type)

setProtegeType

public static void setProtegeType(RDFResource resource,
                                  RDFSClass type)

setProtegeTypes

public static void setProtegeTypes(RDFResource resource,
                                   Collection types)

addDifferentFrom

public static void addDifferentFrom(RDFResource resource,
                                    RDFResource differentFrom)

removeDifferentFrom

public static void removeDifferentFrom(RDFResource resource,
                                       RDFResource differentFrom)

addComment

public static void addComment(RDFResource resource,
                              String comment)

removeComment

public static void removeComment(RDFResource resource,
                                 String comment)

addPropertyValue

public static void addPropertyValue(RDFResource resource,
                                    RDFProperty property,
                                    Object value)

getComments

public static Collection getComments(RDFResource resource)

setComment

public static void setComment(RDFResource resource,
                              String comment)

setComments

public static void setComments(RDFResource resource,
                               Collection comments)

setInferredTypes

public static void setInferredTypes(RDFResource resource,
                                    Collection types)

getDifferentFrom

public static Collection getDifferentFrom(RDFResource resource)

getPropertyValue

public static Object getPropertyValue(RDFResource resource,
                                      RDFProperty property,
                                      boolean includingSubproperties)

getPropertyValueCount

public static int getPropertyValueCount(RDFResource resource,
                                        RDFProperty property)

getPropertyValues

public static Collection getPropertyValues(RDFResource resource,
                                           RDFProperty property,
                                           boolean includingSubproperties)

listPropertyValues

public static Iterator listPropertyValues(RDFResource resource,
                                          RDFProperty property,
                                          boolean includingSubproperties)

removePropertyValue

public static void removePropertyValue(RDFResource resource,
                                       RDFProperty property,
                                       Object value)

setPropertyValue

public static void setPropertyValue(RDFResource resource,
                                    RDFProperty property,
                                    Object value)

setPropertyValues

public static void setPropertyValues(RDFResource resource,
                                     RDFProperty property,
                                     Collection values)

isSystem

public static boolean isSystem(edu.stanford.smi.protege.model.Frame resource)

getPropertyValueLiterals

public static Collection getPropertyValueLiterals(RDFResource resource,
                                                  RDFProperty property)

getPropertyValueLiteral

public static RDFSLiteral getPropertyValueLiteral(RDFResource resource,
                                                  RDFProperty property)

getRDFProperties

public static Collection getRDFProperties(RDFResource resource)

addResourceListener

public static void addResourceListener(RDFResource resource,
                                       ResourceListener listener)

removeResourceListener

public static void removeResourceListener(RDFResource resource,
                                          ResourceListener listener)

hasPropertyValue

public static boolean hasPropertyValue(RDFResource resource,
                                       RDFProperty property,
                                       Object value,
                                       boolean includingSubproperties)

addPropertyValueListener

public static void addPropertyValueListener(RDFResource resource,
                                            PropertyValueListener listener)

removePropertyValueListener

public static void removePropertyValueListener(RDFResource resource,
                                               PropertyValueListener listener)

getPossibleRDFProperties

public static Collection getPossibleRDFProperties(RDFResource resource)

as

public static RDFResource as(RDFResource resource,
                             Class javaInterface)

canAs

public static boolean canAs(RDFResource resource,
                            Class javaInterface)

getPropertyValuesAs

public static Collection getPropertyValuesAs(RDFResource resource,
                                             RDFProperty property,
                                             Class javaInterface)

getPropertyValueAs

public static RDFResource getPropertyValueAs(RDFResource resource,
                                             RDFProperty property,
                                             Class javaInterface)

listPropertyValuesAs

public static Iterator listPropertyValuesAs(RDFResource resource,
                                            RDFProperty property,
                                            Class javaInterface)

hasPropertyValue

public static boolean hasPropertyValue(RDFResource resource,
                                       RDFProperty property)

hasPropertyValue

public static boolean hasPropertyValue(RDFResource resource,
                                       RDFProperty property,
                                       boolean includingSubproperties)

getRDFType

public static RDFSClass getRDFType(RDFResource resource)

getRDFTypes

public static Collection getRDFTypes(RDFResource resource)

addRDFType

public static void addRDFType(RDFResource resource,
                              RDFSClass type)

removeRDFType

public static void removeRDFType(RDFResource resource,
                                 RDFSClass type)

hasRDFType

public static boolean hasRDFType(RDFResource resource,
                                 RDFSClass type)

hasRDFType

public static boolean hasRDFType(RDFResource resource,
                                 RDFSClass type,
                                 boolean includingSuperclasses)

sortSubclasses

public static void sortSubclasses(OWLModel owlModel)

setRDFType

public static void setRDFType(RDFResource resource,
                              RDFSClass type)

setRDFTypes

public static void setRDFTypes(RDFResource resource,
                               Collection types)

getHasValuesOnTypes

public static Collection getHasValuesOnTypes(RDFResource resource,
                                             RDFProperty property)

containsAnonymousClass

public static boolean containsAnonymousClass(Collection clses)

removeInvisibleResources

public static List removeInvisibleResources(Iterator it)

isValidPropertyValue

public static boolean isValidPropertyValue(RDFResource resource,
                                           RDFProperty property,
                                           Object object)

getAllValuesFromOnTypes

public static RDFResource getAllValuesFromOnTypes(RDFResource resource,
                                                  RDFProperty property)