public Map<OWLIndividual, SortedSet<Double>> getDoubleValues(OWLDataProperty dataProperty) { Map<OWLIndividual, SortedSet<Double>> map = new TreeMap<>(); for (OWLIndividual ind : individuals) { Set<OWLLiteral> literals = getRelatedValuesImpl(ind, dataProperty); if (!literals.isEmpty()) { SortedSet<Double> values = new TreeSet<>(); for (OWLLiteral lit : literals) { if (lit.isDouble()) { values.add(lit.parseDouble()); } } map.put(ind, values); } } return map; }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!super.equals(obj)) { return false; } if (obj instanceof OWLLiteralImplDouble) { OWLLiteralImplDouble other = (OWLLiteralImplDouble) obj; return literal == other.literal; } if (obj instanceof OWLLiteral) { return ((OWLLiteral) obj).isDouble() && Double.compare(literal, ((OWLLiteral) obj).parseDouble()) == 0; } return false; }
@Override public Collection<Object> getData(IProperty property) { List<Object> ret = new ArrayList<>(); for (OWLLiteral dat : individual.getDataPropertyValues(((Property)property)._owl.asOWLDataProperty(), ontology)) { if (dat.isBoolean()) { ret.add(dat.parseBoolean()); } else if (dat.isBoolean()) { ret.add(dat.parseBoolean()); } else if (dat.isDouble()) { ret.add(dat.parseDouble()); } else if (dat.isFloat()) { ret.add(dat.parseFloat()); } else if (dat.isInteger()) { ret.add(dat.parseFloat()); } else { ret.add(dat.getLiteral()); } } return ret; }
@Override public void visit(OWLLiteral node) { String literal = node.getLiteral(); if (node.isInteger() || node.isBoolean() || node.isDouble()) { stringBuilder.append(literal);
/*** * @param literal An OWLLiteral * @return an optional correctly typed Java object from the OWLLiteral */ public static Optional<Object> getTypedLiteralValue(OWLLiteral literal) { Object literalValue = null; if (literal.isBoolean()) { literalValue = literal.parseBoolean(); } else if (literal.isInteger()) { literalValue = literal.parseInteger(); } else if (literal.isFloat()) { literalValue = literal.parseFloat(); } else if (literal.isDouble()) { literalValue = literal.parseDouble(); } else { // This needs to be addressed by #110 if (literal.hasLang() && !literal.getLang().startsWith("en")) { if (!unknownLanguages.contains(literal.getLang())) { unknownLanguages.add(literal.getLang()); logger.warning("Ignoring *all* literals with unsupported language: \"" + literal.getLang() + "\"."); } return Optional.empty(); } literalValue = literal.getLiteral(); } return Optional.of(literalValue); }
public static Object literal2obj(OWLAnnotationValue l) { if (l instanceof OWLLiteral) { if (((OWLLiteral) l).isBoolean()) return ((OWLLiteral) l).parseBoolean(); else if (((OWLLiteral) l).isInteger()) return ((OWLLiteral) l).parseInteger(); else if (((OWLLiteral) l).isFloat()) return ((OWLLiteral) l).parseFloat(); else if (((OWLLiteral) l).isDouble()) return ((OWLLiteral) l).parseDouble(); else { return ((OWLLiteral)l).getLiteral(); } } else if (l instanceof IRI) { return ((IRI)l).toURI().toString(); } return l.toString(); }
double min = facetRestrictions.stream() .filter(fr -> fr.getFacet() == OWLFacet.MIN_INCLUSIVE) .map(fr -> fr.getFacetValue().isDouble() ? fr.getFacetValue().parseDouble() : (double) fr.getFacetValue().parseFloat()) .findAny().orElse(-Double.MAX_VALUE); double max = facetRestrictions.stream() .filter(fr -> fr.getFacet() == OWLFacet.MAX_INCLUSIVE) .map(fr -> fr.getFacetValue().isDouble() ? fr.getFacetValue().parseDouble() : (double) fr.getFacetValue().parseFloat()) .findAny().orElse(Double.MAX_VALUE);
@Override public void visit(SWRLLiteralArgument node) { OWLLiteral literal=node.getLiteral(); if (literal.isBoolean()) terms.add(fac.getBooleanConstant(literal.parseBoolean())); else if(literal.hasLang()) terms.add(fac.getConstantLiteral(literal.getLiteral(), literal.getLang())); else if (literal.isDouble()) terms.add(fac.getConstantLiteral(literal.getLiteral(), Predicate.COL_TYPE.DOUBLE)); else if (literal.isFloat()) terms.add(fac.getConstantLiteral(literal.getLiteral(), Predicate.COL_TYPE.DECIMAL)); else if (literal.isInteger()) terms.add(fac.getConstantLiteral(literal.getLiteral(), Predicate.COL_TYPE.INTEGER)); else fac.getConstantLiteral(literal.getLiteral()); }
@Override public void visit(SWRLLiteralArgument node) { OWLLiteral literal=node.getLiteral(); if (literal.isBoolean()) terms.add(termFactory.getBooleanConstant(literal.parseBoolean())); else if(literal.hasLang()) terms.add(termFactory.getConstantLiteral(literal.getLiteral(), literal.getLang())); else if (literal.isDouble()) terms.add(termFactory.getConstantLiteral(literal.getLiteral(), typeFactory.getXsdDoubleDatatype())); else if (literal.isFloat()) terms.add(termFactory.getConstantLiteral(literal.getLiteral(), typeFactory.getXsdDecimalDatatype())); else if (literal.isInteger()) terms.add(termFactory.getConstantLiteral(literal.getLiteral(), typeFactory.getXsdIntegerDatatype())); else termFactory.getConstantLiteral(literal.getLiteral()); }
public void visit(OWLLiteral owlLiteral) { if (owlLiteral.isBoolean()) { builder.append(Boolean.toString(owlLiteral.parseBoolean())); } else if (owlLiteral.isDouble()) { builder.append(owlLiteral.parseDouble()); } else if (owlLiteral.isFloat()) { builder.append(owlLiteral.parseFloat()); } else if (owlLiteral.isInteger()) { builder.append(owlLiteral.parseInteger()); } else { builder.append("\""); builder.append(owlLiteral.getLiteral()); builder.append("\"^^"); owlLiteral.getDatatype().accept(this); } }
public void visit(@Nonnull OWLLiteral owlLiteral) { if (owlLiteral.isBoolean()) { builder.append(owlLiteral.getLiteral()); } else if (owlLiteral.isDouble()) { builder.append(owlLiteral.getLiteral()); } else if (owlLiteral.isFloat()) { builder.append(owlLiteral.getLiteral()); } else if (owlLiteral.isInteger()) { builder.append(owlLiteral.getLiteral()); } else { builder.append("\""); builder.append(owlLiteral.getLiteral()); builder.append("\"^^"); owlLiteral.getDatatype().accept(this); } }
public void visit(OWLLiteral owlLiteral) { if (owlLiteral.isBoolean()) { builder.append(Boolean.toString(owlLiteral.parseBoolean())); } else if (owlLiteral.isDouble()) { builder.append(owlLiteral.parseDouble()); } else if (owlLiteral.isFloat()) { builder.append(owlLiteral.parseFloat()); } else if (owlLiteral.isInteger()) { builder.append(owlLiteral.parseInteger()); } else { builder.append("\""); builder.append(owlLiteral.getLiteral()); builder.append("\"^^"); owlLiteral.getDatatype().accept(this); } }
/** * Builder initialized from an existing object. * * @param expected the existing object * @param df data factory */ public BuilderLiteral(OWLLiteral expected, OWLDataFactory df) { this(df); if (expected.hasLang()) { withLanguage(expected.getLang()); } else { withDatatype(expected.getDatatype()); } if (expected.isBoolean()) { withValue(expected.parseBoolean()); } else if (expected.isDouble()) { withValue(expected.parseDouble()); } else if (expected.isFloat()) { withValue(expected.parseFloat()); } else if (expected.isInteger()) { withValue(expected.parseInteger()); } else { withLiteralForm(expected.getLiteral()); } }
/** * Builder initialized from an existing object. * * @param expected the existing object * @param df data factory */ public BuilderLiteral(OWLLiteral expected, OWLDataFactory df) { this(df); if (expected.hasLang()) { withLanguage(expected.getLang()); } else { withDatatype(expected.getDatatype()); } if (expected.isBoolean()) { withValue(expected.parseBoolean()); } else if (expected.isDouble()) { withValue(expected.parseDouble()); } else if (expected.isFloat()) { withValue(expected.parseFloat()); } else if (expected.isInteger()) { withValue(expected.parseInteger()); } else { withLiteralForm(expected.getLiteral()); } }
/** * Builder initialized from an existing object. * * @param expected the existing object * @param df data factory */ public BuilderLiteral(OWLLiteral expected, OWLDataFactory df) { this(df); if (expected.hasLang()) { withLanguage(expected.getLang()); } else { withDatatype(expected.getDatatype()); } if (expected.isBoolean()) { withValue(expected.parseBoolean()); } else if (expected.isDouble()) { withValue(expected.parseDouble()); } else if (expected.isFloat()) { withValue(expected.parseFloat()); } else if (expected.isInteger()) { withValue(expected.parseInteger()); } else { withLiteralForm(expected.getLiteral()); } }
/** * Builder initialized from an existing object. * * @param expected * the existing object * @param df * data factory */ public BuilderLiteral(OWLLiteral expected, OWLDataFactory df) { this(df); if (expected.hasLang()) { withLanguage(expected.getLang()); } else { withDatatype(expected.getDatatype()); } if (expected.isBoolean()) { withValue(expected.parseBoolean()); } else if (expected.isDouble()) { withValue(expected.parseDouble()); } else if (expected.isFloat()) { withValue(expected.parseFloat()); } else if (expected.isInteger()) { withValue(expected.parseInteger()); } else { withLiteralForm(expected.getLiteral()); } }