Exemplo n.º 1
0
    private SWRLDataObject makeDataObject(final Expr expr) throws URISyntaxException {
      if (expr.isVariable()) {
        return swrlFactory.createDataVariable(new URI(varNS + expr.getVarName()));
      } else if (expr.isConstant()) {
        final NodeValue nv = (NodeValue) expr;
        OWLDataValue value;
        if (nv.isInteger()) value = owlModel.createDataValue(nv.getInteger());
        else if (nv.isDouble()) value = owlModel.createDataValue(Double.valueOf(nv.getDouble()));
        else if (nv.isFloat()) value = owlModel.createDataValue(Float.valueOf(nv.getFloat()));
        else if (nv.isBoolean()) value = owlModel.createDataValue(Boolean.valueOf(nv.getBoolean()));
        else if (nv.isString()) value = owlModel.createDataValue(nv.getString());
        else if (nv.isDecimal()) value = owlModel.createDataValue(nv.getDecimal());
        else if (nv.hasDateTime()) value = owlModel.createDataValue(nv.getDateTime());
        else /* if (nv.isLiteral()) */ throw new NotImplementedException();

        return swrlFactory.wrapDataValue(value);
      } else {
        throw new IllegalArgumentException(
            "Nested constraint (filter) near " + expr + " can not be transformed to SWRL atom.");
      }
    }