コード例 #1
0
 @Override
 @Test
 public void testEqualsNegative() throws Exception {
   OWLClassExpression a = Class(createIRI());
   OWLClassExpression b = Class(createIRI());
   OWLObject objA = EquivalentClasses(a, b);
   OWLClassExpression c = Class(createIRI());
   OWLObject objB = EquivalentClasses(a, b, c);
   assertFalse(objA.equals(objB));
 }
コード例 #2
0
 @Override
 @Test
 public void testHashCode() throws Exception {
   OWLClassExpression a = Class(createIRI());
   OWLClassExpression b = Class(createIRI());
   OWLClassExpression c = Class(createIRI());
   OWLObject objA = EquivalentClasses(a, b, c);
   OWLObject objB = EquivalentClasses(a, b, c);
   assertEquals(objA.hashCode(), objB.hashCode());
 }
コード例 #3
0
 private int countResult(QuestOWLResultSet rs, boolean stdout) throws OWLException {
   int counter = 0;
   while (rs.nextRow()) {
     counter++;
     if (stdout) {
       for (int column = 1; column <= rs.getColumCount(); column++) {
         OWLObject binding = rs.getOWLObject(column);
         System.out.print(binding.toString() + ", ");
       }
       System.out.print("\n");
     }
   }
   return counter;
 }
  private int executeQuery(String q) throws OWLException {
    String prefix =
        "PREFIX : <http://it.unibz.krdb/obda/ontologies/quest-typing-test.owl#> \n PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> \n PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>";
    String query = prefix + " " + q;

    QuestOWLResultSet res = st.executeTuple(query);
    int count = 0;
    int columns = res.getColumCount();
    while (res.nextRow()) {
      for (int i = 0; i < columns; i++) {
        OWLObject o = res.getOWLObject(i + 1);
        System.out.println(o.toString());
      }
      count += 1;
    }
    res.close();
    return count;
  }
コード例 #5
0
  public ATermAppl term(OWLObject d) {
    refreshCheck();

    visitor.reset();
    visitor.setAddAxiom(false);
    d.accept(visitor);

    ATermAppl a = visitor.result();

    if (a == null) throw new InternalReasonerException("Cannot create ATerm from description " + d);

    return a;
  }
コード例 #6
0
 private Set<OWLAnnotationAssertionAxiom> writeEntityStart(
     ManchesterOWLSyntax keyword, OWLObject entity) {
   event = new RendererEvent(this, entity);
   String kw = keyword.toString();
   fireFrameRenderingPrepared(kw);
   writeSection(keyword);
   entity.accept(this);
   fireFrameRenderingStarted(kw);
   writeNewLine();
   incrementTab(4);
   writeNewLine();
   if (entity instanceof OWLEntity) {
     return writeAnnotations(((OWLEntity) entity).getIRI());
   } else if (entity instanceof OWLAnonymousIndividual) {
     return writeAnnotations((OWLAnonymousIndividual) entity);
   }
   return Collections.emptySet();
 }
コード例 #7
0
  public void writeSection(
      ManchesterOWLSyntax keyword,
      Collection<?> content,
      String delimeter,
      boolean newline,
      OWLOntology... ontologiesList) {

    String sec = keyword.toString();
    if (!content.isEmpty() || renderingDirector.renderEmptyFrameSection(keyword, ontologiesList)) {
      fireSectionRenderingPrepared(sec);
      writeSection(keyword);
      writeOntologiesList(ontologiesList);
      incrementTab(4);
      writeNewLine();
      fireSectionRenderingStarted(sec);
      for (Iterator<?> it = content.iterator(); it.hasNext(); ) {
        Object obj = it.next();
        fireSectionItemPrepared(sec);
        if (obj instanceof OWLObject) {
          ((OWLObject) obj).accept(this);
        } else {
          write(obj.toString());
        }
        if (it.hasNext()) {
          write(delimeter);
          fireSectionItemFinished(sec);
          if (newline) {
            writeNewLine();
          }
        } else {
          fireSectionItemFinished(sec);
        }
      }
      fireSectionRenderingFinished(sec);
      popTab();
      writeNewLine();
      writeNewLine();
    }
  }
