01: /*
02: * (c) Copyright 2003, 2004, Hewlett-Packard Development Company, LP
03: * All rights reserved.
04: * [See end of file]
05: * $Id: Tutorial11.java,v 1.5 2007/11/14 09:51:57 chris-dollin Exp $
06: */
07: package jena.examples.rdf;
08:
09: import com.hp.hpl.jena.rdf.model.*;
10: import com.hp.hpl.jena.vocabulary.*;
11:
12: import java.io.PrintWriter;
13:
14: /** Tutorial 11 - more on literals
15: *
16: * @author bwm - updated by kers/Daniel
17: * @version Release='$Name: $' Revision='$Revision: 1.5 $' Date='$Date: 2007/11/14 09:51:57 $'
18: */
19: public class Tutorial11 extends Object {
20:
21: public static void main(String args[]) {
22: // create an empty graph
23: Model model = ModelFactory.createDefaultModel();
24:
25: // create the resource
26: Resource r = model.createResource();
27:
28: // add the property
29: r.addProperty(RDFS.label, model.createLiteral("chat", "en"))
30: .addProperty(RDFS.label,
31: model.createLiteral("chat", "fr")).addProperty(
32: RDFS.label,
33: model.createLiteral("<em>chat</em>", true));
34:
35: // write out the graph
36: model.write(new PrintWriter(System.out));
37: System.out.println();
38:
39: // create an empty graph
40: model = ModelFactory.createDefaultModel();
41:
42: // create the resource
43: r = model.createResource();
44:
45: // add the property
46: r.addProperty(RDFS.label, "11").addLiteral(RDFS.label, 11);
47:
48: // write out the graph
49: model.write(System.out, "N-TRIPLE");
50: }
51: }
52:
53: /*
54: * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
55: * All rights reserved.
56: *
57: * Redistribution and use in source and binary forms, with or without
58: * modification, are permitted provided that the following conditions
59: * are met:
60: * 1. Redistributions of source code must retain the above copyright
61: * notice, this list of conditions and the following disclaimer.
62: * 2. Redistributions in binary form must reproduce the above copyright
63: * notice, this list of conditions and the following disclaimer in the
64: * documentation and/or other materials provided with the distribution.
65: * 3. The name of the author may not be used to endorse or promote products
66: * derived from this software without specific prior written permission.
67: *
68: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
69: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
70: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
71: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
72: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
73: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
74: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
75: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
76: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
77: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78: */
|