/** * Read a KiWiDoubleLiteral serialized with writeDoubleLiteral from a DataInput source * * @param input the source * @return the de-serialized KiWiDoubleLiteral * @throws IOException */ public static KiWiDoubleLiteral readDoubleLiteral(DataInput input) throws IOException { long id = input.readLong(); if (id == -1) { return null; } double content = input.readDouble(); KiWiUriResource dtype = readURI(input); Date created = new Date(input.readLong()); KiWiDoubleLiteral r = new KiWiDoubleLiteral(content, dtype, created); r.setId(id); return r; }
/** * Efficiently serialize a KiWiDoubleLiteral to a DataOutput destination. * * @param out the destination * @param literal the KiWiDoubleLiteral to serialize * @throws IOException */ public static void writeDoubleLiteral(DataOutput out, KiWiDoubleLiteral literal) throws IOException { if(literal == null) { out.writeLong(-1L); } else { out.writeLong(literal.getId()); out.writeDouble(literal.getDoubleContent()); writeURI(out, literal.getType()); out.writeLong(literal.getCreated().getTime()); } }
public void setDoubleContent(Double doubleContent) { this.doubleContent = doubleContent; this.content = fmt(doubleContent); }
} else if(n instanceof KiWiDoubleLiteral) { KiWiDoubleLiteral l = (KiWiDoubleLiteral)n; createNodeList(rowArray, l.getId(), l.getClass(), l.getContent(), l.getDoubleContent(), null, null, null, null, l.getDatatype(), l.getLocale(), l.getCreated()); } else if(n instanceof KiWiBooleanLiteral) { KiWiBooleanLiteral l = (KiWiBooleanLiteral)n;
insertNode.setString(2, doubleLiteral.getContent()); insertNode.setDouble(3, doubleLiteral.getDoubleContent()); if (doubleLiteral.getType() != null) insertNode.setLong(4,doubleLiteral.getType().getId()); else throw new IllegalStateException("a double literal must have a datatype"); insertNode.setTimestamp(5, new Timestamp(doubleLiteral.getCreated().getTime()), calendarUTC);
KiWiDoubleLiteral literal = new KiWiDoubleLiteral(value, uri); connection.storeNode(literal); Assert.assertTrue(literal.getId() >= 0); KiWiNode testLiteral1 = connection.loadNodeById(literal.getId()); KiWiNode testLiteral2 = connection.loadNodeById(literal.getId()); KiWiNode testLiteral3 = connection.loadLiteral(literal.stringValue(),null,uri); KiWiNode testLiteral4 = connection.loadNodeById(literal.getId()); KiWiNode testLiteral5 = connection.loadLiteral(literal.stringValue(),null,uri); Assert.assertEquals((long) literal.getId(), result.getLong("id")); Assert.assertEquals(literal.stringValue(),result.getString("svalue")); Assert.assertEquals(value,result.getDouble("dvalue"),0.01); Assert.assertEquals("double",result.getString("ntype"));
result= new KiWiDoubleLiteral(dvalue, rtype);
KiWiDoubleLiteral result = new KiWiDoubleLiteral(row.getDouble(5), null, new Date(row.getTimestamp(11, calendarUTC).getTime())); result.setId(id); if(row.getLong(10) != 0) { result.setType((KiWiUriResource) loadNodeById(row.getLong(10)));
/** * Returns the <tt>double</tt> value of this literal. * * @return The <tt>double</tt> value of the literal. * @throws NumberFormatException If the literal's label cannot be represented by a <tt>double</tt>. */ @Override public double doubleValue() { return getDoubleContent(); }
} else if(n instanceof KiWiDoubleLiteral) { KiWiDoubleLiteral l = (KiWiDoubleLiteral)n; createNodeList(rowArray, l.getId(), l.getClass(), l.getContent(), l.getDoubleContent(), null, null, null, null, l.getDatatype(), l.getLocale(), l.getCreated()); } else if(n instanceof KiWiBooleanLiteral) { KiWiBooleanLiteral l = (KiWiBooleanLiteral)n;
insertNode.setString(2, doubleLiteral.getContent()); insertNode.setDouble(3, doubleLiteral.getDoubleContent()); if (doubleLiteral.getType() != null) insertNode.setLong(4,doubleLiteral.getType().getId()); else throw new IllegalStateException("a double literal must have a datatype"); insertNode.setTimestamp(5, new Timestamp(doubleLiteral.getCreated().getTime()), calendarUTC);
result= new KiWiDoubleLiteral(dvalue, rtype);
KiWiDoubleLiteral result = new KiWiDoubleLiteral(row.getDouble(5), null, new Date(row.getTimestamp(11, calendarUTC).getTime())); result.setId(id); if(row.getLong(10) != 0) { result.setType((KiWiUriResource) loadNodeById(row.getLong(10)));
/** * Returns the <tt>double</tt> value of this literal. * * @return The <tt>double</tt> value of the literal. * @throws NumberFormatException If the literal's label cannot be represented by a <tt>double</tt>. */ @Override public double doubleValue() { return getDoubleContent(); }
} else if(n instanceof KiWiDoubleLiteral) { KiWiDoubleLiteral l = (KiWiDoubleLiteral)n; createNodeList(rowArray, l.getId(), l.getClass(), l.getContent(), l.getDoubleContent(), null, null, null, null, l.getDatatype(), l.getLocale(), l.getCreated()); } else if(n instanceof KiWiBooleanLiteral) { KiWiBooleanLiteral l = (KiWiBooleanLiteral)n;
/** * Efficiently serialize a KiWiDoubleLiteral to a DataOutput destination. * * @param out the destination * @param literal the KiWiDoubleLiteral to serialize * @throws IOException */ public static void writeDoubleLiteral(DataOutput out, KiWiDoubleLiteral literal) throws IOException { if(literal == null) { out.writeLong(-1L); } else { out.writeLong(literal.getId()); out.writeDouble(literal.getDoubleContent()); writeURI(out, literal.getType()); out.writeLong(literal.getCreated().getTime()); } }
/** * Creates a new <tt>xsd:float</tt>-typed literal representing the specified * value. * * @param value The value for the literal. * @return An <tt>xsd:float</tt>-typed literal for the specified value. */ @Override public Literal createLiteral(float value) { KiWiLiteral l = new KiWiDoubleLiteral(Double.valueOf(value), (KiWiUriResource) createURI(LiteralCommons.getXSDType(Float.class)), new Date()); l.setId(idGenerator.getId()); return l; }
/** * Read a KiWiDoubleLiteral serialized with writeDoubleLiteral from a DataInput source * * @param input the source * @return the de-serialized KiWiDoubleLiteral * @throws IOException */ public static KiWiDoubleLiteral readDoubleLiteral(DataInput input) throws IOException { long id = input.readLong(); if (id == -1) { return null; } double content = input.readDouble(); KiWiUriResource dtype = readURI(input); Date created = new Date(input.readLong()); KiWiDoubleLiteral r = new KiWiDoubleLiteral(content, dtype, created); r.setId(id); return r; }
/** * Returns the <tt>float</tt> value of this literal. * * @return The <tt>float</tt> value of the literal. * @throws NumberFormatException If the literal's label cannot be represented by a <tt>float</tt>. */ @Override public float floatValue() { return getDoubleContent().floatValue(); }
public void setDoubleContent(Double doubleContent) { this.doubleContent = doubleContent; this.content = fmt(doubleContent); }