1 5 6 7 package org.joseki.util; 8 9 import com.hp.hpl.jena.rdf.model.* ; 10 import org.apache.commons.logging.* ; 11 12 17 18 public class PrintUtils 19 { 20 22 static public String 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 fmt(Literal literal) 35 { 36 return literal.toString() ; 37 } 38 39 static public void dumpResource(Log log, Resource r) 40 { 41 42 String 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 82 | Popular Tags |