/** * Reads all the bytes from the specified stream into a temporary buffer, * which is necessary because we may need to access the input stream more * than once. In other words, this method caches the input stream. * * @param stream * The stream to be cached */ private void readIntoBuffer(InputStream reader) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); final int length = 100000; byte[] tempBuffer = new byte[length]; int read = 0; do { read = reader.read(tempBuffer, 0, length); if (read > 0) { bos.write(tempBuffer, 0, read); } } while (read > 0); mBuffer = bos.toByteArray(); } catch (IOException e) { throw new OWLRuntimeException(e); } }
@Override public IRI getIRI(String prefixIRI) { if (prefixIRI.startsWith("<")) { return IRI.create(prefixIRI.substring(1, prefixIRI.length() - 1)); } int sep = prefixIRI.indexOf(':'); if (sep == -1) { if (getDefaultPrefix() != null) { return IRI.create(getDefaultPrefix() + prefixIRI); } else { return IRI.create(prefixIRI); } } else { String prefixName = prefixIRI.substring(0, sep + 1); if (!containsPrefixMapping(prefixName)) { throw new OWLRuntimeException("Prefix not registered for prefix name: " + prefixName); } String prefix = getPrefix(prefixName); String localName = prefixIRI.substring(sep + 1); return IRI.create(prefix, localName); } }
/** * @param literal the lexical form * @param lang the language; can be null or an empty string, in which case datatype can be any * datatype but not null * @param datatype the datatype; if lang is null or the empty string, it can be null or it MUST * be RDFPlainLiteral */ public OWLLiteralImpl(@Nonnull String literal, @Nullable String lang, @Nullable OWLDatatype datatype) { this.literal = new LiteralWrapper(checkNotNull(literal, "literal cannot be null")); if (lang == null || lang.isEmpty()) { language = ""; if (datatype == null) { this.datatype = RDF_PLAIN_LITERAL; } else { this.datatype = datatype; } } else { if (datatype != null && !datatype.isRDFPlainLiteral()) { // ERROR: attempting to build a literal with a language tag and // type different from plain literal throw new OWLRuntimeException("Error: cannot build a literal with type: " + datatype.getIRI() + " and language: " + lang); } language = lang; this.datatype = RDF_PLAIN_LITERAL; } hashcode = getHashCode(literal); }
@Override public void render(OWLOntology ontology, PrintWriter writer) throws OWLRendererException { try { OWLFuncionalSyntaxRefsetObjectRenderer ren = new OWLFuncionalSyntaxRefsetObjectRenderer(ontology, writer); ontology.accept(ren); writer.flush(); } catch (OWLRuntimeException e) { throw new OWLRendererIOException(e); } }
public OWLRuntimeException convert(ElkException e) { if (e instanceof ElkFreshEntitiesException) return convert((ElkFreshEntitiesException) e); else if (e instanceof ElkInconsistentOntologyException) return convert((ElkInconsistentOntologyException) e); else if (e instanceof ElkInterruptedException) return convert((ElkInterruptedException) e); else return new OWLRuntimeException(e); }
private OWLOntology loadViaOWLAPI() throws Owl2ParseException { try { return TestOWLManager.createOWLOntologyManager() .loadOntologyFromOntologyDocument(mOntoSource); } catch (OWLOntologyCreationException e) { throw new Owl2ParseException(e); } catch (OWLRuntimeException re) { throw new Owl2ParseException(re); } }
@Override public OWL2Datatype getBuiltInDatatype() { if (!builtin) { throw new OWLRuntimeException( iri + " is not a built in datatype. The getBuiltInDatatype() method should only be called on built in datatypes."); } else { return OWL2Datatype.getDatatype(iri); } }
public OWLRuntimeException convert(ElkRuntimeException e) { return new ReasonerInternalException(e); }
@Override public boolean parseBoolean() { throw new OWLRuntimeException(getClass().getName() + " does not have a boolean value"); }
@Override public double parseDouble() { throw new OWLRuntimeException(getClass().getName() + " does not have a double value"); }
@Override public float parseFloat() { throw new OWLRuntimeException(getClass().getName() + " does not have a float value"); }
@Override public OWLClass asOWLClass() { throw new OWLRuntimeException("Not an OWLClass!"); }
@Override public OWLDatatype asOWLDatatype() { throw new OWLRuntimeException("Not an OWLDatatype!"); }
@Override public OWLNamedIndividual asOWLNamedIndividual() { throw new OWLRuntimeException("Not an OWLIndividual!"); }
@Override public OWLObjectProperty asOWLObjectProperty() { throw new OWLRuntimeException("Not an OWLObjectProperty!"); }
@Override public OWLAnnotationProperty asOWLAnnotationProperty() { throw new OWLRuntimeException("Not an annotation property"); }
@Override public OWLClass asOWLClass() { throw new OWLRuntimeException( "Not an OWLClass. This method should only be called if the isAnonymous method returns false!"); }
@Override public OWLObjectProperty asOWLObjectProperty() { throw new OWLRuntimeException( "Property is not a named property. Check using the isAnonymous method before calling this method!"); }
@Override public OWLDataProperty asOWLDataProperty() { throw new OWLRuntimeException("Not a data property!"); }
@Override public OWLNamedIndividual asOWLNamedIndividual() { throw new OWLRuntimeException("Not an individual!"); }
@Override public OWLObjectProperty asOWLObjectProperty() { throw new OWLRuntimeException("Not an object property"); }
@Nonnull @Override public OWLDatatype asOWLDatatype() { throw new OWLRuntimeException("Not a data type!"); }
@Override public OWLDatatype asOWLDatatype() { throw new OWLRuntimeException("Not a data type!"); }
public SKOSUntypedLiteral getAsSKOSUntypedLiteral() { throw new OWLRuntimeException("Not a SKOS Untyped Constant"); }
public SKOSConceptScheme asSKOSConceptScheme() { throw new OWLRuntimeException("Not a SKOS Concept Scheme"); }
public SKOSLabelRelationImpl asSKOSLabelRelation() { throw new OWLRuntimeException("Not a SKOS Label Relation"); }
public SKOSResource asSKOSResource() { throw new OWLRuntimeException("Not a SKOS Resource"); }
public SKOSLabelRelation asSKOSLabelRelation() { throw new OWLRuntimeException("Not a SKOS Label Relation"); }
public SKOSTypedLiteral getAsSKOSTypedLiteral() { throw new OWLRuntimeException("This is not a SKOS Typed Constant"); }