Package org.openrdf.model.impl

Examples of org.openrdf.model.impl.LiteralImpl


      if (s.length() == 0) {
        return null;
      } else if (s.charAt(0) == 'r') {
        return new URIImpl(s.substring(1));
      } else {
        return new LiteralImpl(s.substring(1));
      }
    }
View Full Code Here


    public SailGraphSpecificTestSuite(final GraphTest graphTest) {
        super(graphTest);
    }

    public void testTypeConversion() {
        assertEquals(SailVertex.castLiteral(new LiteralImpl("marko", new URIImpl("http://www.w3.org/2001/XMLSchema#string"))).getClass(), String.class);
        assertEquals(SailVertex.castLiteral(new LiteralImpl("marko")).getClass(), String.class);
        assertEquals(SailVertex.castLiteral(new LiteralImpl("27", new URIImpl("http://www.w3.org/2001/XMLSchema#int"))).getClass(), Integer.class);
        assertEquals(SailVertex.castLiteral(new LiteralImpl("27", new URIImpl("http://www.w3.org/2001/XMLSchema#float"))).getClass(), Float.class);
        assertEquals(SailVertex.castLiteral(new LiteralImpl("27.0134", new URIImpl("http://www.w3.org/2001/XMLSchema#double"))).getClass(), Double.class);
        assertEquals(SailVertex.castLiteral(new LiteralImpl("hello", "en")), "hello");
    }
View Full Code Here

    public void testNavigateThroughLiteralVertex() {
        SailGraph graph = (SailGraph) graphTest.generateGraph();
        SailGraphFactory.createTinkerGraph(graph);

        Vertex v1 = graph.getVertex("tg:1");
        SailVertex vx = new SailVertex(new LiteralImpl("Marko"), graph);
        graph.addEdge(null, v1, vx, "tg:name");

        Vertex v = v1.getEdges(Direction.OUT, "tg:name").iterator().next().getVertex(Direction.IN);
        assertEquals("Marko", v.getProperty(SailTokens.VALUE));
        v1 = v.getEdges(Direction.IN, "tg:name").iterator().next().getVertex(Direction.OUT);
View Full Code Here

    public static Literal makeLiteral(final String resource, SailGraph graph) {
        final Matcher matcher = literalPattern.matcher(resource);
        if (matcher.matches()) {
            if (null != matcher.group(4))
                return new LiteralImpl(matcher.group(1), new URIImpl(graph.expandPrefix(matcher.group(4))));
            else
                return new LiteralImpl(matcher.group(1), matcher.group(6));
        } else {
            if (resource.startsWith("\"") && resource.endsWith("\"") && resource.length() > 1) {
                return new LiteralImpl(resource.substring(1, resource.length() - 1));
            } else {
                return null;
            }
        }
    }
View Full Code Here

            throw new RuntimeException(URI_BLANK_NODE_PROPERTIES);
        } else {
            boolean update = false;
            final Literal oldLiteral = (Literal) this.rawVertex;
            if (key.equals(SailTokens.DATATYPE)) {
                this.rawVertex = new LiteralImpl(oldLiteral.getLabel(), new URIImpl(this.graph.expandPrefix(value.toString())));
                update = true;
            } else if (key.equals(SailTokens.LANGUAGE)) {
                this.rawVertex = new LiteralImpl(oldLiteral.getLabel(), value.toString());
                update = true;
            }
            if (update) {
                this.updateLiteral(oldLiteral, (Literal) this.rawVertex);
            }
View Full Code Here

        if (this.rawVertex instanceof Resource) {
            throw new RuntimeException(URI_BLANK_NODE_PROPERTIES);
        } else {
            final Literal oldLiteral = (Literal) this.rawVertex;
            if (key.equals(SailTokens.DATATYPE) || key.equals(SailTokens.LANGUAGE)) {
                this.rawVertex = new LiteralImpl(oldLiteral.getLabel());
                this.updateLiteral(oldLiteral, (Literal) this.rawVertex);
            }
            if (key.equals(SailTokens.DATATYPE)) {
                return (T) oldLiteral.getDatatype().toString();
            } else if (key.equals(SailTokens.LANGUAGE)) {
View Full Code Here

            sc.begin();

            Vertex type = gSail.getVertex(RDF.TYPE);
            assertNull(type);

            sc.addStatement(RDF.TYPE, RDFS.LABEL, new LiteralImpl("type"));

            type = gSail.getVertex(RDF.TYPE);
            assertNotNull(type);
            assertEquals(RDF.TYPE.stringValue(), type.getProperty(GraphSail.VALUE));
        } finally {
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

    for (int i=0;i<512;i++) {
      sb.append(Character.toChars('A' + (i%26)));
    }
    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

TOP

Related Classes of org.openrdf.model.impl.LiteralImpl

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.