RelatedObjectsHelper { protected static Set<OWLAnnotation> getAnnotations( OWLOntology ontology, IOHelper ioHelper, String annotation) throws Exception { String propertyID = annotation.split("=")[0]; IRI propertyIRI = ioHelper.createIRI(propertyID); if (propertyIRI == null) { throw new IllegalArgumentException( String.format(invalidIRIError, "annotation property", propertyID)); } OWLAnnotationProperty annotationProperty = df.getOWLAnnotationProperty(propertyIRI); String value = annotation.split("=")[1]; if (value.startsWith("@")) { String lang = value.substring(1); return getLangAnnotations(ontology, annotationProperty, lang); } else if (value.startsWith("^^")) { String datatypeString = value.substring(2).replace("<", "").replace(">", ""); IRI datatypeIRI = ioHelper.createIRI(datatypeString); OWLDatatype datatype = df.getOWLDatatype(datatypeIRI); return getTypedAnnotations(ontology, annotationProperty, datatype); } else if (value.contains("<") && value.contains(">") && !value.contains("^^")) { String valueID = value.substring(1, value.length() - 1); IRI valueIRI = ioHelper.createIRI(valueID); if (valueIRI == null) { throw new IllegalArgumentException( String.format(invalidIRIError, "annotation value (IRI)", valueID)); } return Sets.newHashSet(df.getOWLAnnotation(annotationProperty, valueIRI)); } else if (value.contains("~'")) { return getPatternAnnotations(ontology, annotationProperty, value); } else if (value.contains("'")) { return Sets.newHashSet(getLiteralAnnotation(ioHelper, annotationProperty, value)); } else { IRI valueIRI = ioHelper.createIRI(value); if (valueIRI == null) { throw new IllegalArgumentException( String.format(invalidIRIError, "annotation value (CURIE)", value)); } return Sets.newHashSet(df.getOWLAnnotation(annotationProperty, valueIRI)); } }  static Set<OWLAxiom> getAnnotationAxioms(OWLOntology ontology, Set<OWLObject> objects); static Set<OWLAxiom> filterAxioms(
      Set<OWLAxiom> inputAxioms,
      Set<OWLObject> objects,
      List<String> axiomSelectors,
      List<String> baseNamespaces,
      boolean partial,
      boolean namedOnly); static Set<OWLAxiom> filterAxiomsByAxiomType(
      Set<OWLAxiom> axioms,
      Set<OWLObject> objects,
      Set<Class<? extends OWLAxiom>> axiomTypes,
      boolean partial,
      boolean namedOnly); static Set<OWLAxiom> filterCompleteAxioms(
      Set<OWLAxiom> inputAxioms,
      Set<OWLObject> objects,
      Set<Class<? extends OWLAxiom>> axiomTypes,
      boolean namedOnly); static Set<OWLAxiom> filterExternalAxioms(
      Set<OWLAxiom> axioms, List<String> baseNamespaces); static Set<OWLAxiom> filterInternalAxioms(
      Set<OWLAxiom> axioms, List<String> baseNamespaces); static Set<OWLAxiom> filterPartialAxioms(
      Set<OWLAxiom> inputAxioms,
      Set<OWLObject> objects,
      Set<Class<? extends OWLAxiom>> axiomTypes,
      boolean namedOnly); static Set<OWLAxiom> filterTautologicalAxioms(Set<OWLAxiom> axioms, boolean structural); @Deprecated static Set<OWLAxiom> getAxioms(
      OWLOntology ontology,
      Set<OWLObject> objects,
      Set<Class<? extends OWLAxiom>> axiomTypes,
      boolean partial,
      boolean signature); static Set<Class<? extends OWLAxiom>> getAxiomValues(String axiomSelector); static Set<OWLAxiom> getCompleteAxioms(
      OWLOntology ontology, Set<OWLObject> objects, Set<Class<? extends OWLAxiom>> axiomTypes); static Set<OWLAxiom> getCompleteAxioms(
      OWLOntology ontology,
      Set<OWLObject> objects,
      Set<Class<? extends OWLAxiom>> axiomTypes,
      boolean namedOnly); static Set<OWLAxiom> getPartialAxioms(
      OWLOntology ontology, Set<OWLObject> objects, Set<Class<? extends OWLAxiom>> axiomTypes); static Set<OWLAxiom> getPartialAxioms(
      OWLOntology ontology,
      Set<OWLObject> objects,
      Set<Class<? extends OWLAxiom>> axiomTypes,
      boolean namedOnly); static Set<OWLObject> selectGroups(
      OWLOntology ontology,
      IOHelper ioHelper,
      Set<OWLObject> objects,
      List<List<String>> selectorGroups); static Set<OWLObject> select(
      OWLOntology ontology, IOHelper ioHelper, Set<OWLObject> objects, List<String> selectors); static Set<OWLObject> select(
      OWLOntology ontology, IOHelper ioHelper, Set<OWLObject> objects, String selector); static Set<OWLObject> selectAncestors(OWLOntology ontology, Set<OWLObject> objects); static Set<OWLObject> selectAnnotationProperties(Set<OWLObject> objects); static Set<OWLObject> selectAnonymous(Set<OWLObject> objects); static Set<OWLObject> selectChildren(OWLOntology ontology, Set<OWLObject> objects); static Set<OWLObject> selectClasses(Set<OWLObject> objects); static Set<OWLObject> selectComplement(OWLOntology ontology, Set<OWLObject> objects); static Set<OWLObject> selectCURIE(
      IOHelper ioHelper, Set<OWLObject> objects, String selector); static Set<OWLObject> selectDataProperties(Set<OWLObject> objects); static Set<OWLObject> selectDescendants(OWLOntology ontology, Set<OWLObject> objects); static Set<OWLObject> selectDomains(OWLOntology ontology, Set<OWLObject> objects); static Set<OWLObject> selectEquivalents(OWLOntology ontology, Set<OWLObject> objects); static Set<OWLObject> selectIndividuals(Set<OWLObject> objects); static Set<OWLObject> selectInstances(OWLOntology ontology, Set<OWLObject> objects); static Set<OWLObject> selectIRI(Set<OWLObject> objects, String selector); static Set<OWLObject> selectNamed(Set<OWLObject> objects); static Set<OWLObject> selectObjectProperties(Set<OWLObject> objects); static Set<OWLObject> selectParents(OWLOntology ontology, Set<OWLObject> objects); static Set<OWLObject> selectPattern(
      OWLOntology ontology, IOHelper ioHelper, Set<OWLObject> objects, String annotationPattern); static Set<OWLObject> selectProperties(Set<OWLObject> objects); static Set<OWLObject> selectRanges(OWLOntology ontology, Set<OWLObject> objects); static Set<OWLObject> selectTypes(OWLOntology ontology, Set<OWLObject> objects); static Set<OWLAxiom> spanGaps(OWLOntology ontology, Set<OWLObject> objects); static Set<OWLAxiom> spanGaps(
      OWLOntology ontology, Set<OWLObject> objects, boolean excludeAnonymous);  }
