1 6 7 package com.hp.hpl.jena.rdf.model; 8 9 import com.hp.hpl.jena.rdf.model.impl.*; 10 import com.hp.hpl.jena.graph.*; 11 12 46 47 public class SimpleSelector extends Object implements Selector { 48 49 protected Resource subject; 50 protected Property predicate; 51 protected RDFNode object; 52 53 56 public SimpleSelector() { 57 subject = null; 58 predicate = null; 59 object = null; 60 } 61 62 74 public SimpleSelector(Resource subject, Property predicate, RDFNode object) { 75 this.subject = subject; 76 this.predicate = predicate; 77 this.object = object; 78 } 79 80 92 public SimpleSelector(Resource subject, Property predicate, boolean object) { 93 this(subject, predicate, String.valueOf( object ) ); 94 } 95 96 108 public SimpleSelector(Resource subject, Property predicate, long object) { 109 this(subject, predicate, String.valueOf( object ) ); 110 } 111 112 124 public SimpleSelector(Resource subject, Property predicate, char object) { 125 this(subject, predicate, String.valueOf( object ) ); 126 } 127 128 140 public SimpleSelector(Resource subject, Property predicate, float object) { 141 this(subject, predicate, String.valueOf( object ) ); 142 } 143 144 156 public SimpleSelector(Resource subject, Property predicate, double object) { 157 this(subject, predicate, String.valueOf( object ) ); 158 } 159 160 172 public SimpleSelector(Resource subject, Property predicate, String object) { 173 this( subject, predicate, object, "" ); 174 } 175 176 189 public SimpleSelector(Resource subject, Property predicate, 190 String object, String language) { 191 this.subject = subject; 192 this.predicate = predicate; 193 if (object != null) { 194 this.object = literal( object, language ); 195 } else { 196 this.object = null; 197 } 198 } 199 200 private Literal literal( String s, String lang ) 201 { return new LiteralImpl( Node.createLiteral( s, lang, false ), (ModelCom) null ); } 202 203 215 public SimpleSelector(Resource subject, Property predicate, Object object) { 216 this.subject = subject; 217 this.predicate = predicate; 218 if (object != null) { 219 this.object = literal( object.toString(), "" ); 220 } else { 221 this.object = null; 222 } 223 } 224 225 228 public Resource getSubject() { return subject; } 229 232 public Property getPredicate() { return predicate; } 233 236 public RDFNode getObject() { return object; } 237 238 246 public boolean isSimple() 247 { return this.getClass() == SimpleSelector.class; } 248 249 257 public boolean test(Statement s) { 258 return (subject == null || subject.equals(s.getSubject())) 259 && (predicate == null || predicate.equals(s.getPredicate())) 260 && (object == null || object.equals(s.getObject())) 261 && selects(s); 262 } 263 264 269 public boolean selects(Statement s) { 270 return true; 271 } 272 273 } 274 | Popular Tags |