Search in sources :

Example 1 with PrimitiveType

use of edu.stanford.bmir.protege.web.shared.PrimitiveType in project webprotege by protegeproject.

the class PrimitiveDataParserImpl method parsePrimitiveDataFromTrimmedContent.

private void parsePrimitiveDataFromTrimmedContent(final String trimmedContent, final java.util.Optional<String> lang, Set<PrimitiveType> allowedTypes, final PrimitiveDataParserCallback callback) {
    if (trimmedContent.isEmpty()) {
        callback.onSuccess(java.util.Optional.empty());
        return;
    }
    if (lang.isPresent()) {
        if (allowedTypes.contains(PrimitiveType.LITERAL)) {
            OWLLiteralData literalData = parseLiteralData(trimmedContent, lang);
            callback.onSuccess(java.util.Optional.of(literalData));
        } else {
            // TODO: Literal not expected
            callback.parsingFailure();
        }
        return;
    }
    Set<EntityType<?>> allowedEntityTypes = Sets.newHashSet();
    for (PrimitiveType primitiveType : allowedTypes) {
        if (primitiveType.isEntityType()) {
            allowedEntityTypes.add(primitiveType.getEntityType());
        }
    }
    parseEntityDataIRIOrLiteral(trimmedContent, lang, allowedEntityTypes, allowedTypes, callback);
}
Also used : EntityType(org.semanticweb.owlapi.model.EntityType) OWLLiteralData(edu.stanford.bmir.protege.web.shared.entity.OWLLiteralData) PrimitiveType(edu.stanford.bmir.protege.web.shared.PrimitiveType)

Aggregations

PrimitiveType (edu.stanford.bmir.protege.web.shared.PrimitiveType)1 OWLLiteralData (edu.stanford.bmir.protege.web.shared.entity.OWLLiteralData)1 EntityType (org.semanticweb.owlapi.model.EntityType)1