/** * Read a KiWiBooleanLiteral serialized with writeBooleanLiteral from a DataInput source * * @param input the source * @return the de-serialized KiWiBooleanLiteral * @throws IOException */ public static KiWiBooleanLiteral readBooleanLiteral(DataInput input) throws IOException { long id = input.readLong(); if(id == -1) { return null; } else { boolean content = input.readBoolean(); KiWiUriResource dtype = readURI(input); Date created = new Date(input.readLong()); KiWiBooleanLiteral r = new KiWiBooleanLiteral(content, dtype, created); r.setId(id); return r; } }
/** * Efficiently serialize a KiWiBooleanLiteral to a DataOutput destination. * * @param out the destination * @param literal the KiWiBooleanLiteral to serialize * @throws IOException */ public static void writeBooleanLiteral(DataOutput out, KiWiBooleanLiteral literal) throws IOException { if(literal == null) { out.writeLong(-1L); } else { out.writeLong(literal.getId()); out.writeBoolean(literal.booleanValue()); writeURI(out, literal.getType()); out.writeLong(literal.getCreated().getTime()); } }
} else if(n instanceof KiWiBooleanLiteral) { KiWiBooleanLiteral l = (KiWiBooleanLiteral)n; createNodeList(rowArray, l.getId(), l.getClass(), l.getContent(), null, null, null, null, l.booleanValue(), l.getDatatype(), l.getLocale(), l.getCreated()); } else if(n instanceof KiWiDateLiteral) { KiWiDateLiteral l = (KiWiDateLiteral)n;
insertNode.setString(2, booleanLiteral.getContent()); insertNode.setBoolean(3, booleanLiteral.booleanValue()); if (booleanLiteral.getType() != null) insertNode.setLong(4,booleanLiteral.getType().getId()); else throw new IllegalStateException("a boolean literal must have a datatype"); insertNode.setTimestamp(5, new Timestamp(booleanLiteral.getCreated().getTime()), calendarUTC);
boolean value = rnd.nextBoolean(); KiWiBooleanLiteral literal = new KiWiBooleanLiteral(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.getBoolean("bvalue")); Assert.assertEquals("boolean",result.getString("ntype"));
KiWiBooleanLiteral result = new KiWiBooleanLiteral(row.getBoolean(8),null,new Date(row.getTimestamp(11, calendarUTC).getTime())); result.setId(id); result.setType((KiWiUriResource) loadNodeById(row.getLong(10)));
result= new KiWiBooleanLiteral(bvalue, rtype);
} else if(n instanceof KiWiBooleanLiteral) { KiWiBooleanLiteral l = (KiWiBooleanLiteral)n; createNodeList(rowArray, l.getId(), l.getClass(), l.getContent(), null, null, null, null, l.booleanValue(), l.getDatatype(), l.getLocale(), l.getCreated()); } else if(n instanceof KiWiDateLiteral) { KiWiDateLiteral l = (KiWiDateLiteral)n;
insertNode.setString(2, booleanLiteral.getContent()); insertNode.setBoolean(3, booleanLiteral.booleanValue()); if (booleanLiteral.getType() != null) insertNode.setLong(4,booleanLiteral.getType().getId()); else throw new IllegalStateException("a boolean literal must have a datatype"); insertNode.setTimestamp(5, new Timestamp(booleanLiteral.getCreated().getTime()), calendarUTC);
KiWiBooleanLiteral result = new KiWiBooleanLiteral(row.getBoolean(8),null,new Date(row.getTimestamp(11, calendarUTC).getTime())); result.setId(id); result.setType((KiWiUriResource) loadNodeById(row.getLong(10)));
result= new KiWiBooleanLiteral(bvalue, rtype);
} else if(n instanceof KiWiBooleanLiteral) { KiWiBooleanLiteral l = (KiWiBooleanLiteral)n; createNodeList(rowArray, l.getId(), l.getClass(), l.getContent(), null, null, null, null, l.booleanValue(), l.getDatatype(), l.getLocale(), l.getCreated()); } else if(n instanceof KiWiDateLiteral) { KiWiDateLiteral l = (KiWiDateLiteral)n;
/** * Efficiently serialize a KiWiBooleanLiteral to a DataOutput destination. * * @param out the destination * @param literal the KiWiBooleanLiteral to serialize * @throws IOException */ public static void writeBooleanLiteral(DataOutput out, KiWiBooleanLiteral literal) throws IOException { if(literal == null) { out.writeLong(-1L); } else { out.writeLong(literal.getId()); out.writeBoolean(literal.booleanValue()); writeURI(out, literal.getType()); out.writeLong(literal.getCreated().getTime()); } }
/** * Creates a new <tt>xsd:boolean</tt>-typed literal representing the * specified value. * * @param value The value for the literal. * @return An <tt>xsd:boolean</tt>-typed literal for the specified value. */ @Override public Literal createLiteral(boolean value) { KiWiLiteral l = new KiWiBooleanLiteral(value, (KiWiUriResource) createURI(LiteralCommons.getXSDType(Boolean.class)), new Date()); l.setId(idGenerator.getId()); return l; }
/** * Read a KiWiBooleanLiteral serialized with writeBooleanLiteral from a DataInput source * * @param input the source * @return the de-serialized KiWiBooleanLiteral * @throws IOException */ public static KiWiBooleanLiteral readBooleanLiteral(DataInput input) throws IOException { long id = input.readLong(); if(id == -1) { return null; } else { boolean content = input.readBoolean(); KiWiUriResource dtype = readURI(input); Date created = new Date(input.readLong()); KiWiBooleanLiteral r = new KiWiBooleanLiteral(content, dtype, created); r.setId(id); return r; } }
} else if(n instanceof KiWiBooleanLiteral) { KiWiBooleanLiteral l = (KiWiBooleanLiteral)n; createNodeList(rowArray, l.getId(), l.getClass(), l.getContent(), null, null, null, null, l.booleanValue(), l.getDatatype(), l.getLocale(), l.getCreated()); } else if(n instanceof KiWiDateLiteral) { KiWiDateLiteral l = (KiWiDateLiteral)n;
result= new KiWiBooleanLiteral(bvalue, rtype, importDate); } else { nodesLoaded++;
result= new KiWiBooleanLiteral(bvalue, rtype, importDate); } else { nodesLoaded++;