コード例 #1
0
ファイル: RDFUtil.java プロジェクト: mepcotterell/cs8470-ads
  /** returns true if old triples from r were removed */
  public static boolean setUniqueObject(
      Model r, Resource subject, Resource predicate, RDFNode object) throws ModelException {

    Model old = r.find(subject, predicate, null);
    SetOperations.subtract(r, old);
    Statement stmt = get1(old);

    if (subject == null && stmt != null) subject = stmt.subject();
    if (predicate == null && stmt != null) predicate = stmt.predicate();

    r.add(r.getNodeFactory().createStatement(subject, predicate, object));
    return !old.isEmpty();
  }
コード例 #2
0
ファイル: RDFUtil.java プロジェクト: mepcotterell/cs8470-ads
 /** Returns the first triple of the model */
 public static Statement get1(Model m) throws ModelException {
   if (m == null || m.isEmpty()) return null;
   //    if(m.size() > 1)
   //      throw new RuntimeException("Model contains more than one triple");
   return (Statement) m.elements().nextElement();
 }