1 5 6 package com.hp.hpl.jena.n3; 7 8 import com.hp.hpl.jena.rdf.model.*; 10 11 18 19 public class N3JenaWriterTriples extends N3JenaWriterCommon 20 { 21 static public final int colWidth = 8 ; 22 23 protected void writeModel(Model model) 24 { 25 alwaysAllocateBNodeLabel = true ; 26 StmtIterator sIter = model.listStatements() ; 27 for ( ; sIter.hasNext() ; ) 28 { 29 Statement stmt = sIter.nextStatement() ; 30 String subjStr = formatResource(stmt.getSubject()) ; 31 32 out.print(subjStr) ; 33 padCol(subjStr) ; 34 out.print(minGapStr) ; 35 36 37 String predStr = formatProperty(stmt.getPredicate()) ; 38 out.print(predStr) ; 39 padCol(predStr) ; 40 out.print(minGapStr) ; 41 42 out.print( formatNode(stmt.getObject()) ) ; 43 out.println(" .") ; 44 } 45 sIter.close() ; 46 } 47 48 private void padCol(String tmp) 49 { 50 if ( tmp.length() < (colWidth) ) 51 out.print(pad( colWidth - tmp.length())) ; 52 } 53 } 54 55 81 | Popular Tags |