Example #1
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;
  }
 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();
 }
  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();
    }
  }
  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();
    }
  }
 /**
  * @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;
 }
 private void process(Set<? extends OWLObject> objects) {
   for (OWLObject obj : objects) {
     obj.accept(this);
   }
 }
 /**
  * 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);
 }
Example #8
0
 /*
  * (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();
 }
 public int getTypeIndex(OWLObject object) {
   object.accept(this);
   return type;
 }
 private void writeNested(OWLObject expression) {
   expression.accept(this);
 }