/** * Sets a positional parameter to a float literal * * @param index * Positional Index * @param f * Float value */ public void setLiteral(int index, float f) { this.setParam(index, NodeFactoryExtra.floatToNode(f)); }
/** * Sets a variable parameter to a float literal * * @param var * Variable * @param f * Float value */ public void setLiteral(String var, float f) { this.setParam(var, NodeFactoryExtra.floatToNode(f)); }
@Override public void setFloat(int parameterIndex, float value) throws SQLException { this.setParameter(parameterIndex, NodeFactoryExtra.floatToNode(value)); }
@Override public void setFloat(int parameterIndex, float value) throws SQLException { this.setParameter(parameterIndex, NodeFactoryExtra.floatToNode(value)); }
NodeFactory.createLiteral(((BigDecimal) value).toPlainString(), XSDDatatype.XSDdecimal)); } else if (value instanceof Float) { this.setParameter(parameterIndex, NodeFactoryExtra.floatToNode((Float) value)); } else if (value instanceof Double) { this.setParameter(parameterIndex, NodeFactoryExtra.doubleToNode((Double) value));
NodeFactory.createLiteral(((BigDecimal) value).toPlainString(), XSDDatatype.XSDdecimal)); } else if (value instanceof Float) { this.setParameter(parameterIndex, NodeFactoryExtra.floatToNode((Float) value)); } else if (value instanceof Double) { this.setParameter(parameterIndex, NodeFactoryExtra.doubleToNode((Double) value));
case Types.FLOAT: if (value instanceof Float) { this.setParameter(parameterIndex, NodeFactoryExtra.floatToNode((Float)value)); } else if (value instanceof Node) { Float f = JdbcNodeUtils.toFloat((Node)value); this.setParameter(parameterIndex, NodeFactoryExtra.floatToNode(f)); } else { throw new SQLException("The given value is not marshallable to the desired target type"); this.setParameter(parameterIndex, NodeFactoryExtra.doubleToNode((Double)value)); } else if (value instanceof Float) { this.setParameter(parameterIndex, NodeFactoryExtra.floatToNode((Float)value)); } else if (value instanceof Short) { this.setParameter(parameterIndex, NodeFactory.createLiteral(Short.toString((Short)value), XSDDatatype.XSDshort));
case Types.FLOAT: if (value instanceof Float) { this.setParameter(parameterIndex, NodeFactoryExtra.floatToNode((Float)value)); } else if (value instanceof Node) { Float f = JdbcNodeUtils.toFloat((Node)value); this.setParameter(parameterIndex, NodeFactoryExtra.floatToNode(f)); } else { throw new SQLException("The given value is not marshallable to the desired target type"); this.setParameter(parameterIndex, NodeFactoryExtra.doubleToNode((Double)value)); } else if (value instanceof Float) { this.setParameter(parameterIndex, NodeFactoryExtra.floatToNode((Float)value)); } else if (value instanceof Short) { this.setParameter(parameterIndex, NodeFactory.createLiteral(Short.toString((Short)value), XSDDatatype.XSDshort));
private QueryIterator resultsToQueryIterator(Binding binding, Node s, Node score, Node literal, Node graph, Collection<TextHit> results, ExecutionContext execCxt) { log.trace("resultsToQueryIterator: {}", results) ; Var sVar = Var.isVar(s) ? Var.alloc(s) : null ; Var scoreVar = (score==null) ? null : Var.alloc(score) ; Var literalVar = (literal==null) ? null : Var.alloc(literal) ; Var graphVar = (graph==null) ? null : Var.alloc(graph) ; Function<TextHit,Binding> converter = (TextHit hit) -> { if (score == null && literal == null) return sVar != null ? BindingFactory.binding(binding, sVar, hit.getNode()) : BindingFactory.binding(binding); BindingMap bmap = BindingFactory.create(binding); if (sVar != null) bmap.add(sVar, hit.getNode()); if (scoreVar != null) bmap.add(scoreVar, NodeFactoryExtra.floatToNode(hit.getScore())); if (literalVar != null) bmap.add(literalVar, hit.getLiteral()); if (graphVar != null && hit.getGraph() != null) bmap.add(graphVar, hit.getGraph()); return bmap; } ; Iterator<Binding> bIter = Iter.map(results.iterator(), converter); QueryIterator qIter = new QueryIterPlainWrapper(bIter, execCxt); return qIter ; }
private QueryIterator resultsToQueryIterator(Binding binding, Node s, Node score, Node literal, Node graph, Collection<TextHit> results, ExecutionContext execCxt) { log.trace("resultsToQueryIterator: {}", results) ; Var sVar = Var.isVar(s) ? Var.alloc(s) : null ; Var scoreVar = (score==null) ? null : Var.alloc(score) ; Var literalVar = (literal==null) ? null : Var.alloc(literal) ; Var graphVar = (graph==null) ? null : Var.alloc(graph) ; Function<TextHit,Binding> converter = (TextHit hit) -> { if (score == null && literal == null) return sVar != null ? BindingFactory.binding(binding, sVar, hit.getNode()) : BindingFactory.binding(binding); BindingMap bmap = BindingFactory.create(binding); if (sVar != null) bmap.add(sVar, hit.getNode()); if (scoreVar != null) bmap.add(scoreVar, NodeFactoryExtra.floatToNode(hit.getScore())); if (literalVar != null) bmap.add(literalVar, hit.getLiteral()); if (graphVar != null && hit.getGraph() != null) bmap.add(graphVar, hit.getGraph()); return bmap; } ; Iterator<Binding> bIter = Iter.map(results.iterator(), converter); QueryIterator qIter = new QueryIterPlainWrapper(bIter, execCxt); return qIter ; }
/** * Tests that the various set methods of {@link JenaPreparedStatement} * function correctly * * @throws SQLException */ @Test public void prepared_statement_setters_49() throws SQLException { JenaConnection conn = this.getConnection(); JenaPreparedStatement stmt = (JenaPreparedStatement) conn.prepareStatement("SELECT * WHERE { ?s ?p ? }"); stmt.setObject(1, NodeFactoryExtra.floatToNode(123.4f), Types.FLOAT); ParameterizedSparqlString pss = stmt.getParameterizedString(); Assert.assertTrue(pss.toString().contains("123.4")); Assert.assertTrue(pss.toString().contains(XSDDatatype.XSDfloat.getURI())); stmt.close(); conn.close(); }