@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 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; }
stringBuilder.append(literal); else if (node.isFloat()) { stringBuilder.append(literal); stringBuilder.append("f");
/*** * @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(); }
@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()); }
if (i2.isDouble() || i2.isInteger() || i2.isFloat())
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()); } }