Package org.openrdf.model

Examples of org.openrdf.model.Literal


      throw new RDFHandlerException(e.getMessage(), e);
    }
  }

  private Binding getBinding(Resource bindingNode) {
    Literal name = (Literal)model.filter(bindingNode, VARIABLE, null).objects().iterator().next();
    Value value = model.filter(bindingNode, VALUE, null).objects().iterator().next();
    return new BindingImpl(name.getLabel(), value);
  }
View Full Code Here


    }
    finally {
      statements.close();
    }

    Literal literal = (Literal)st.getObject();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(baos);
    out.writeObject(literal);
    out.close();

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    ObjectInputStream in = new ObjectInputStream(bais);
    Literal deserializedLiteral = (Literal)in.readObject();
    in.close();

    assertEquals(literal, deserializedLiteral);

    assertTrue(testCon.hasMatch(bob, name, literal, true));
View Full Code Here

  {
    String optional = "{ ?s :p1 ?v1 OPTIONAL {?s :p2 ?v2 FILTER(?v1<3) } }";
    URI s = vf.createURI("urn:test:s");
    URI p1 = vf.createURI("urn:test:p1");
    URI p2 = vf.createURI("urn:test:p2");
    Literal v1 = vf.createLiteral(1);
    Literal v2 = vf.createLiteral(2);
    Literal v3 = vf.createLiteral(3);
    testCon.add(s, p1, v1);
    testCon.add(s, p2, v2);
    testCon.add(s, p1, v3);
    String qry = "PREFIX :<urn:test:> SELECT ?s ?v1 ?v2 WHERE " + optional;
    TupleQuery query = testCon.prepareTupleQuery(QueryLanguage.SPARQL, qry);
View Full Code Here

    throws Exception
  {
    URI s = vf.createURI("urn:test:s");
    URI p1 = vf.createURI("urn:test:p1");
    URI p3 = vf.createURI("urn:test:p3");
    Literal one = vf.createLiteral(1);
    Literal three = vf.createLiteral(3);
    testCon.add(s, p1, one);
    testCon.add(s, p3, three);
    String qry = "PREFIX :<urn:test:>\nPREFIX xsd:  <http://www.w3.org/2001/XMLSchema#>\n"
        + "SELECT ?s WHERE { ?s :p1 ?one ; :p3 ?three FILTER (datatype(?one / ?three) = xsd:decimal) }";
    TupleQuery query = testCon.prepareTupleQuery(QueryLanguage.SPARQL, qry);
View Full Code Here

      sb.append(Character.toChars('A' + (i % 26)));
    }
    String EXAMPLE_NS = "urn:test:";
    URI subj = new URIImpl(EXAMPLE_NS + "PICASSO");
    URI pred = new URIImpl(EXAMPLE_NS + "PAINTS");
    Literal obj = new LiteralImpl("guernica" + sb.toString());

    testValueRoundTrip(subj, pred, obj);
  }
View Full Code Here

      sb.append(Character.toChars('A' + (i % 26)));
    }
    String EXAMPLE_NS = "urn:test:";
    URI subj = new URIImpl(EXAMPLE_NS + "PICASSO");
    URI pred = new URIImpl(EXAMPLE_NS + "PAINTS");
    Literal obj = new LiteralImpl("guernica" + sb.toString());

    testValueRoundTrip(subj, pred, obj);
  }
View Full Code Here

      sb.append(Character.toChars('A' + (i % 26)));
    }
    String EXAMPLE_NS = "urn:test:";
    URI subj = new URIImpl(EXAMPLE_NS + "PICASSO");
    URI pred = new URIImpl(EXAMPLE_NS + "PAINTS");
    Literal obj = new LiteralImpl("guernica" + sb.toString(), "es");

    testValueRoundTrip(subj, pred, obj);
  }
View Full Code Here

  public void testValueRoundTrip3()
    throws Exception
  {
    URI subj = new URIImpl(EXAMPLE_NS + PICASSO);
    URI pred = new URIImpl(EXAMPLE_NS + PAINTS);
    Literal obj = new LiteralImpl("guernica");

    testValueRoundTrip(subj, pred, obj);
  }
View Full Code Here

  public void testValueRoundTrip4()
    throws Exception
  {
    URI subj = new URIImpl(EXAMPLE_NS + PICASSO);
    URI pred = new URIImpl(EXAMPLE_NS + PAINTS);
    Literal obj = new LiteralImpl("guernica", "es");

    testValueRoundTrip(subj, pred, obj);
  }
View Full Code Here

  public void testValueRoundTrip5()
    throws Exception
  {
    URI subj = new URIImpl(EXAMPLE_NS + PICASSO);
    URI pred = new URIImpl(EXAMPLE_NS + PAINTS);
    Literal obj = new NumericLiteralImpl(3);

    testValueRoundTrip(subj, pred, obj);
  }
View Full Code Here

TOP

Related Classes of org.openrdf.model.Literal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.