use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class OpQuad method equivalent.
public boolean equivalent(OpQuadPattern opQuads) {
QuadPattern quads = opQuads.getPattern();
if (quads.size() != 1)
return false;
Quad q = quads.get(0);
return quad.equals(q);
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class OpQuadBlock method convertOp.
/** Convenience - convert to OpQuadPatterns which are more widely used (currently?) */
public Op convertOp() {
if (quads.size() == 0)
return OpTable.empty();
if (quads.size() == 1) {
Quad q = quads.get(0);
BasicPattern bgp = new BasicPattern();
bgp.add(q.asTriple());
return new OpQuadPattern(q.getGraph(), bgp);
}
List<OpQuadPattern> x = convert();
OpSequence ops = OpSequence.create();
for (OpQuadPattern oqp : x) ops.add(oqp);
return ops;
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class RdfTypesTest method quad_writable_02.
/**
* Basic quad writable round tripping test
*
* @throws IOException
* @throws InstantiationException
* @throws IllegalAccessException
* @throws ClassNotFoundException
*/
@Test
public void quad_writable_02() throws IOException, InstantiationException, IllegalAccessException, ClassNotFoundException {
Quad q = new Quad(Quad.defaultGraphNodeGenerated, NodeFactory.createBlankNode(), NodeFactory.createURI("http://predicate"), NodeFactory.createLiteral("value"));
QuadWritable qw = new QuadWritable(q);
testWriteRead(qw, qw);
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class QuadWritable method write.
@Override
public void write(DataOutput output) throws IOException {
if (this.get() == null)
throw new IOException("Null quads cannot be written using this class, consider using NodeTupleWritable instead");
// May not have yet prepared the Thrift triple
if (!this.quad.isSetS()) {
Quad tuple = this.get();
this.quad.setG(ThriftConvert.convert(tuple.getGraph(), false));
this.quad.setS(ThriftConvert.convert(tuple.getSubject(), false));
this.quad.setP(ThriftConvert.convert(tuple.getPredicate(), false));
this.quad.setO(ThriftConvert.convert(tuple.getObject(), false));
}
byte[] buffer;
try {
buffer = ThriftConverter.toBytes(this.quad);
} catch (TException e) {
throw new IOException(e);
}
output.writeInt(buffer.length);
output.write(buffer);
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class RdfTypesTest method quad_writable_01.
/**
* Basic quad writable round tripping test
*
* @throws IOException
* @throws InstantiationException
* @throws IllegalAccessException
* @throws ClassNotFoundException
*/
@Test
public void quad_writable_01() throws IOException, InstantiationException, IllegalAccessException, ClassNotFoundException {
Quad q = new Quad(Quad.defaultGraphNodeGenerated, NodeFactory.createURI("http://example"), NodeFactory.createURI("http://predicate"), NodeFactory.createLiteral("value"));
QuadWritable qw = new QuadWritable(q);
testWriteRead(qw, qw);
}
Aggregations