1 5 6 package com.hp.hpl.jena.joseki; 7 8 import org.apache.commons.logging.* ; 9 import java.net.* ; 10 import java.io.* ; 11 12 import com.hp.hpl.jena.rdf.model.*; 13 import org.joseki.*; 14 15 19 28 29 public class HttpExecuteModel extends HttpExecute 30 { 31 private static Log log = LogFactory.getLog(HttpExecuteModel.class.getName()) ; 32 33 private Model model = null ; 34 35 40 41 protected HttpExecuteModel(String target, String opName) 42 throws MalformedURLException 43 { super(target, opName) ; } 44 45 48 protected HttpExecuteModel() { super(); } 49 50 51 55 56 protected void onSend(String mediaType, OutputStream out) 57 { 58 model.write(out, Joseki.getWriterType(mediaType)) ; 59 } 60 61 public Model getModel() 62 { 63 ensureModel() ; 64 return model ; 65 } 66 67 public void setModel(Model m) 68 { 69 if ( model != null ) 70 log.warn("Replacing allocated model") ; 71 model = m ; 72 } 73 74 77 protected void collect(Statement s) 78 { 79 ensureModel() ; 80 model.add(s) ; 81 } 82 83 protected void collect(Model m) 84 { 85 ensureModel() ; 86 model.add(m) ; 87 } 88 89 90 private void ensureModel() 91 { 92 if ( model == null ) 93 model = ModelFactory.createDefaultModel() ; 95 } 96 } 97 98 99 125 126 | Popular Tags |