コード例 #8
0
 @Override
 public void visit(OWLEquivalentClassesAxiom axiom) {
   if (axiom.getClassExpressions().size() > 2) {
     Set<Set<OWLClassExpression>> rendered = new HashSet<Set<OWLClassExpression>>();
     for (OWLClassExpression left : axiom.getClassExpressions()) {
       for (OWLClassExpression right : axiom.getClassExpressions()) {
         if (left != right) {
           Set<OWLClassExpression> cur = CollectionFactory.createSet(left, right);
           if (!rendered.contains(cur)) {
             rendered.add(cur);
             left.accept(this);
             writeSpace();
             write(EQUIV);
             writeSpace();
             right.accept(this);
           }
         }
       }
     }
   } else if (axiom.getClassExpressions().size() == 2) {
     Iterator<OWLClassExpression> it = axiom.getClassExpressions().iterator();
     OWLClassExpression descA = it.next();
     OWLClassExpression descB = it.next();
     OWLClassExpression lhs;
     OWLClassExpression rhs;
     if (subject.equals(descA)) {
       lhs = descA;
       rhs = descB;
     } else {
       lhs = descB;
       rhs = descA;
     }
     lhs.accept(this);
     writeSpace();
     write(EQUIV);
     writeSpace();
     rhs.accept(this);
   }
 }
コード例 #9
0
  public void writeSection(
      ManchesterOWLSyntax keyword,
      SectionMap content,
      String delimeter,
      boolean newline,
      OWLOntology... ontologiesList) {
    String sec = keyword.toString();
    if (!content.isEmpty() || renderingDirector.renderEmptyFrameSection(keyword, ontologiesList)) {
      fireSectionRenderingPrepared(sec);
      writeSection(keyword);
      writeOntologiesList(ontologiesList);
      incrementTab(4);
      writeNewLine();
      fireSectionRenderingStarted(sec);
      for (Iterator<?> it = content.getSectionObjects().iterator(); it.hasNext(); ) {
        Object obj = it.next();
        Set<Set<OWLAnnotation>> annotationSets = content.getAnnotationsForSectionObject(obj);
        for (Iterator<Set<OWLAnnotation>> annosSetIt = annotationSets.iterator();
            annosSetIt.hasNext(); ) {
          Set<OWLAnnotation> annos = annosSetIt.next();
          fireSectionItemPrepared(sec);
          if (!annos.isEmpty()) {
            incrementTab(4);
            writeNewLine();
            write(ManchesterOWLSyntax.ANNOTATIONS.toString());
            write(": ");
            pushTab(getIndent() + 1);
            for (Iterator<OWLAnnotation> annoIt = annos.iterator(); annoIt.hasNext(); ) {
              annoIt.next().accept(this);
              if (annoIt.hasNext()) {
                write(", ");
                writeNewLine();
              }
            }
            popTab();
            popTab();
            writeNewLine();
          }
          // Write actual object
          if (obj instanceof OWLObject) {
            ((OWLObject) obj).accept(this);
          } else if (obj instanceof Collection) {
            for (Iterator<?> listIt = ((Collection<?>) obj).iterator(); listIt.hasNext(); ) {
              Object o = listIt.next();
              if (o instanceof OWLObject) {
                ((OWLObject) o).accept(this);
              } else {
                write(o.toString());
              }
              if (listIt.hasNext()) {
                write(delimeter);
                if (newline) {
                  writeNewLine();
                }
              }
            }

          } else {
            write(obj.toString());
          }
          if (it.hasNext()) {
            write(delimeter);
            fireSectionItemFinished(sec);
            if (newline) {
              writeNewLine();
            }
          } else {
            fireSectionItemFinished(sec);
          }

          if (annosSetIt.hasNext()) {
            write(",");
            writeNewLine();
          }
        }
      }
      fireSectionRenderingFinished(sec);
      popTab();
      writeNewLine();
      writeNewLine();
    }
  }
コード例 #10
0
 /**
  * @param object the object to duplicate
  * @return the duplicate
  */
 @SuppressWarnings("unchecked")
 public <O extends OWLObject> O duplicateObject(OWLObject object) {
   object.accept(this);
   return (O) obj;
 }
コード例 #11
0
 private void process(Set<? extends OWLObject> objects) {
   for (OWLObject obj : objects) {
     obj.accept(this);
   }
 }
コード例 #12
0
 /**
  * A convenience method that obtains the components of an OWL object. Note that by definition, the
  * components of the object include the object itself.
  *
  * @param object The object whose components are to be obtained.
  * @return The component of the specified object.
  */
 public Set<OWLObject> getComponents(OWLObject object) {
   result.clear();
   object.accept(this);
   return new HashSet<OWLObject>(result);
 }
コード例 #13
0
ファイル: ALCRenderer.java プロジェクト: jmayaalv/mapo
 /*
  * (non-Javadoc)
  *
  * @see
  * org.semanticweb.owlapi.io.OWLObjectRenderer#render(org.semanticweb.owlapi
  * .model.OWLObject)
  */
 @Override
 public String render(OWLObject object) {
   object.accept(this);
   return sb.toString();
 }
コード例 #14
0
 public int getTypeIndex(OWLObject object) {
   object.accept(this);
   return type;
 }
コード例 #15
0
 private void writeNested(OWLObject expression) {
   expression.accept(this);
 }