protected Float getPropertyFloatValue(OntResource res, Property prop){ if( prop != null ){ try{ return new Float( ((Literal)res.getPropertyValue(prop)).getFloat() ); }catch(Exception e){ return null; } }else return null; }
public float getFloat() { return getLiteral().getFloat(); }
public float getFloat() { return getLiteral().getFloat(); }
/** * Return the float value of a literal node. Depending on the backend implementing this method, * the value can be retrieved directly or must be parsed from the string representation. The method can throw * a NumberFormatException or ArithmeticException indicating that the value cannot be represented as float, and an * IllegalArgumentException, indicating that the passed node is not a literal * * @param rdfNode the literal node for which to return the float value * @return long value of the literal node * @throws NumberFormatException in case the literal cannot be represented as float value * @throws ArithmeticException in case the literal cannot be represented as float value * @throws IllegalArgumentException in case the node passed as argument is not a literal */ @Override public Float floatValue(RDFNode rdfNode) { if(isLiteral(rdfNode)) { return ((Literal)rdfNode).getFloat(); } else { throw new IllegalArgumentException("the node "+rdfNode+" is not a literal value"); } }
@Override public float getFloat() throws ReadDeniedException, AuthenticationRequiredException { checkRead(); return holder.getBaseItem().getFloat(); }
protected Float getPropertyFloatValue(OntResource res, Property prop){ if( prop != null ){ try{ return new Float( ((Literal)res.getPropertyValue(prop)).getFloat() ); }catch(Exception e){ return null; } }else return null; }
protected void testFloat( final Model model, final float tv ) { Assert.assertEquals(tv, model.createTypedLiteral(tv).getFloat(), AbstractModelTestBase.fDelta); }
protected void testFloat( final Model model, final float tv ) { Assert.assertEquals(tv, model.createTypedLiteral(tv).getFloat(), AbstractModelTestBase.fDelta); }
/** * convenience method for use with functional properties */ protected void updatePropertyFloatValue(Resource res, Property dataprop, Float value, Model model) { if (dataprop != null) { Float existingValue = null; Statement stmt = res.getProperty(dataprop); if (stmt != null) { RDFNode object = stmt.getObject(); if (object != null && object.isLiteral()){ existingValue = ((Literal)object).getFloat(); } } if (value == null) { model.removeAll(res, dataprop, null); } else if (existingValue == null ) { model.add(res, dataprop, Float.toString(value), XSDDatatype.XSDfloat); } else if (existingValue.compareTo(value) != 0) { model.removeAll(res, dataprop, null); model.add(res, dataprop, Float.toString(value), XSDDatatype.XSDfloat); } } }
private Literal getMax(Set<Literal> literals){ Iterator<Literal> iter = literals.iterator(); Literal max = iter.next(); Literal l; while(iter.hasNext()){ l = iter.next(); if(l.getDatatype() == XSDDatatype.XSDinteger || l.getDatatype() == XSDDatatype.XSDint){ max = (l.getInt() > max.getInt()) ? l : max; } else if(l.getDatatype() == XSDDatatype.XSDdouble || l.getDatatype() == XSDDatatype.XSDdecimal){ max = (l.getDouble() > max.getDouble()) ? l : max; } else if(l.getDatatype() == XSDDatatype.XSDfloat){ max = (l.getFloat() > max.getFloat()) ? l : max; } else if(l.getDatatype() == XSDDatatype.XSDdate){ max = (DatatypeConverter.parseDate(l.getLexicalForm()).compareTo(DatatypeConverter.parseDate(max.getLexicalForm())) > 0) ? l : max; } } return max; }
@Override public PropertyStatement buildPropertyStatement(Statement s) { return new FloatPropertyStatement(s.getPredicate().getURI(), s .getObject().asLiteral().getFloat()); }
private Literal getMin(Set<Literal> literals){ Iterator<Literal> iter = literals.iterator(); Literal min = iter.next(); Literal l; while(iter.hasNext()){ l = iter.next(); if(l.getDatatype() == XSDDatatype.XSDinteger || l.getDatatype() == XSDDatatype.XSDint){ min = (l.getInt() < min.getInt()) ? l : min; } else if(l.getDatatype() == XSDDatatype.XSDdouble || l.getDatatype() == XSDDatatype.XSDdecimal){ min = (l.getDouble() < min.getDouble()) ? l : min; } else if(l.getDatatype() == XSDDatatype.XSDfloat){ min = (l.getFloat() < min.getFloat()) ? l : min; } else if(l.getDatatype() == XSDDatatype.XSDdate){ min = (DatatypeConverter.parseDate(l.getLexicalForm()).compareTo(DatatypeConverter.parseDate(min.getLexicalForm())) < 0) ? l : min; } } return min; }
private Literal getMax(Set<Literal> literals){ Iterator<Literal> iter = literals.iterator(); Literal max = iter.next(); Literal l; while(iter.hasNext()){ l = iter.next(); if(l.getDatatype() == XSDDatatype.XSDinteger || l.getDatatype() == XSDDatatype.XSDint){ max = (l.getInt() > max.getInt()) ? l : max; } else if(l.getDatatype() == XSDDatatype.XSDdouble || l.getDatatype() == XSDDatatype.XSDdecimal){ max = (l.getDouble() > max.getDouble()) ? l : max; } else if(l.getDatatype() == XSDDatatype.XSDfloat){ max = (l.getFloat() > max.getFloat()) ? l : max; } else if(l.getDatatype() == XSDDatatype.XSDdate){ max = (DatatypeConverter.parseDate(l.getLexicalForm()).compareTo(DatatypeConverter.parseDate(max.getLexicalForm())) == 1) ? l : max; } else if(l.getDatatype() == XSDDatatype.XSDgYear){ max = (DatatypeConverter.parseDate(l.getLexicalForm()).compareTo(DatatypeConverter.parseDate(max.getLexicalForm())) == 1) ? l : max; } } return max; }
private Literal getMin(Set<Literal> literals){ Iterator<Literal> iter = literals.iterator(); Literal min = iter.next(); Literal l; while(iter.hasNext()){ l = iter.next(); if(l.getDatatype() == XSDDatatype.XSDinteger || l.getDatatype() == XSDDatatype.XSDint){ min = (l.getInt() < min.getInt()) ? l : min; } else if(l.getDatatype() == XSDDatatype.XSDdouble || l.getDatatype() == XSDDatatype.XSDdecimal){ min = (l.getDouble() < min.getDouble()) ? l : min; } else if(l.getDatatype() == XSDDatatype.XSDfloat){ min = (l.getFloat() < min.getFloat()) ? l : min; } else if(l.getDatatype() == XSDDatatype.XSDdate){ min = (DatatypeConverter.parseDate(l.getLexicalForm()).compareTo(DatatypeConverter.parseDate(min.getLexicalForm())) == -1) ? l : min; } else if(l.getDatatype() == XSDDatatype.XSDgYear){ min = (DatatypeConverter.parseDate(l.getLexicalForm()).compareTo(DatatypeConverter.parseDate(min.getLexicalForm())) == -1) ? l : min; } } return min; }
public Float getSearchBoost(){ if( this._searchBoostJena != null ){ return this._searchBoostJena; }else{ ind.getOntModel().enterCriticalSection(Lock.READ); try{ try { searchBoost = ((Literal)ind.getPropertyValue(webappDaoFactory.getJenaBaseDao().SEARCH_BOOST_ANNOT)).getFloat(); } catch (Exception e) { searchBoost = null; } return searchBoost; }finally{ ind.getOntModel().leaveCriticalSection(); } } }
private boolean isLessOrEqual(Literal l1, Literal l2){ if((l1.getDatatype() == XSDDatatype.XSDinteger || l1.getDatatype() == XSDDatatype.XSDint) && (l2.getDatatype() == XSDDatatype.XSDinteger || l2.getDatatype() == XSDDatatype.XSDint)){ return (l1.getInt() <= l2.getInt()); } else if((l1.getDatatype() == XSDDatatype.XSDdouble || l1.getDatatype() == XSDDatatype.XSDdecimal) && (l2.getDatatype() == XSDDatatype.XSDdouble || l2.getDatatype() == XSDDatatype.XSDdecimal)){ return l1.getDouble() <= l2.getDouble(); } else if(l1.getDatatype() == XSDDatatype.XSDfloat && l2.getDatatype() == XSDDatatype.XSDfloat){ return l1.getFloat() <= l2.getFloat(); } else if(l1.getDatatype() == XSDDatatype.XSDdate && l2.getDatatype() == XSDDatatype.XSDdate){ Calendar date1 = DatatypeConverter.parseDate(l1.getLexicalForm()); Calendar date2 = DatatypeConverter.parseDate(l2.getLexicalForm()); int comp = date1.compareTo(date2); return comp <= 0; } return false; }
private boolean isGreaterOrEqual(Literal l1, Literal l2){ if((l1.getDatatype() == XSDDatatype.XSDinteger || l1.getDatatype() == XSDDatatype.XSDint) && (l2.getDatatype() == XSDDatatype.XSDinteger || l2.getDatatype() == XSDDatatype.XSDint)){ return (l1.getInt() >= l2.getInt()); } else if((l1.getDatatype() == XSDDatatype.XSDdouble || l1.getDatatype() == XSDDatatype.XSDdecimal) && (l2.getDatatype() == XSDDatatype.XSDdouble || l2.getDatatype() == XSDDatatype.XSDdecimal)){ return l1.getDouble() >= l2.getDouble(); } else if(l1.getDatatype() == XSDDatatype.XSDfloat && l2.getDatatype() == XSDDatatype.XSDfloat){ return l1.getFloat() >= l2.getFloat(); } else if(l1.getDatatype() == XSDDatatype.XSDdate && l2.getDatatype() == XSDDatatype.XSDdate){ Calendar date1 = DatatypeConverter.parseDate(l1.getLexicalForm()); Calendar date2 = DatatypeConverter.parseDate(l2.getLexicalForm()); int comp = date1.compareTo(date2); return comp >= 0; } return false; }
assertEquals("class wrong", l2.getValue().getClass(), Float.class); assertFloatEquals("value wrong", ((Float)(l2.getValue())).floatValue(), 42.42); assertFloatEquals("Value accessor problem", l1.getFloat(), 42.42); assertEquals("wrong type", l2.getDatatype(), XSDDatatype.XSDfloat); assertSameValueAs("equality fn", l1, l3);
factory.getOWLDataPropertyAssertionAxiom(p, me, ln.getFloat())); } else if (one.getBPart().isDouble()) { owlAPIOntologyCollector.addAxiom(