KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > joseki > util > PrintUtils


1 /*
2  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
3  * [See end of file]
4  */

5
6
7 package org.joseki.util;
8
9 import com.hp.hpl.jena.rdf.model.* ;
10 import org.apache.commons.logging.* ;
11
12 /** Code to format things for output
13  *
14  * @author Andy Seaborne
15  * @version $Id: PrintUtils.java,v 1.4 2004/04/30 14:13:13 andy_seaborne Exp $
16  */

17  
18 public class PrintUtils
19 {
20 // static Log logger = LogFactory.getLog(PrintUtils.class) ;
21

22     static public String JavaDoc fmt(RDFNode n)
23     {
24         if ( n instanceof Resource )
25         {
26             Resource r = (Resource)n ;
27             if ( r.isAnon() )
28                 return "[]" ;
29             return r.getURI() ;
30         }
31         return n.toString() ;
32     }
33     
34     static public String JavaDoc fmt(Literal literal)
35     {
36         return literal.toString() ;
37     }
38     
39     static public void dumpResource(Log log, Resource r)
40     {
41         
42         String JavaDoc label = "" ;
43         log.info("Resource: "+fmt(r)) ;
44         
45         StmtIterator iter = r.listProperties() ;
46         for ( ; iter.hasNext() ; )
47         {
48             Statement s = iter.nextStatement() ;
49             Property p = s.getPredicate() ;
50             log.info(" "+p.getURI()) ;
51         }
52         iter.close() ;
53     }
54 }
55
56 /*
57  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
58  * All rights reserved.
59  *
60  * Redistribution and use in source and binary forms, with or without
61  * modification, are permitted provided that the following conditions
62  * are met:
63  * 1. Redistributions of source code must retain the above copyright
64  * notice, this list of conditions and the following disclaimer.
65  * 2. Redistributions in binary form must reproduce the above copyright
66  * notice, this list of conditions and the following disclaimer in the
67  * documentation and/or other materials provided with the distribution.
68  * 3. The name of the author may not be used to endorse or promote products
69  * derived from this software without specific prior written permission.
70  *
71  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
72  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
73  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
74  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
75  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
76  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
77  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
78  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
79  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
80  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
81  */

82
Popular Tags