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

Examples of org.apache.clerezza.rdf.core.serializedform.Parser


            throw new UnsupportedOperationException("Parsing of JSON not yet implemented :(");
       } else if(isSupported(content.getMediaType())){ //from RDF serialisation
            RdfValueFactory valueFactory = RdfValueFactory.getInstance();
            Map<String,Representation> representations = new HashMap<String,Representation>();
            Set<NonLiteral> processed = new HashSet<NonLiteral>();
            Parser parser = ContextHelper.getServiceFromContext(Parser.class, servletContext);
            MGraph graph = new IndexedMGraph();
            try {
                parser.parse(graph,content.getEntityStream(), content.getMediaType().toString());
            } catch (UnsupportedParsingFormatException e) {
                //String acceptedMediaType = httpHeaders.getFirst("Accept");
                //throw an internal server Error, because we check in
                //isReadable(..) for supported types and still we get here a
                //unsupported format -> therefore it looks like an configuration
View Full Code Here


     */
    public static void reset() {
        // reset Clerezza objects
        tcManager = new TcManager();
        tcManager.addWeightedTcProvider(new SimpleTcProvider());
        parser = new Parser(); // add Jena-supported formats + RDF/JSON
        parser.bindParsingProvider(new JenaParserProvider());
        parser.bindParsingProvider(new RdfJsonParsingProvider());
        serializer = new Serializer(); // add Jena-supported formats + RDF/JSON
        serializer.bindSerializingProvider(new JenaSerializerProvider());
        serializer.bindSerializingProvider(new RdfJsonSerializingProvider());
View Full Code Here

    }
   
    @BeforeClass
    public static void init() throws IOException {
        //init the RDF parser
        rdfParser = new Parser();
        rdfParser.bindParsingProvider(new JenaParserProvider());
        rdfParser.bindParsingProvider(new RdfJsonParsingProvider());
        //init theTestData
    }
View Full Code Here

       
        serializer = new Serializer();
        serializer.bindSerializingProvider(new JenaSerializerProvider());
        serializer.bindSerializingProvider(new RdfJsonSerializingProvider());
       
        parser = new Parser();
        parser.bindParsingProvider(new JenaParserProvider());
        parser.bindParsingProvider(new RdfJsonParsingProvider());
    }
View Full Code Here

        final Dictionary<String,Object> config = new Hashtable<String,Object>();
        config.put(OfflineConfiguration.ONTOLOGY_PATHS, new String[] {"/ontologies", "/ontologies/registry"});
        OfflineConfiguration offline = new OfflineConfigurationImpl(config);
        // The registry manager can be updated via calls to createModel()
        regman = new RegistryManagerImpl(offline, new ClerezzaOntologyProvider(new SimpleTcProvider(),
                offline, new Parser()), config);
    }
View Full Code Here

    }

    @Test
    public void testImportModelFromSKOS() throws Exception {
        log.info(" --- testImportModelFromSKOS --- ");
        Parser parser = Parser.getInstance();
        parser.bindParsingProvider(new JenaParserProvider());
        Graph graph = parser.parse(getClass().getResourceAsStream("/sample-scheme.skos.rdf.xml"),
            SupportedFormat.RDF_XML);
        int imported = classifier.importConceptsFromGraph(graph, OntologicalClasses.SKOS_CONCEPT,
            Properties.SKOS_BROADER);
        assertEquals(imported, 4);
        assertEquals(0, classifier.getBroaderConcepts("http://example.com/ns#someconceptscheme/100").size());
View Full Code Here

            tcManager.getMGraph(graphName);
        } catch (NoSuchEntityException nsee) {
            tc = tcManager.createMGraph(graphName);
            InputStream fin = null;
            fin = getClass().getResourceAsStream("data.turtle");
            Parser parser = Parser.getInstance();
            tc.addAll(parser.parse(fin, "text/turtle"));
        }
    }
View Full Code Here

        final URLConnection con = url.openConnection();
        con.addRequestProperty("Accept", "application/rdf+xml");
        final InputStream inputStream = con.getInputStream();

        //get the singleton instance of Parser
        final Parser parser = Parser.getInstance();
        Graph deserializedGraph = parser.parse(inputStream, "application/rdf+xml");

        mGraph.addAll(deserializedGraph);
        for (GraphChangedListener graphChangedListener : graphChangedListeners) {
            graphChangedListener.graphChanged();
        }
View Full Code Here

            throw new UnsupportedOperationException("Parsing of JSON not yet implemented :(");
       } else if(isSupported(content.getMediaType())){ //from RDF serialisation
            RdfValueFactory valueFactory = RdfValueFactory.getInstance();
            Set<Representation> representations = new HashSet<Representation>();
            Set<NonLiteral> processed = new HashSet<NonLiteral>();
            Parser parser = ContextHelper.getServiceFromContext(Parser.class, servletContext);
            MGraph graph = new IndexedMGraph();
            try {
                parser.parse(graph,content.getEntityStream(), content.getMediaType().toString());
            } catch (UnsupportedParsingFormatException e) {
                //String acceptedMediaType = httpHeaders.getFirst("Accept");
                //throw an internal server Error, because we check in
                //isReadable(..) for supported types and still we get here a
                //unsupported format -> therefore it looks like an configuration
View Full Code Here

public class ExampleClerezza_01 {

  // Thanks to Reto
  public static void main(String[] args) {
    InputStream in = Utils.getResourceAsStream("data/data.ttl");
    Parser parser = Parser.getInstance();
    Graph g = parser.parse(in, SupportedFormat.TURTLE);
    Serializer serializer = Serializer.getInstance();
    serializer.serialize(System.out, g, SupportedFormat.N_TRIPLE);
  }
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.serializedform.Parser

Copyright © 2018 www.massapicom. 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.