예제 #1
0
  /**
   * Returns <code>true</code> if the ontology obtained by parsing the URI is in OWL Full. Will
   * report findings to the reporter as it goes. Note that the inner workings of the validator
   * assume that the ontology has <strong>not</strong> already been parsed.
   *
   * @param uri an <code>URI</code> value
   * @return a <code>boolean</code> value
   */
  public boolean isOWLFull(URI uri) {
    /*
     * An ontology is OWL Full if:
     *
     * 1) There are OWL Full constructs used in the syntax, e.g. things have
     * not been explicitly typed
     *
     * or
     *
     * 2) The expressivity is Full.
     *
     */

    boolean result = false;
    try {
      /* Handler that doesn't care about OWLFullExceptions */
      syntaxLevel = LITE;
      OWLRDFErrorHandler handler =
          new OWLRDFErrorHandler() {
            public void owlFullConstruct(int code, String message) throws SAXException {
              /*
               * We know that there's some syntactic Full stuff going on,
               * but we don't necessarily want to throw an exception as
               * there may be stuff that comes up later that pushed us out
               * of Full, e.g. malformed RDF.
               */
              setSyntaxLevel(FULL);
              explain(FULL, code, message);
            }

            public void error(String message) throws SAXException {
              throw new SAXException(message);
            }

            public void warning(String message) throws SAXException {
              message(message.toString());
            }

            public void owlFullConstruct(int code, String message, Object obj) throws SAXException {
              // TODO Auto-generated method stub

            }
          };
      OWLOntology o = parseFromURI(handler, uri);
      int species = species(o, true) | syntaxLevel;
      result = (species == DL || species == LITE || species == FULL);
      // releaseOntology( o );
    } catch (ParserException ex) {
      explain(OTHER, UNKNOWN, ex.getMessage());
    } catch (OWLException ex) {
      explain(OTHER, UNKNOWN, ex.getMessage());
    }
    return result;
  }
예제 #2
0
  /**
   * Returns <code>true</code> if the ontology obtained by parsing the URI is in OWL DL. Will report
   * findings to the reporter as it goes. Note that the inner workings of the validator assume that
   * the ontology has <strong>not</strong> already been parsed.
   *
   * @param uri an <code>URI</code> value
   * @return a <code>boolean</code> value
   */
  public boolean isOWLDL(URI uri) {
    boolean result = false;
    try {
      /* Handler that's strict about OWLFullExceptions */
      syntaxLevel = LITE;
      OWLRDFErrorHandler handler =
          new OWLRDFErrorHandler() {
            public void owlFullConstruct(int code, String message) throws SAXException {
              /* Doesn't throw an error, but keeps going.... */
              setSyntaxLevel(FULL);
              explain(FULL, code, message);
              // throw new OWLFullConstructRDFException( message );
            }

            public void error(String message) throws SAXException {
              throw new SAXException(message.toString());
            }

            public void warning(String message) throws SAXException {
              message(message.toString());
            }

            public void owlFullConstruct(int code, String message, Object obj) throws SAXException {
              // TODO Auto-generated method stub

            }
          };
      OWLOntology o = parseFromURI(handler, uri);
      int species = species(o, true) | syntaxLevel;
      result = (species == DL || species == LITE);
      // releaseOntology( o );
    } catch (ParserException ex) {
      explain(OTHER, UNKNOWN, ex.getMessage());
    } catch (OWLException ex) {
      explain(OTHER, UNKNOWN, ex.getMessage());
    }
    return result;
  }