예제 #1
0
 /**
  * Insert Triple/Statement into graph
  *
  * @param s subject uriref
  * @param p predicate uriref
  * @param o value object (URIref or Literal)
  */
 public void add(URI s, URI p, Value o) {
   try {
     RepositoryConnection con = therepository.getConnection();
     try {
       ValueFactory myFactory = con.getValueFactory();
       Statement st = myFactory.createStatement(s, p, o);
       con.add(st);
     } finally {
       con.close();
     }
   } catch (Exception e) {
     // handle exception
   }
 }
예제 #2
0
 /**
  * UR Iref factory
  *
  * @param uri to build
  * @return URI resource
  */
 public URI URIref(String uri) {
   try {
     RepositoryConnection con = therepository.getConnection();
     try {
       ValueFactory vf = con.getValueFactory();
       return vf.createURI(uri);
     } finally {
       con.close();
     }
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
예제 #3
0
 /**
  * BNode factory
  *
  * @return BNode a blank node
  */
 public BNode bnode() {
   try {
     RepositoryConnection con = therepository.getConnection();
     try {
       ValueFactory vf = con.getValueFactory();
       return vf.createBNode();
     } finally {
       con.close();
     }
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
예제 #4
0
 /**
  * Literal factory
  *
  * @param s the literal value
  * @param typeuri uri representing the type (generally xsd)
  * @return Literal type
  */
 public org.openrdf.model.Literal Literal(String s, URI typeuri) {
   try {
     RepositoryConnection con = therepository.getConnection();
     try {
       ValueFactory vf = con.getValueFactory();
       if (typeuri == null) {
         return vf.createLiteral(s);
       } else {
         return vf.createLiteral(s, typeuri);
       }
     } finally {
       con.close();
     }
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
예제 #5
0
 public Value eval(RCvalue args) throws EvalException {
   if (args.size() != 2) throw new EvalException("usage: reduce(polygon, errtol])");
   PolygonValue pv1 = (PolygonValue) args.value(0);
   PolygonValue pv2 = (PolygonValue) args.value(1);
   boolean isContain = pv1.polygon().contains(pv2.polygon());
   double contain = 0;
   if (isContain) {
     contain = 1; // we don't have a boolean factory now.
   }
   return ValueFactory.create(contain);
 }