Package io.opencaesar.oml.util
Class OmlRead
java.lang.Object
io.opencaesar.oml.util.OmlRead
The Read API for the model. It complements the OML getter API by additional utilities.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <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 rootstatic String
getAbbreviatedIriIn
(Member member, Ontology context) Gets the abbreviated IRI of the given member in the given context ontologystatic Literal
getAnnotationLiteralValue
(IdentifiedElement element, AnnotationProperty property) Gets the first literal value of a given annotation property in the given elementstatic Member
getAnnotationReferencedValue
(IdentifiedElement element, AnnotationProperty property) Gets the first referenced value of a given annotation property in the given elementgetAnnotationValues
(IdentifiedElement element, AnnotationProperty property) Gets the values of a given annotation property in the given elementgetAssertions
(Instance instance) Gets all the assertions owned by the given instancegetAxioms
(SpecializableTerm term) Gets all the axioms specified on the given termstatic List<Classifier>
getEquivalenceSuperClassifiers
(Classifier classifier) Gets the equivalence super classifiers of the given classifiergetEquivalenceSuperProperties
(Property property) Gets the equivalence super properties of the given propertygetEquivalenceSuperScalars
(Scalar scalar) Gets the equivalence super scalars of the given scalargetImportedOntologies
(Ontology ontology) Gets the ontologies directly imported by a given ontology This will cause an imported ontology's resource to load if not already loadedstatic 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 loadedstatic 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 loadedstatic 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 loadedstatic 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 loadedstatic Collection<Ontology>
getImportingOntologies
(Ontology ontology) Gets loaded ontologies that directly import the given ontologystatic Ontology
getImportingOntology
(Import _import) Gets the ontology that owns the given importgetImportNamespaceToPrefixMap
(Ontology ontology) Gets a map from import namespaces to import prefixes in the given ontologygetImportPrefixToNamespaceMap
(Ontology ontology) Gets a map from import prefixes to import namespaces in the given ontologystatic 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 loadedstatic Object
getJavaValue
(Literal literal) Gets the Java Object value of the given literalstatic Member
getMemberByAbbreviatedIri
(Ontology ontology, String iri) Gets a member with the given abbreviated IRI defined by the given ontology or its importsstatic Member
getMemberByAbbreviatedIri
(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, String iri) Gets a member with the given abbreviated IRI in the given resource setstatic Member
getMemberByIri
(Ontology ontology, String iri) Gets a member with the given IRI defined by the given ontology or its importsstatic Member
getMemberByIri
(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, String iri) Gets a member with the given IRI in the given resource setstatic Member
getMemberByName
(Ontology ontology, String name) Gets a member with the given name defined in the given ontologystatic 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 loadedgetMembers
(Ontology ontology) Gets all members defined in the given ontologystatic int
Gets the number of facets defined on the given scalar equivalence axiomgetOntologies
(org.eclipse.emf.ecore.resource.ResourceSet resourceSet) Gets all ontologies loaded in the given resource setstatic Ontology
getOntology
(org.eclipse.emf.ecore.resource.Resource resource) Gets the ontology loaded in the given OML resource (if one exists)static Ontology
getOntologyByIri
(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, String iri) Gets an ontology with the given IRI loaded in the given resource setstatic 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 returnedstatic 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 loadedstatic 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.static StructureInstance
getPropertyContainedValue
(Instance instance, StructuredProperty property) Gets the first contained value of the given structured property in the given instancestatic Literal
getPropertyLiteralValue
(Instance instance, ScalarProperty property) Gets the first literal value of the given scalar property in the given instancestatic NamedInstance
getPropertyReferencedValue
(Instance instance, Relation relation) Gets the first referenced value of the given relation in the given instancegetPropertyValues
(Instance instance, SemanticProperty property) Gets the values of the given semantic property in the given instanceGets all refs defined in a given ontologystatic 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.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 resourceGets the specialization super terms of the given termgetStatements
(Ontology ontology) Gets all statements of the given ontologygetSuperTerms
(Term term) Gets the super terms of the given termstatic Term
Gets the term that is bound by the given predicatestatic Scalar
Gets the type of the given literalstatic List<Classifier>
Gets the types declared on the given instancestatic boolean
isAnnotatedBy
(IdentifiedElement element, AnnotationProperty property) Determines whether the given element is annotated with the given annotation propertystatic boolean
Determins if the two given literals are equalstatic <T,
V extends T>
booleanisInClosure
(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 rootstatic boolean
isResolvedUri
(org.eclipse.emf.common.util.URI uri) Determines whether the given URI can be resolved to an OML resource in the workspacestatic boolean
isStandardScalar
(Scalar scalar) Determines if the given scalar is a standard one
-
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 fromincludeRoot
- whether to include the root in the closure resultsrecursive
- 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 forroot
- the given root to start the recursion fromincludeRoot
- whether to include the root in the closurerecursive
- 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 resolutioniri
- 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
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
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 iniri
- 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 inprefix
- 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 resolutioniri
- The IRI of the ontology to get- Returns:
- an ontology with the given IRI
-
getImportedOntologies
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
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 ontologyiri
- the IRI of the imported ontology- Returns:
- an ontology that is imported by the given IRI; otherwise null
-
getImportedOntologyByPrefix
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 ontologyprefix
- the prefix of the imported ontology- Returns:
- an ontology that is imported by the given prefix; otherwise null
-
getImportedOntologyClosure
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 ontologyinclusive
- whether the given ontology should be included in the closure- Returns:
- a collection of ontologies directly or transitively imported by the given ontology
-
getImportingOntologies
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
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
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
Gets the ontology that owns the given import- Parameters:
_import
- the given import- Returns:
- the ontology that defines the given import
-
getImportNamespaceToPrefixMap
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
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
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
Gets a member with the given name defined in the given ontology- Parameters:
ontology
- the given ontologyname
- the name of the member- Returns:
- a member with the given name if found; otherwise null
-
getMemberByIri
Gets a member with the given IRI defined by the given ontology or its imports- Parameters:
ontology
- the given ontologyiri
- 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 iniri
- The IRI of the member- Returns:
- a member with the given IRI if found; otherwise null
-
getMemberByAbbreviatedIri
Gets a member with the given abbreviated IRI defined by the given ontology or its imports- Parameters:
ontology
- the given ontologyiri
- 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 iniri
- 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 iniri
- The IRI of the member- Returns:
- A member if one exists with the given IRI; otherwise null
-
getPrefixIn
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 ontologycontext
- the context ontology- Returns:
- ontology's prefix in context or null
-
getAbbreviatedIriIn
Gets the abbreviated IRI of the given member in the given context ontology- Parameters:
member
- the given membercontext
- the given context ontology- Returns:
- the abbreviated IRI of the given reference in the given context ontology
-
getStatements
Gets all statements of the given ontology- Parameters:
ontology
- the given ontology- Returns:
- a list of all statements of the given ontology
-
getRefs
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 elementproperty
- 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 elementproperty
- the given annotation property- Returns:
- an annotation literal value
-
isAnnotatedBy
Determines whether the given element is annotated with the given annotation property- Parameters:
element
- The given elementproperty
- 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 elementproperty
- the given annotation property- Returns:
- an annotation reference value
-
getSuperTerms
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
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
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
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
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
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
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
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
Determines if the given scalar is a standard one- Parameters:
scalar
- the given scalar- Returns:
- whether the scalar is standard
-
getAssertions
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
Gets the values of the given semantic property in the given instance- Parameters:
instance
- The given instanceproperty
- the given semantic property- Returns:
- a list of elements representing the property values
-
getPropertyLiteralValue
Gets the first literal value of the given scalar property in the given instance- Parameters:
instance
- The given instanceproperty
- 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 instanceproperty
- the given property- Returns:
- a structure instance representing the property's contained value
-
getPropertyReferencedValue
Gets the first referenced value of the given relation in the given instance- Parameters:
instance
- The given instancerelation
- the given relation- Returns:
- a named instance representing the relation's referenced value
-
getTypes
Gets the types declared on the given instance- Parameters:
instance
- the given instance- Returns:
- a list of types of the given element
-
getJavaValue
Gets the Java Object value of the given literal- Parameters:
literal
- The given literal- Returns:
- Object representing value of literal
-
getType
Gets the type of the given literal- Parameters:
literal
- the given literal- Returns:
- the scalar type of the given literal
-
isEqual
Determins if the two given literals are equal- Parameters:
literal1
- the first given literalliteral2
- the second given literal- Returns:
- true if equivalent; otherwise false
-