/** * Select parsers by MIME type and format of the input source, if known. If format and MIME type * are not known or not matched by any parser, return all known parsers. * * @param documentSource document source * @param parsers parsers * @return selected parsers */ private static PriorityCollection<OWLParserFactory> getParsers( OWLOntologyDocumentSource documentSource, PriorityCollection<OWLParserFactory> parsers) { if (parsers.isEmpty()) { return parsers; } Optional<OWLDocumentFormat> format = documentSource.getFormat(); Optional<String> mimeType = documentSource.getMIMEType(); if (!format.isPresent() && !mimeType.isPresent()) { return parsers; } PriorityCollection<OWLParserFactory> candidateParsers = parsers; if (format.isPresent()) { candidateParsers = getParsersByFormat(format.get(), parsers); } if (candidateParsers.isEmpty() && mimeType.isPresent()) { candidateParsers = getParserCandidatesByMIME(mimeType.get(), parsers); } if (candidateParsers.isEmpty()) { return parsers; } return candidateParsers; }
createOWLOntology(manager, ontologyID, documentSource.getDocumentIRI(), handler); getParsers(documentSource, manager.getOntologyParsers()); ont = createOWLOntology(manager, ontologyID, documentSource.getDocumentIRI(), handler);
private static void augmentManager(OWLOntologyManager manager, ReadWriteLock readWriteLock) { var nonConcurrentBuilder = new NonConcurrentOWLOntologyBuilder(); var concurrentBuilder = new ConcurrentOWLOntologyBuilder(nonConcurrentBuilder, readWriteLock); var ontologyFactory = new OWLOntologyFactoryImpl(concurrentBuilder); manager.getOntologyFactories().add(ontologyFactory); manager.getOntologyParsers().add(new BinaryOWLOntologyDocumentParserFactory()); manager.getOntologyStorers().add(new BinaryOWLStorerFactory()); } }
createOWLOntology(manager, ontologyID, documentSource.getDocumentIRI(), handler); getParsers(documentSource, manager.getOntologyParsers()); ont = createOWLOntology(manager, ontologyID, documentSource.getDocumentIRI(), handler);
/** * Select parsers by MIME type and format of the input source, if known. If format and MIME type * are not known or not matched by any parser, return all known parsers. * * @param documentSource document source * @param parsers parsers * @return selected parsers */ private static PriorityCollection<OWLParserFactory> getParsers( OWLOntologyDocumentSource documentSource, PriorityCollection<OWLParserFactory> parsers) { if (parsers.isEmpty()) { return parsers; } Optional<OWLDocumentFormat> format = documentSource.getFormat(); Optional<String> mimeType = documentSource.getMIMEType(); if (!format.isPresent() && !mimeType.isPresent()) { return parsers; } PriorityCollection<OWLParserFactory> candidateParsers = parsers; if (format.isPresent()) { candidateParsers = getParsersByFormat(format.get(), parsers); } if (candidateParsers.isEmpty() && mimeType.isPresent()) { candidateParsers = getParserCandidatesByMIME(mimeType.get(), parsers); } if (candidateParsers.isEmpty()) { return parsers; } return candidateParsers; }
createOWLOntology(manager, ontologyID, documentSource.getDocumentIRI(), handler); getParsers(documentSource, manager.getOntologyParsers()); ont = createOWLOntology(manager, ontologyID, documentSource.getDocumentIRI(), handler);
/** * Select parsers by MIME type and format of the input source, if known. If format and MIME type * are not known or not matched by any parser, return all known parsers. * * @param documentSource document source * @param parsers parsers * @return selected parsers */ private static PriorityCollection<OWLParserFactory> getParsers( OWLOntologyDocumentSource documentSource, PriorityCollection<OWLParserFactory> parsers) { if (parsers.isEmpty()) { return parsers; } Optional<OWLDocumentFormat> format = documentSource.getFormat(); Optional<String> mimeType = documentSource.getMIMEType(); if (!format.isPresent() && !mimeType.isPresent()) { return parsers; } PriorityCollection<OWLParserFactory> candidateParsers = parsers; if (format.isPresent()) { candidateParsers = getParsersByFormat(format.get(), parsers); } if (candidateParsers.isEmpty() && mimeType.isPresent()) { candidateParsers = getParserCandidatesByMIME(mimeType.get(), parsers); } if (candidateParsers.isEmpty()) { return parsers; } return candidateParsers; }
createOWLOntology(manager, ontologyID, documentSource.getDocumentIRI(), handler); getParsers(documentSource, manager.getOntologyParsers()); ont = createOWLOntology(manager, ontologyID, documentSource.getDocumentIRI(), handler);
/** * Select parsers by MIME type and format of the input source, if known. If format and MIME type * are not known or not matched by any parser, return all known parsers. * * @param documentSource document source * @param parsers parsers * @return selected parsers */ private static PriorityCollection<OWLParserFactory> getParsers( OWLOntologyDocumentSource documentSource, PriorityCollection<OWLParserFactory> parsers) { if (parsers.isEmpty()) { return parsers; } Optional<OWLDocumentFormat> format = documentSource.getFormat(); Optional<String> mimeType = documentSource.getMIMEType(); if (!format.isPresent() && !mimeType.isPresent()) { return parsers; } PriorityCollection<OWLParserFactory> candidateParsers = parsers; if (format.isPresent()) { candidateParsers = getParsersByFormat(format.get(), parsers); } if (candidateParsers.isEmpty() && mimeType.isPresent()) { candidateParsers = getParserCandidatesByMIME(mimeType.get(), parsers); } if (candidateParsers.isEmpty()) { return parsers; } return candidateParsers; }