Package org.apache.clerezza.rdf.core.serializedform

Examples of org.apache.clerezza.rdf.core.serializedform.SerializingProvider.serialize()


  public void testTurtleSerializer() {
    initializeGraph();
    SerializingProvider provider = new JenaSerializerProvider();

    ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
    provider.serialize(serializedGraph, mGraph.getGraph(),
        "text/turtle");
    InputStream in = new ByteArrayInputStream(serializedGraph.toByteArray());

    Graph deserializedGraph = parse(in, "TURTLE");
    // due to http://issues.trialox.org/jira/browse/RDF-6 we cannot just
View Full Code Here


  public void testTurtleSerializerWithParam() {
    initializeGraph();
    SerializingProvider provider = new JenaSerializerProvider();

    ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
    provider.serialize(serializedGraph, mGraph.getGraph(),
        "text/turtle;param=test");
    InputStream in = new ByteArrayInputStream(serializedGraph.toByteArray());

    Graph deserializedGraph = parse(in, "TURTLE");
    Assert.assertEquals(mGraph.getGraph(), deserializedGraph);
View Full Code Here

    initializeGraph();

    SerializingProvider provider = new JenaSerializerProvider();

    ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
    provider.serialize(serializedGraph, mGraph.getGraph(),
        "application/rdf+xml");
    InputStream in = new ByteArrayInputStream(serializedGraph.toByteArray());

    Graph deserializedGraph = parse(in, "RDF/XML-ABBREV");
    Assert.assertEquals(mGraph.getGraph(), deserializedGraph);
View Full Code Here

  public void testRdfNtSerializer() {
    initializeGraph();
    SerializingProvider provider = new JenaSerializerProvider();

    ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
    provider.serialize(serializedGraph, mGraph.getGraph(), "text/rdf+nt");
    InputStream in = new ByteArrayInputStream(serializedGraph.toByteArray());

    Graph deserializedGraph = parse(in, "N-TRIPLE");
    Assert.assertEquals(mGraph.getGraph(), deserializedGraph);
  }
View Full Code Here

  public void testRdfN3Serializer() {
    initializeGraph();
    SerializingProvider provider = new JenaSerializerProvider();

    ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
    provider.serialize(serializedGraph, mGraph.getGraph(), "text/rdf+n3");
    InputStream in = new ByteArrayInputStream(serializedGraph.toByteArray());

    Graph deserializedGraph = parse(in, "N3");
    Assert.assertEquals(mGraph.getGraph(), deserializedGraph);
  }
View Full Code Here

  @Test
  public void testSerializationOfBNode() {
    mGraph.add(new TripleImpl(node1, prop1, blank1));
    SerializingProvider provider = new RdfJsonSerializingProvider();
    ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
    provider.serialize(serializedGraph, mGraph, "application/rdf+json");
    Assert.assertTrue(serializedGraph.toString().contains("_:"));
  }

  @Test
  public void testSerializationOfRdfList() {
View Full Code Here

//    System.out.println(mGraph);

    SerializingProvider provider = new RdfJsonSerializingProvider();
    ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
    provider.serialize(serializedGraph, mGraph, "application/rdf+json");

//    System.out.println(serializedGraph.toString());

    ParsingProvider parsingProvider = new RdfJsonParsingProvider();
    ByteArrayInputStream jsonIn = new ByteArrayInputStream(serializedGraph.toByteArray());
View Full Code Here

    mGraph.add(new TripleImpl(blank1, prop5, typedLiteralA));
    mGraph.add(new TripleImpl(node1, prop6, blank1));

    SerializingProvider provider = new RdfJsonSerializingProvider();
    ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
    provider.serialize(serializedGraph, mGraph, "application/rdf+json");
//        System.out.println(serializedGraph.toString());
    ParsingProvider parsingProvider = new RdfJsonParsingProvider();
    ByteArrayInputStream jsonIn = new ByteArrayInputStream(serializedGraph.toByteArray());
    MGraph parsedMGraph = new SimpleMGraph();
    parsingProvider.parse(parsedMGraph, jsonIn, "application/rdf+json", null);
View Full Code Here

    int originalSize = mGraph.size();
   
    SerializingProvider provider = new RdfJsonSerializingProvider();
    ByteArrayOutputStream serializedGraph = new ByteArrayOutputStream();
    long start = System.currentTimeMillis();
    provider.serialize(serializedGraph, mGraph, "application/rdf+json");
    System.out.println("Serialized " + mGraph.size() + " Triples in " + (System.currentTimeMillis() - start) + " ms");
        ParsingProvider parsingProvider = new RdfJsonParsingProvider();
        ByteArrayInputStream jsonIn = new ByteArrayInputStream(serializedGraph.toByteArray());
        MGraph parsedMGraph = new SimpleMGraph();
        parsingProvider.parse(parsedMGraph, jsonIn, "application/rdf+json", null);
View Full Code Here

                if (RDF_JSON_TYPE.equals(mediaType)) serializer = new RdfJsonSerializingProvider();
                else if (N3_TYPE.equals(mediaType) || N_TRIPLE_TYPE.equals(mediaType)
                         || TEXT_PLAIN.equals(mediaType.toString())) serializer = new JenaSerializerProvider();

                // text/plain is interpreted as N3.
                if (serializer != null) serializer.serialize(out, mGraph,
                    TEXT_PLAIN.equals(mediaType.toString()) ? N3 : mediaType.toString());
            }
        }

        // JSON_LD not supported until both parser and serializer are stable.
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.