Package spark.spi.rdf

Examples of spark.spi.rdf.NamedNodeImpl


  }
 
  @Test
  public void testData() {
    NamedNodeImpl uri1 = new NamedNodeImpl(URI.create("http://example.org/foo"));
    NamedNodeImpl uri2 = new NamedNodeImpl(URI.create("http://example.org/bar"));
    TypedLiteralImpl lit1 = new TypedLiteralImpl("10", XsdTypes.INT);
    TypedLiteralImpl lit2 = new TypedLiteralImpl("20", XsdTypes.INT);
    List<List<Object>> data = toList(
        new Object[][] {
            new Object[] { iri(uri1), iri(uri2), toInt(lit1) },
View Full Code Here


  }
 
  @Test
  public void testDatatypes() {
    Date d = new Date();
    NamedNodeImpl uri = new NamedNodeImpl(URI.create("http://example.org/foo"));
    PlainLiteralImpl lit1 = new PlainLiteralImpl("bar");
    PlainLiteralImpl lit2 = new PlainLiteralImpl("baz", "en");
    TypedLiteralImpl lit3 = new TypedLiteralImpl(DateTime.format(d, TimeZone.getDefault()), XsdTypes.DATE_TIME);
    TypedLiteralImpl aInt = new TypedLiteralImpl("20", XsdTypes.INT);
    TypedLiteralImpl aLong = new TypedLiteralImpl("54687323427654", XsdTypes.LONG);
    TypedLiteralImpl aBool = new TypedLiteralImpl("true", XsdTypes.BOOLEAN);
    TypedLiteralImpl aFloat = new TypedLiteralImpl("3.14", XsdTypes.FLOAT);
    TypedLiteralImpl aDouble = new TypedLiteralImpl("98.6", XsdTypes.DOUBLE);
    TypedLiteralImpl aString = new TypedLiteralImpl("abcd", XsdTypes.STRING);
    BlankNodeImpl bn = new BlankNodeImpl("node0");
   
    List<List<Object>> data = toList(
        new Object[][] {
            new Object[] { iri(uri) },
            new Object[] { plainLit(lit1) },
            new Object[] { plainLit(lit2) },
            new Object[] { typedLit(lit3) },
            new Object[] { Integer.valueOf(aInt.getLexical()) },
            new Object[] { Long.valueOf(aLong.getLexical()) },
            new Object[] { Boolean.valueOf(aBool.getLexical()) },
            new Object[] { Float.valueOf(aFloat.getLexical()) },
            new Object[] { Double.valueOf(aDouble.getLexical()) },
            new Object[] { aString.getLexical() },
            new Object[] { bNode(bn) },
            new Object[] { null },
        });
   
    DummySherpaServer server = new DummySherpaServer(data);
    try {
      Solutions s = helpExecuteQuery(server, 10);
      String var = "a";
     
      Assert.assertTrue(s.next());
      Assert.assertEquals(uri, s.getBinding(var));
      Assert.assertEquals(uri.getURI(), s.getURI(var));
     
      Assert.assertTrue(s.next());
      Assert.assertEquals(lit1, s.getBinding(var));
      Assert.assertEquals(lit1, s.getLiteral(var));
     
View Full Code Here

    if (value == null) {
      return null;
    } else if (value instanceof RDFNode) {
      return (RDFNode) value;
    } else if (value instanceof IRI) {
      return new NamedNodeImpl(URI.create(((IRI)value).iri.toString()));
    } else if (value instanceof PlainLiteral) {
      PlainLiteral pl = (PlainLiteral)value;
      String lang = pl.language != null ? pl.language.toString() : null;
      return new PlainLiteralImpl(pl.lexical.toString(), lang);
    } else if (value instanceof TypedLiteral) {
View Full Code Here

    List<Map<String,RDFNode>> sl = new ArrayList<Map<String,RDFNode>>();
    for (int i = 0; i < 10; i++) {
      sl.add(new HashMap<String,RDFNode>());
    }
   
    NamedNode uriRef = new NamedNodeImpl(URI.create("http://example.org/test"));
    BlankNode bn = new BlankNodeImpl("1");
    Literal lit = new PlainLiteralImpl("foo");
   
    sl.get(0).put(var, uriRef);
    sl.get(1).put(var, bn);
    sl.get(2).put(var, lit);
    sl.get(3).put(var, new PlainLiteralImpl(A_DATE_TIME));
    sl.get(4).put(var, new PlainLiteralImpl("198765415975423167465132498465"));
    sl.get(5).put(var, new PlainLiteralImpl("true"));
    sl.get(6).put(var, new PlainLiteralImpl("3.14"));
    sl.get(7).put(var, new PlainLiteralImpl("98.6"));
    sl.get(8).put(var, new PlainLiteralImpl("42"));
   
    SolutionSet s = new SolutionSet(null, Arrays.asList("x"), sl);
    TestCursor.assertCursor(s, BEFORE_FIRST);
   
    assertTrue(s.next());
    TestCursor.assertCursor(s, FIRST);
    assertEquals(uriRef, s.getNamedNode(var));   
    assertEquals(uriRef.getURI(), s.getURI(var));   
   
    assertTrue(s.next());
    TestCursor.assertCursor(s, NONE);
    assertEquals(bn, s.getBlankNode(var));   
   
View Full Code Here

    Element elt = Element.valueOf(reader.getLocalName().toUpperCase());
    try {
      switch (elt) {
      case URI:
        if (reader.next() != CHARACTERS) throw new SparqlException("Unexpected data in URI binding");
        return new NamedNodeImpl(new URI(reader.getText()));
      case BNODE:
        if (reader.next() != CHARACTERS) throw new SparqlException("Unexpected data in BNode binding");
        return new BlankNodeImpl(reader.getText());
      case LITERAL:
        String dt = reader.getAttributeValue(null, DATATYPE);
View Full Code Here

      TestCursor.assertCursor(s, BEFORE_FIRST);
     
      // Check single row
      assertTrue(s.next());
      TestCursor.assertCursor(s, FIRST | LAST);
      assertEquals(new NamedNodeImpl(u), s.getBinding("x"));
      assertEquals(u, s.getURI("x"));
      assertEquals(new PlainLiteralImpl("John Doe"), s.getBinding("y"));
      assertFalse(s.isBound("z"));
      assertNull(s.getBinding("z"));
     
View Full Code Here

TOP

Related Classes of spark.spi.rdf.NamedNodeImpl

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.