1 5 6 9 package com.hp.hpl.jena.n3; 10 11 import java.io.OutputStream ; 13 import java.io.Writer ; 14 15 import com.hp.hpl.jena.rdf.model.*; 16 17 33 34 35 36 public class N3JenaWriter implements RDFWriter 37 { 38 static public boolean DEBUG = false ; 40 41 static protected final String propBase = "http://jena.hpl.hp.com/n3/properties/" ; 43 44 47 48 static public final String propWriteSimple = "com.hp.hpl.jena.n3.N3JenaWriter.writeSimple" ; 49 50 51 static public final String propWriterName = propBase+"writer" ; 52 53 59 60 static public final String n3Writer = "N3" ; 61 62 67 static public final String n3WriterPrettyPrinter = "N3-PP" ; 68 69 73 static public final String n3WriterPlain = "N3-PLAIN" ; 74 75 79 static public final String n3WriterTriples = "N3-TRIPLES" ; 80 81 84 static public final String n3WriterTriplesAlt = "N3-TRIPLE" ; 85 86 90 static public final String turtleWriter = "TURTLE" ; 91 92 93 protected N3JenaWriterCommon writer = null ; 94 95 public N3JenaWriter() { writer = chooseWriter() ; } 96 public N3JenaWriter(N3JenaWriterCommon w) { writer = w ;} 97 98 N3JenaWriterCommon chooseWriter() 99 { 100 if ( System.getProperty(propWriteSimple, "false").equals("true")) 102 return new N3JenaWriterCommon() ; 103 104 String writerName = System.getProperty(propWriterName) ; 106 if ( writerName == null || 107 writerName.equals("N3") || writerName.equals(n3WriterPrettyPrinter) ) 108 return new N3JenaWriterPP() ; 109 110 if ( writerName.equalsIgnoreCase(n3WriterPlain) ) 111 return new N3JenaWriterCommon() ; 112 113 if ( writerName.equalsIgnoreCase(n3WriterTriples) || 114 writerName.equalsIgnoreCase(n3WriterTriplesAlt) ) 115 return new N3JenaWriterTriples() ; 116 117 if ( writerName.equalsIgnoreCase(turtleWriter) ) 118 { 119 N3JenaWriterPP w = new N3JenaWriterPP() ; 120 w.useWellKnownPropertySymbols = false ; 121 return w ; 122 } 123 124 return new N3JenaWriterPP() ; 126 } 127 128 129 132 133 public void write(Model model, Writer out, String base) 134 { 135 writer.write(model, out, base) ; 136 } 137 138 161 162 public void write(Model model, OutputStream out, String base) 163 { 164 writer.write(model, out, base) ; 165 } 166 167 168 171 public Object setProperty(String propName, Object propValue) 172 { 173 return writer.setProperty(propName, propValue) ; 174 } 175 176 179 public RDFErrorHandler setErrorHandler(RDFErrorHandler errHandler) 180 { 181 return writer.setErrorHandler(errHandler) ; 182 } 183 184 } 185 186 212 | Popular Tags |