@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!super.equals(obj)) { return false; } if (obj instanceof OWLLiteralImplFloat) { OWLLiteralImplFloat other = (OWLLiteralImplFloat) obj; return literal == other.literal && datatype.equals(other.getDatatype()); } if (obj instanceof OWLLiteral) { return ((OWLLiteral) obj).isFloat() && Float.compare(literal, ((OWLLiteral) obj).parseFloat()) == 0; } return false; }
@Override protected int compareObjectOfSameType(OWLObject object) { OWLLiteral other = (OWLLiteral) object; int diff = getLiteral().compareTo(other.getLiteral()); if (diff != 0) { return diff; } int compareTo = datatype.compareTo(other.getDatatype()); if (compareTo != 0) { return compareTo; } return Float.compare(literal, other.parseFloat()); }
@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; }
return Range.between(min.parseFloat(), max.parseFloat()).contains(value.parseFloat()); } else if(OWLAPIUtils.intDatatypes.contains(datatype)) { return Range.between(min.parseInteger(), max.parseInteger()).contains(value.parseInteger());
/*** * @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);
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); } }
print("(instance " + getIndividualName(i1) + " (= " + dpName + " " + i2.parseInteger() + ") " + d + " )"); else print("(instance " + getIndividualName(i1) + " (= " + dpName + " " + i2.parseFloat() + ") " + d + " )");
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()); } }