KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snipsnap > serialization > rdf > DAMLSerializer


1 package org.snipsnap.serialization.rdf;
2
3 import java.util.*;
4 import com.hp.hpl.jena.daml.*;
5 import java.io.Writer JavaDoc;
6 import com.hp.hpl.jena.daml.common.*;
7 import com.hp.hpl.mesa.rdf.jena.model.*;
8
9 import org.snipsnap.snip.Snip;
10 import org.snipsnap.serialization.rdf.vocabulary.*;
11
12 public class DAMLSerializer extends RDFSerializerBase {
13
14     public DAMLSerializer(int outputFormat) {
15         super(outputFormat);
16     }
17
18     protected Model createModel() {
19         return new DAMLModelImpl();
20     }
21
22     protected void addSingleSnipToModel(Snip snip, Model m) throws RDFException {
23         DAMLModelImpl model = (DAMLModelImpl)m;
24         String JavaDoc snipName = snip.getName();
25         String JavaDoc snipContent = snip.getContent();
26         System.out.println("**** SnipDAMLSerializer is serializing snip \"" + snip.getName() + "\" (dummy) ... ");
27         // put this into SNIP?
28
DAMLClass snipClass = model.createDAMLClass(SNIP.getURI() + "snip");
29         DAMLInstance snipInstance = model.createDAMLInstance(snipClass, _uriPrefix + '#' + snip.getName());
30         DAMLObjectProperty prop = model.createDAMLObjectProperty(SNIP.getURI() + "name");
31         snipInstance.addProperty(prop, snipName);
32         prop = model.createDAMLObjectProperty(SNIP.getURI() + "content");
33         snipInstance.addProperty(prop, snipContent);
34
35         /*
36         DAMLList snipChildren = model.createDAMLList( _uriPrefix + '#' + "snipChildren" );
37         // TODO: test if list is empty ...
38         Iterator iterator = getChildrenIterator( snip );
39         while (iterator.hasNext()) {
40             Snip child = (Snip) iterator.next();
41             DAMLCommon element = model.createDAMLValue( _uriPrefix + '#' + child.getName(),
42                                                         snipClass, null );
43             snipChildren.add( element );
44         }
45         snipChildren.setRestNil();
46         snipInstance.addProperty( model.createDAMLObjectProperty( SNIP.getURI()+ "children"), snipChildren);
47         // snipResource.addProperty(RDF.predicate, snipChildren);
48         */

49     }
50
51     protected void writeModel(Model model, Writer JavaDoc writer) throws RDFException {
52     }
53
54     protected void recursiveFillModel(Snip snip, Model model, int depth) throws RDFException {
55     }
56 }
57
Popular Tags