Class OmlRead

java.lang.Object
io.opencaesar.oml.util.OmlRead

public final class OmlRead extends Object
The Read API for the model. It complements the OML getter API by additional utilities.
  • Constructor Details

    • OmlRead

      public OmlRead()
  • Method Details

    • closure

      public static <T, V extends T> Collection<T> closure(V root, boolean includeRoot, Function<T,Collection<T>> recursive)
      Gets the closure of the given recursive function starting from a given root
      Parameters:
      root - the given root to start the recursion from
      includeRoot - whether to include the root in the closure results
      recursive - the function to recurse with
      Returns:
      the recursive closure of applying the given function on the given root
    • isInClosure

      public static <T, V extends T> boolean isInClosure(T item, V root, boolean includeRoot, Function<T,Collection<T>> recursive)
      Checks if a given item is in the closure of the given recursive function starting from a given root
      Parameters:
      item - the given item to look for
      root - the given root to start the recursion from
      includeRoot - whether to include the root in the closure
      recursive - the function to recurse with
      Returns:
      true if the given item is in the closure; otherwise false
    • isResolvedUri

      public static boolean isResolvedUri(org.eclipse.emf.common.util.URI uri)
      Determines whether the given URI can be resolved to an OML resource in the workspace
      Parameters:
      uri - the given URI
      Returns:
      True if the given URI can be resolved, otherwise False
    • getResolvedUri

      public static org.eclipse.emf.common.util.URI getResolvedUri(org.eclipse.emf.ecore.resource.Resource context, String iri)
      Gets a URI that is resolved by the given IRI in the context of the given OML resource.
      Parameters:
      context - The OML resource to use as context of URI resolution
      iri - The IRI to resolve
      Returns:
      The resolved URI
    • getResolvedUris

      public static Set<org.eclipse.emf.common.util.URI> getResolvedUris(org.eclipse.emf.ecore.resource.Resource context)
      Gets the URIs that can be resolved in the context of the given OML resource
      Parameters:
      context - the context resource
      Returns:
      a set of resource URIs that are resolvable from the given resource
    • getOntology

      public static Ontology getOntology(org.eclipse.emf.ecore.resource.Resource resource)
      Gets the ontology loaded in the given OML resource (if one exists)
      Parameters:
      resource - The OML resource to get the ontology of
      Returns:
      An ontology if one exists in the given resource; otherwise null
    • getOntologies

      public static List<Ontology> getOntologies(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
      Gets all ontologies loaded in the given resource set
      Parameters:
      resourceSet - The resource set to look for ontologies in
      Returns:
      The list of ontologies loaded in the given resource set
    • getOntologyByIri

      public static Ontology getOntologyByIri(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, String iri)
      Gets an ontology with the given IRI loaded in the given resource set
      Parameters:
      resourceSet - The resource set to look for an ontology in
      iri - The IRI of the ontology
      Returns:
      an ontology with the given IRI if found; otherwise null
    • getOntologyByPrefix

      public static Ontology getOntologyByPrefix(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, String prefix)
      Gets an ontology with the given prefix loaded in the given resource set If more than one ontology has the same prefix, the first found is returned
      Parameters:
      resourceSet - The resource set to look for an ontology in
      prefix - The prefix of the ontology
      Returns:
      an ontology with the given prefix if found; otherwise null
    • getOntologyByResolvingIri

      public static Ontology getOntologyByResolvingIri(org.eclipse.emf.ecore.resource.Resource context, String iri)
      Gets an ontology with the given IRI that can be resolved in the context of the given resource This will cause the ontology's resource to load if not already loaded
      Parameters:
      context - The resource to use as context of IRI resolution
      iri - The IRI of the ontology to get
      Returns:
      an ontology with the given IRI
    • getImportedOntologies

      public static List<Ontology> getImportedOntologies(Ontology ontology)
      Gets the ontologies directly imported by a given ontology This will cause an imported ontology's resource to load if not already loaded
      Parameters:
      ontology - the given ontology
      Returns:
      a list of ontologies directly imported by the given ontology
    • getImportedOntologyByIri

      public static Ontology getImportedOntologyByIri(Ontology ontology, String iri)
      Gets an ontology directly imported by a given ontology using the given IRI This will cause an imported ontology's resource to load if not already loaded
      Parameters:
      ontology - the context ontology
      iri - the IRI of the imported ontology
      Returns:
      an ontology that is imported by the given IRI; otherwise null
    • getImportedOntologyByPrefix

      public static Ontology getImportedOntologyByPrefix(Ontology ontology, String prefix)
      Gets an ontology directly imported by a given ontology using the given prefix This will cause an imported ontology's resource to load if not already loaded
      Parameters:
      ontology - the context ontology
      prefix - the prefix of the imported ontology
      Returns:
      an ontology that is imported by the given prefix; otherwise null
    • getImportedOntologyClosure

      public static Collection<Ontology> getImportedOntologyClosure(Ontology ontology, boolean inclusive)
      Gets the ontologies directly or transitively imported by the given ontology This will cause an imported ontology's resource to load if not already loaded
      Parameters:
      ontology - the given ontology
      inclusive - whether the given ontology should be included in the closure
      Returns:
      a collection of ontologies directly or transitively imported by the given ontology
    • getImportingOntologies

      public static Collection<Ontology> getImportingOntologies(Ontology ontology)
      Gets loaded ontologies that directly import the given ontology
      Parameters:
      ontology - the given ontologies
      Returns:
      a collection of ontologies that import the given ontology directly
    • getImportScope

      public static Set<org.eclipse.emf.ecore.resource.Resource> getImportScope(Ontology ontology)
      Gets the set of resources that represent the import scope of the given ontology This will cause an imported ontology's resource to load if not already loaded
      Parameters:
      ontology - the given ontology
      Returns:
      a collection of resources that represent the import scope of the given ontology
    • getImportedOntology

      public static Ontology getImportedOntology(Import _import)
      Gets the ontology that is imported by the given import This will cause an imported ontology's resource to load if not already loaded
      Parameters:
      _import - the given import
      Returns:
      the ontology that is imported by the given import (or null if the import resolution failed)
    • getImportingOntology

      public static Ontology getImportingOntology(Import _import)
      Gets the ontology that owns the given import
      Parameters:
      _import - the given import
      Returns:
      the ontology that defines the given import
    • getImportNamespaceToPrefixMap

      public static Map<String,String> getImportNamespaceToPrefixMap(Ontology ontology)
      Gets a map from import namespaces to import prefixes in the given ontology
      Parameters:
      ontology - the given ontology
      Returns:
      a map from import namespaces to import prefixes
    • getImportPrefixToNamespaceMap

      public static Map<String,String> getImportPrefixToNamespaceMap(Ontology ontology)
      Gets a map from import prefixes to import namespaces in the given ontology
      Parameters:
      ontology - the given ontology
      Returns:
      a map from import prefixes to import namespaces
    • getMembers

      public static List<Member> getMembers(Ontology ontology)
      Gets all members defined in the given ontology
      Parameters:
      ontology - the given ontology
      Returns:
      a list of all members defined in the given ontology
    • getMemberByName

      public static Member getMemberByName(Ontology ontology, String name)
      Gets a member with the given name defined in the given ontology
      Parameters:
      ontology - the given ontology
      name - the name of the member
      Returns:
      a member with the given name if found; otherwise null
    • getMemberByIri

      public static Member getMemberByIri(Ontology ontology, String iri)
      Gets a member with the given IRI defined by the given ontology or its imports
      Parameters:
      ontology - the given ontology
      iri - the IRI of the member
      Returns:
      a member with the given IRI if found; otherwise null
    • getMemberByIri

      public static Member getMemberByIri(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, String iri)
      Gets a member with the given IRI in the given resource set
      Parameters:
      resourceSet - The resource set to look for an ontology in
      iri - The IRI of the member
      Returns:
      a member with the given IRI if found; otherwise null
    • getMemberByAbbreviatedIri

      public static Member getMemberByAbbreviatedIri(Ontology ontology, String iri)
      Gets a member with the given abbreviated IRI defined by the given ontology or its imports
      Parameters:
      ontology - the given ontology
      iri - the abbreviated IRI of the member
      Returns:
      a member with the given abbreviated IRI if found; otherwise null
    • getMemberByAbbreviatedIri

      public static Member getMemberByAbbreviatedIri(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, String iri)
      Gets a member with the given abbreviated IRI in the given resource set
      Parameters:
      resourceSet - The resource set to look for an ontology in
      iri - The abbreviated IRI of the member
      Returns:
      a member with the given abbreviated IRI if found; otherwise null
    • getMemberByResolvingIri

      public static Member getMemberByResolvingIri(org.eclipse.emf.ecore.resource.Resource context, String iri)
      Gets a member with the given IRI that can be resolved in the context of the given resource This will cause the member's ontology resource to load if not already loaded
      Parameters:
      context - The resource to look for the member in
      iri - The IRI of the member
      Returns:
      A member if one exists with the given IRI; otherwise null
    • getPrefixIn

      public static String getPrefixIn(Ontology ontology, Ontology context)
      Gets the prefix of a given ontology in a given context ontology If both ontologies are the same, the ontology's prefix will be returned; otherwise if the ontology is imported, its import prefix will be returned if specified; otherwise null will be returned.
      Parameters:
      ontology - the given ontology
      context - the context ontology
      Returns:
      ontology's prefix in context or null
    • getAbbreviatedIriIn

      public static String getAbbreviatedIriIn(Member member, Ontology context)
      Gets the abbreviated IRI of the given member in the given context ontology
      Parameters:
      member - the given member
      context - the given context ontology
      Returns:
      the abbreviated IRI of the given reference in the given context ontology
    • getStatements

      public static List<Statement> getStatements(Ontology ontology)
      Gets all statements of the given ontology
      Parameters:
      ontology - the given ontology
      Returns:
      a list of all statements of the given ontology
    • getRefs

      public static List<Member> getRefs(Ontology ontology)
      Gets all refs defined in a given ontology
      Parameters:
      ontology - the given ontology
      Returns:
      a list of all refs defined in the given ontology
    • getAnnotationValues

      public static List<Element> getAnnotationValues(IdentifiedElement element, AnnotationProperty property)
      Gets the values of a given annotation property in the given element
      Parameters:
      element - The given element
      property - the given annotation property
      Returns:
      a list of annotation values
    • getAnnotationLiteralValue

      public static Literal getAnnotationLiteralValue(IdentifiedElement element, AnnotationProperty property)
      Gets the first literal value of a given annotation property in the given element
      Parameters:
      element - The given element
      property - the given annotation property
      Returns:
      an annotation literal value
    • isAnnotatedBy

      public static boolean isAnnotatedBy(IdentifiedElement element, AnnotationProperty property)
      Determines whether the given element is annotated with the given annotation property
      Parameters:
      element - The given element
      property - the given annotation property
      Returns:
      true if the element is annotated with the given annotation property; otherwise false
    • getAnnotationReferencedValue

      public static Member getAnnotationReferencedValue(IdentifiedElement element, AnnotationProperty property)
      Gets the first referenced value of a given annotation property in the given element
      Parameters:
      element - The given element
      property - the given annotation property
      Returns:
      an annotation reference value
    • getSuperTerms

      public static List<Term> getSuperTerms(Term term)
      Gets the super terms of the given term
      Parameters:
      term - the give term
      Returns:
      a list of specialization super terms of the given term
    • getSpecializationSuperTerms

      public static List<Term> getSpecializationSuperTerms(Term term)
      Gets the specialization super terms of the given term
      Parameters:
      term - the give term
      Returns:
      a list of specialization super terms of the given term
    • getEquivalenceSuperClassifiers

      public static List<Classifier> getEquivalenceSuperClassifiers(Classifier classifier)
      Gets the equivalence super classifiers of the given classifier
      Parameters:
      classifier - the given classifier
      Returns:
      a list of equivalence super classifiers of the given classifier
    • getEquivalenceSuperScalars

      public static List<Scalar> getEquivalenceSuperScalars(Scalar scalar)
      Gets the equivalence super scalars of the given scalar
      Parameters:
      scalar - the given scalar
      Returns:
      a list of equivalence super scalars of the given scalar
    • getEquivalenceSuperProperties

      public static List<Property> getEquivalenceSuperProperties(Property property)
      Gets the equivalence super properties of the given property
      Parameters:
      property - the given property
      Returns:
      a list of equivalence super properties of the given property
    • getAxioms

      public static List<Axiom> getAxioms(SpecializableTerm term)
      Gets all the axioms specified on the given term
      Parameters:
      term - the given term
      Returns:
      a list of axioms specified on the given term
    • getNumberOfFacets

      public static int getNumberOfFacets(ScalarEquivalenceAxiom axiom)
      Gets the number of facets defined on the given scalar equivalence axiom
      Parameters:
      axiom - the given axiom
      Returns:
      the number of facets defined on the given scalar equivalence axiom
    • getTerm

      public static Term getTerm(Predicate predicate)
      Gets the term that is bound by the given predicate
      Parameters:
      predicate - the given predicate
      Returns:
      the term that is bound by the predicate
    • isStandardScalar

      public static boolean isStandardScalar(Scalar scalar)
      Determines if the given scalar is a standard one
      Parameters:
      scalar - the given scalar
      Returns:
      whether the scalar is standard
    • getAssertions

      public static List<Assertion> getAssertions(Instance instance)
      Gets all the assertions owned by the given instance
      Parameters:
      instance - the given instance
      Returns:
      a list of assertions owned by the given instance
    • getPropertyValues

      public static List<Element> getPropertyValues(Instance instance, SemanticProperty property)
      Gets the values of the given semantic property in the given instance
      Parameters:
      instance - The given instance
      property - the given semantic property
      Returns:
      a list of elements representing the property values
    • getPropertyLiteralValue

      public static Literal getPropertyLiteralValue(Instance instance, ScalarProperty property)
      Gets the first literal value of the given scalar property in the given instance
      Parameters:
      instance - The given instance
      property - the given semantic property
      Returns:
      a literal representing the property's literal value
    • getPropertyContainedValue

      public static StructureInstance getPropertyContainedValue(Instance instance, StructuredProperty property)
      Gets the first contained value of the given structured property in the given instance
      Parameters:
      instance - The given instance
      property - the given property
      Returns:
      a structure instance representing the property's contained value
    • getPropertyReferencedValue

      public static NamedInstance getPropertyReferencedValue(Instance instance, Relation relation)
      Gets the first referenced value of the given relation in the given instance
      Parameters:
      instance - The given instance
      relation - the given relation
      Returns:
      a named instance representing the relation's referenced value
    • getTypes

      public static List<Classifier> getTypes(Instance instance)
      Gets the types declared on the given instance
      Parameters:
      instance - the given instance
      Returns:
      a list of types of the given element
    • getJavaValue

      public static Object getJavaValue(Literal literal)
      Gets the Java Object value of the given literal
      Parameters:
      literal - The given literal
      Returns:
      Object representing value of literal
    • getType

      public static Scalar getType(Literal literal)
      Gets the type of the given literal
      Parameters:
      literal - the given literal
      Returns:
      the scalar type of the given literal
    • isEqual

      public static boolean isEqual(Literal literal1, Literal literal2)
      Determins if the two given literals are equal
      Parameters:
      literal1 - the first given literal
      literal2 - the second given literal
      Returns:
      true if equivalent; otherwise false