@Test public void testGetAnnotationByExactLangValue() throws Exception { IOHelper ioHelper = new IOHelper(); OWLOntology ontology = getOntology(); String select = "rdfs:label='English label'@en"; Set<OWLAnnotation> annotations = RelatedObjectsHelper.getAnnotations(ontology, ioHelper, select); assertEquals(1, annotations.size()); assertEquals(annotations.iterator().next(), annotation1); }
@Test public void testGetAnnotationByLangTag() throws Exception { IOHelper ioHelper = new IOHelper(); OWLOntology ontology = getOntology(); String select = "rdfs:label=@en"; Set<OWLAnnotation> annotations = RelatedObjectsHelper.getAnnotations(ontology, ioHelper, select); assertEquals(1, annotations.size()); assertEquals(annotations.iterator().next(), annotation1); }
@Test public void testGetAnnotationByExactDatatypeValue() throws Exception { IOHelper ioHelper = new IOHelper(); OWLOntology ontology = getOntology(); String select = "rdfs:comment='comment 1'^^<http: Set<OWLAnnotation> annotations = RelatedObjectsHelper.getAnnotations(ontology, ioHelper, select); assertEquals(1, annotations.size()); assertEquals(annotations.iterator().next(), annotation3); }
@Test public void testGetAnnotationByDatatype() throws Exception { IOHelper ioHelper = new IOHelper(); OWLOntology ontology = getOntology(); String select = "rdfs:comment=^^<http: Set<OWLAnnotation> annotations = RelatedObjectsHelper.getAnnotations(ontology, ioHelper, select); assertEquals(1, annotations.size()); assertEquals(annotations.iterator().next(), annotation3); }
@Test public void testGetAnnotationByRegex() throws Exception { IOHelper ioHelper = new IOHelper(); OWLOntology ontology = getOntology(); String select = "rdfs:label=~'^.*label$'"; Set<OWLAnnotation> annotations = RelatedObjectsHelper.getAnnotations(ontology, ioHelper, select); assertEquals(2, annotations.size()); assertTrue(annotations.contains(annotation1)); assertTrue(annotations.contains(annotation2)); }