1 6 7 package com.hp.hpl.jena.rdf.model; 8 9 import com.hp.hpl.jena.rdf.model.impl.*; 10 11 27 public class ResourceFactory { 28 protected static Interface instance = new Impl(); 29 30 private ResourceFactory() { 31 } 32 33 37 public static Interface getInstance() { 38 return instance; 39 } 40 45 public static Interface setInstance(Interface newInstance) { 46 Interface previousInstance = instance; 47 instance = newInstance; 48 return previousInstance; 49 } 50 51 57 public static Resource createResource() { 58 return instance.createResource(); 59 } 60 61 68 public static Resource createResource(String uriref) { 69 return instance.createResource(uriref); 70 } 71 72 public static Literal createPlainLiteral( String string ) { 73 return instance.createPlainLiteral( string ); 74 } 75 76 83 public static Property createProperty(String uriref) { 84 return instance.createProperty(uriref); 85 } 86 87 95 public static Property createProperty(String namespace, String localName) { 96 return instance.createProperty(namespace, localName); 97 } 98 99 107 public static Statement createStatement( 108 Resource subject, 109 Property predicate, 110 RDFNode object) { 111 return instance.createStatement(subject, predicate, object); 112 } 113 114 116 public interface Interface { 117 118 122 public Resource createResource(); 123 124 129 public Resource createResource(String uriref); 130 131 136 public Literal createPlainLiteral( String string ); 137 138 143 public Property createProperty(String uriref); 144 145 151 public Property createProperty(String namespace, String localName); 152 153 160 public Statement createStatement( 161 Resource subject, 162 Property predicate, 163 RDFNode object); 164 } 165 166 static class Impl implements Interface { 167 168 Impl() { 169 } 170 171 public Resource createResource() { 172 return new ResourceImpl(); 173 } 174 175 public Resource createResource(String uriref) { 176 return new ResourceImpl(uriref); 177 } 178 179 public Literal createPlainLiteral( String string ) { 180 return new LiteralImpl( string ); 181 } 182 183 public Property createProperty(String uriref) { 184 return new PropertyImpl(uriref); 185 } 186 187 public Property createProperty(String namespace, String localName) { 188 return new PropertyImpl(namespace, localName); 189 } 190 191 public Statement createStatement( 192 Resource subject, 193 Property predicate, 194 RDFNode object) { 195 return new StatementImpl(subject, predicate, object); 196 } 197 198 } 199 } 200 201 | Popular Tags |