Skip to content

Commit

Permalink
ont-api: cosmetic changes (rename vocabulary & change javadocs for se…
Browse files Browse the repository at this point in the history
…veral classes, etc)
  • Loading branch information
sszuev committed Mar 21, 2023
1 parent f56b71f commit 33646b6
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
* Also, please note that although ONT-API supports the ability to change data simultaneously through both interfaces,
* this is not always correct: an {@link Ontology} impls use caches,
* and switching back and forth could flush these caches, which may degrade performance.
* <p>
* Created by szuev on 24.10.2016.
* @see <a href="https://github.com/owlcs/owlapi/blob/version5/api/src/main/java/org/semanticweb/owlapi/model/OWLOntology.java">org.semanticweb.owlapi.model.OWLOntology</a>
*/
public interface Ontology extends OWLOntology {

Expand All @@ -55,6 +54,9 @@ public interface Ontology extends OWLOntology {
* then the method {@link #clearCache()} may help.
* Also note: any changes in the RDF-view will reset the internal cache,
* that means next attempt to retrieve data from axiomatic view (i.e. list axioms) will take the same time as the very first one.
* <p>
* Note that returning {@code OntModel} is not thread-safe even with {@code ReadWriteLock} (see <a href="https://github.com/owlcs/ont-api/issues/46">issue #46</a>).
* But {@code asGraphModel().getGraph()} and {@code asGraphModel().getBaseGraph()} are thread-safe.
*
* @return {@link OntModel Ontology RDF Graph Model}, not {@code null}
* @see org.apache.jena.graph.Graph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* The ontology building and loading factory, the 'core' - the main point to create and load ontologies.
* See also base interface {@link OWLOntologyFactory} and its single implementation
* <a href="https://github.com/owlcs/owlapi/blob/version5/impl/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLOntologyFactoryImpl.java">uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl</a> in the OWLAPI-impl module.
* It is also an outer class for any {@link OWLOntologyCreationException}s sub-classes, which may occur during loading.
* It is also an outer class for any {@link OWLOntologyCreationException}s subclasses, which may occur during loading.
* <p>
* Created by szuev on 24.10.2016.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@
* <li>{@link #getGraphModel(String, String)}</li>
* <li>{@link #getDocumentSourceMappers()} - since 1.3.0</li>
* </ul>
* <p>
* Created by szuev on 24.10.2016.
* @see <a href="https://github.com/owlcs/owlapi/blob/version5/api/src/main/java/org/semanticweb/owlapi/model/OWLOntologyManager.java">org.semanticweb.owlapi.model.OWLOntologyManager</a>
*/
@ParametersAreNonnullByDefault
public interface OntologyManager extends OWLOntologyManager {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.text.MessageFormat;
import java.util.Objects;
Expand All @@ -33,22 +32,6 @@
*/
class ReflectionUtils {

/**
* Finds a static method by the class and its name.
*
* @param clazz {@link Class}
* @param name String name
* @return {@link Method}
* @throws OntApiException if no method is found
*/
static Method findStaticMethod(Class<?> clazz, String name) throws OntApiException {
try {
return clazz.getMethod(name);
} catch (NoSuchMethodException e) {
throw new OntApiException("Can't find method '" + name + "' in " + clazz, e);
}
}

/**
* Returns a proxy instance that implements {@code interfaceType} by dispatching method
* invocations to {@code handler}.
Expand Down Expand Up @@ -110,7 +93,8 @@ static <R> R newInstance(Class<? extends R> interfaceType,
static <R> R newInstance(Class<R> type) throws OntApiException {
try {
return type.getDeclaredConstructor().newInstance();
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException |
IllegalAccessException e) {
throw new OntApiException("Can't create instance of " + type.getName(), e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import com.github.owlcs.ontapi.jena.utils.Iterators;
import com.github.owlcs.ontapi.jena.vocabulary.OWL;
import com.github.owlcs.ontapi.transforms.vocabulary.AVC;
import com.github.owlcs.ontapi.transforms.vocabulary.ONTAPI;
import org.apache.jena.graph.Graph;
import org.apache.jena.rdf.model.Literal;
import org.apache.jena.rdf.model.Property;
Expand Down Expand Up @@ -113,7 +113,7 @@ protected boolean isAnnotationProperty(Resource candidate) {
}

protected boolean isIndividual(Resource candidate) {
return hasType(candidate, OWL.NamedIndividual) || hasType(candidate, AVC.AnonymousIndividual);
return hasType(candidate, OWL.NamedIndividual) || hasType(candidate, ONTAPI.AnonymousIndividual);
}

protected BaseDeclarator declareObjectProperty(Resource resource) {
Expand Down Expand Up @@ -153,7 +153,7 @@ protected BaseDeclarator declareIndividual(Resource resource) {
// test data from owl-api-contact contains such things also:
undeclare(resource, OWL.NamedIndividual);
// the temporary declaration:
declare(resource, AVC.AnonymousIndividual);
declare(resource, ONTAPI.AnonymousIndividual);
} else {
declare(resource, OWL.NamedIndividual);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.github.owlcs.ontapi.jena.vocabulary.OWL;
import com.github.owlcs.ontapi.jena.vocabulary.RDF;
import com.github.owlcs.ontapi.jena.vocabulary.SWRL;
import com.github.owlcs.ontapi.transforms.vocabulary.AVC;
import com.github.owlcs.ontapi.transforms.vocabulary.ONTAPI;
import org.apache.jena.graph.Graph;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.RDFList;
Expand Down Expand Up @@ -297,7 +297,7 @@ private ExtendedIterator<Resource> disjointIndividuals(Resource s) {

protected Set<Resource> collectForbiddenClassCandidates() {
Set<Resource> res = new HashSet<>(builtins.getSystemResources());
res.add(AVC.AnonymousIndividual);
res.add(ONTAPI.AnonymousIndividual);
res.removeAll(builtins.getBuiltinClasses());
return res;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import com.github.owlcs.ontapi.jena.vocabulary.OWL;
import com.github.owlcs.ontapi.jena.vocabulary.RDF;
import com.github.owlcs.ontapi.jena.vocabulary.XSD;
import com.github.owlcs.ontapi.transforms.vocabulary.AVC;
import com.github.owlcs.ontapi.transforms.vocabulary.DEPRECATED;
import com.github.owlcs.ontapi.transforms.vocabulary.ONTAPI;
import org.apache.jena.datatypes.RDFDatatype;
import org.apache.jena.datatypes.xsd.XSDDatatype;
import org.apache.jena.graph.Graph;
Expand Down Expand Up @@ -234,9 +234,9 @@ protected void fixDatatype(Resource r) {
.forEach(s -> {
RDFNode o = s.getObject();
if (o.isURIResource()) {
m.remove(s).add(s.getSubject(), OWL.onDatatype, s.getObject());
m.remove(s).add(s.getSubject(), OWL.onDatatype, o);
} else if (o.isAnon()) {
Resource auto = AVC.randomIRI().inModel(m);
Resource auto = ONTAPI.randomIRI().inModel(m);
m.remove(s).add(s.getSubject(), OWL.onDatatype, auto);
auto.addProperty(OWL.equivalentClass, o);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import com.github.owlcs.ontapi.jena.vocabulary.OWL;
import com.github.owlcs.ontapi.jena.vocabulary.RDF;
import com.github.owlcs.ontapi.transforms.vocabulary.AVC;
import com.github.owlcs.ontapi.transforms.vocabulary.ONTAPI;
import org.apache.jena.graph.Graph;
import org.apache.jena.graph.Triple;
import org.apache.jena.rdf.model.RDFNode;
Expand Down Expand Up @@ -89,7 +89,7 @@ public Stream<Triple> uncertainTriples() {
}

protected void finalActions() {
getWorkModel().removeAll(null, RDF.type, AVC.AnonymousIndividual);
getWorkModel().removeAll(null, RDF.type, ONTAPI.AnonymousIndividual);
// at times the ontology could contain some rdfs garbage,
// even if other transformers (OWLTransformer, RDFSTransformer) have been used.
listStatements(null, RDF.type, RDF.Property)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package com.github.owlcs.ontapi.transforms;

import com.github.owlcs.ontapi.jena.OntVocabulary;
import com.github.owlcs.ontapi.transforms.vocabulary.AVC;
import com.github.owlcs.ontapi.transforms.vocabulary.ONTAPI;
import org.apache.jena.graph.Graph;
import org.apache.jena.graph.Node;
import org.apache.jena.graph.Triple;
Expand Down Expand Up @@ -44,7 +44,7 @@
* Created by @szuev on 24.01.2018.
* <p>
* Note: this transform is slow - the complexity is ~O(n*log(n))
* @see AVC#error(String)
* @see ONTAPI#error(String)
*/
@SuppressWarnings("WeakerAccess")
public class RecursiveTransform extends TransformationModel {
Expand Down Expand Up @@ -158,7 +158,7 @@ public void perform() {
}

public Triple createReplacement(Triple base) {
return createReplacement(base, n -> AVC.error(n).asNode());
return createReplacement(base, n -> ONTAPI.error(n).asNode());
}

public Triple createReplacement(Triple base, UnaryOperator<Node> mapper) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* Vocabulary with (possible, temporary) resources used by ONT-API only.
* Might be moved to {@link com.github.owlcs.ontapi.jena.vocabulary} if necessary.
*/
public class AVC {
public class ONTAPI {
public final static String URI = "https://github.com/owlcs/ont-api";
public final static String NS = URI + "#";

Expand Down

0 comments on commit 33646b6

Please sign in to comment.