/** * Read a KiWiIntLiteral serialized with writeIntLiteral from a DataInput source * * @param input the source * @return the de-serialized KiWiIntLiteral * @throws IOException */ public static KiWiIntLiteral readIntLiteral(DataInput input) throws IOException { long id = input.readLong(); if (id == -1) { return null; } long content = input.readLong(); KiWiUriResource dtype = readURI(input); Date created = new Date(input.readLong()); KiWiIntLiteral r = new KiWiIntLiteral(content, dtype, created); r.setId(id); return r; }
/** * Efficiently serialize a KiWiIntLiteral to a DataOutput destination. * * @param out the destination * @param literal the KiWiIntLiteral to serialize * @throws IOException */ public static void writeIntLiteral(DataOutput out, KiWiIntLiteral literal) throws IOException { if(literal == null) { out.writeLong(-1L); } else { out.writeLong(literal.getId()); out.writeLong(literal.getIntContent()); writeURI(out, literal.getType()); out.writeLong(literal.getCreated().getTime()); } }
} else if(n instanceof KiWiIntLiteral) { KiWiIntLiteral l = (KiWiIntLiteral)n; createNodeList(rowArray, l.getId(), l.getClass(), l.getContent(), l.getDoubleContent(), l.getIntContent(), null, null, null, l.getDatatype(), l.getLocale(), l.getCreated()); } else if(n instanceof KiWiDoubleLiteral) { KiWiDoubleLiteral l = (KiWiDoubleLiteral)n;
insertNode.setString(2, intLiteral.getContent()); insertNode.setDouble(3, intLiteral.getDoubleContent()); insertNode.setLong(4, intLiteral.getIntContent()); if (intLiteral.getType() != null) insertNode.setLong(5,intLiteral.getType().getId()); else throw new IllegalStateException("an integer literal must have a datatype"); insertNode.setTimestamp(6, new Timestamp(intLiteral.getCreated().getTime()), calendarUTC);
KiWiIntLiteral literal = new KiWiIntLiteral(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.getLong("ivalue")); Assert.assertEquals("int",result.getString("ntype"));
result= new KiWiIntLiteral(ivalue, rtype);
KiWiIntLiteral result = new KiWiIntLiteral(row.getLong(4), 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>long</tt> value of this literal. * * @return The <tt>long</tt> value of the literal. * @throws NumberFormatException If the literal's label cannot be represented by to a <tt>long</tt>. */ @Override public long longValue() { return getIntContent(); } }
} else if(n instanceof KiWiIntLiteral) { KiWiIntLiteral l = (KiWiIntLiteral)n; createNodeList(rowArray, l.getId(), l.getClass(), l.getContent(), l.getDoubleContent(), l.getIntContent(), null, null, null, l.getDatatype(), l.getLocale(), l.getCreated()); } else if(n instanceof KiWiDoubleLiteral) { KiWiDoubleLiteral l = (KiWiDoubleLiteral)n;
insertNode.setString(2, intLiteral.getContent()); insertNode.setDouble(3, intLiteral.getDoubleContent()); insertNode.setLong(4, intLiteral.getIntContent()); if (intLiteral.getType() != null) insertNode.setLong(5,intLiteral.getType().getId()); else throw new IllegalStateException("an integer literal must have a datatype"); insertNode.setTimestamp(6, new Timestamp(intLiteral.getCreated().getTime()), calendarUTC);
result= new KiWiIntLiteral(ivalue, rtype);
KiWiIntLiteral result = new KiWiIntLiteral(row.getLong(4), 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>long</tt> value of this literal. * * @return The <tt>long</tt> value of the literal. * @throws NumberFormatException If the literal's label cannot be represented by to a <tt>long</tt>. */ @Override public long longValue() { return getIntContent(); } }
} else if(n instanceof KiWiIntLiteral) { KiWiIntLiteral l = (KiWiIntLiteral)n; createNodeList(rowArray, l.getId(), l.getClass(), l.getContent(), l.getDoubleContent(), l.getIntContent(), null, null, null, l.getDatatype(), l.getLocale(), l.getCreated()); } else if(n instanceof KiWiDoubleLiteral) { KiWiDoubleLiteral l = (KiWiDoubleLiteral)n;
/** * Efficiently serialize a KiWiIntLiteral to a DataOutput destination. * * @param out the destination * @param literal the KiWiIntLiteral to serialize * @throws IOException */ public static void writeIntLiteral(DataOutput out, KiWiIntLiteral literal) throws IOException { if(literal == null) { out.writeLong(-1L); } else { out.writeLong(literal.getId()); out.writeLong(literal.getIntContent()); writeURI(out, literal.getType()); out.writeLong(literal.getCreated().getTime()); } }
/** * Creates a new <tt>xsd:long</tt>-typed literal representing the specified * value. * * @param value The value for the literal. * @return An <tt>xsd:long</tt>-typed literal for the specified value. */ @Override public Literal createLiteral(long value) { KiWiLiteral l = new KiWiIntLiteral(Long.valueOf(value), (KiWiUriResource) createURI(LiteralCommons.getXSDType(Long.class)), new Date()); l.setId(idGenerator.getId()); return l; }
/** * Returns the <tt>int</tt> value of this literal. * * @return The <tt>int</tt> value of the literal. * @throws NumberFormatException If the literal's label cannot be represented by a <tt>int</tt>. */ @Override public int intValue() { return getIntContent().intValue(); }
/** * Read a KiWiIntLiteral serialized with writeIntLiteral from a DataInput source * * @param input the source * @return the de-serialized KiWiIntLiteral * @throws IOException */ public static KiWiIntLiteral readIntLiteral(DataInput input) throws IOException { long id = input.readLong(); if (id == -1) { return null; } long content = input.readLong(); KiWiUriResource dtype = readURI(input); Date created = new Date(input.readLong()); KiWiIntLiteral r = new KiWiIntLiteral(content, dtype, created); r.setId(id); return r; }
} else if(n instanceof KiWiIntLiteral) { KiWiIntLiteral l = (KiWiIntLiteral)n; createNodeList(rowArray, l.getId(), l.getClass(), l.getContent(), l.getDoubleContent(), l.getIntContent(), null, null, null, l.getDatatype(), l.getLocale(), l.getCreated()); } else if(n instanceof KiWiDoubleLiteral) { KiWiDoubleLiteral l = (KiWiDoubleLiteral)n;
/** * Creates a new <tt>xsd:short</tt>-typed literal representing the specified * value. * * @param value The value for the literal. * @return An <tt>xsd:short</tt>-typed literal for the specified value. */ @Override public Literal createLiteral(short value) { KiWiLiteral l = new KiWiIntLiteral(Long.valueOf(value), (KiWiUriResource) createURI(LiteralCommons.getXSDType(Short.class)), new Date()); l.setId(idGenerator.getId()); return l; }