Package org.openrdf.model.impl

Examples of org.openrdf.model.impl.URIImpl


   
    protected Value stringToValue(String s) {
      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


                _logger.error("Exception caught while handling statement", e);
      }
        }

        URI addBNode(String bnode) {
            URI uri = new URIImpl(s_bnodePrefix
                    + (m_uri != null ? m_uri.toString() + ":" : "") + System.currentTimeMillis() + ":" + bnode);

            m_bnodeIDToURI.put(bnode, uri);

            return uri;
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 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));
View Full Code Here

    }

    public void setProperty(final String key, final Object value) {
        if (key.equals(SailTokens.NAMED_GRAPH)) {
            try {
                URI namedGraph = new URIImpl(this.graph.expandPrefix(value.toString()));
                SailHelper.removeStatement(this.rawEdge, this.graph.getSailConnection().get());
                this.rawEdge = new ContextStatementImpl(this.rawEdge.getSubject(), this.rawEdge.getPredicate(), this.rawEdge.getObject(), namedGraph);
                SailHelper.addStatement(this.rawEdge, this.graph.getSailConnection().get());
            } catch (Exception e) {
                throw new RuntimeException(e.getMessage(), e);
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;
            }
View Full Code Here

    private Iterable<Edge> getOutEdges(final String... labels) {
        if (this.rawVertex instanceof Resource) {
            if (labels.length == 0) {
                return new SailEdgeIterable((Resource) this.rawVertex, null, null, this.graph);
            } else if (labels.length == 1) {
                return new SailEdgeIterable((Resource) this.rawVertex, new URIImpl(this.graph.expandPrefix(labels[0])), null, this.graph);
            } else {
                final List<Iterable<Edge>> edges = new ArrayList<Iterable<Edge>>();
                for (final String label : labels) {
                    edges.add(new SailEdgeIterable((Resource) this.rawVertex, new URIImpl(this.graph.expandPrefix(label)), null, this.graph));
                }
                return new MultiIterable<Edge>(edges);
            }
        } else {
            return Collections.emptyList();
View Full Code Here

    private Iterable<Edge> getInEdges(final String... labels) {
        if (labels.length == 0) {
            return new SailEdgeIterable(null, null, this.rawVertex, this.graph);
        } else if (labels.length == 1) {
            return new SailEdgeIterable(null, new URIImpl(this.graph.expandPrefix(labels[0])), this.rawVertex, this.graph);
        } else {
            final List<Iterable<Edge>> edges = new ArrayList<Iterable<Edge>>();
            for (final String label : labels) {
                edges.add(new SailEdgeIterable(null, new URIImpl(this.graph.expandPrefix(label)), this.rawVertex, this.graph));
            }
            return new MultiIterable<Edge>(edges);
        }
    }
View Full Code Here

            return new SailVertex(new BNodeImpl(resource.substring(2)), this);
        } else if ((literal = SailHelper.makeLiteral(resource, this)) != null) {
            return new SailVertex(literal, this);
        } else if (resource.contains(SailTokens.NAMESPACE_SEPARATOR) || resource.contains(SailTokens.FORWARD_SLASH) || resource.contains(SailTokens.POUND)) {
            resource = this.expandPrefix(resource);
            return new SailVertex(new URIImpl(resource), this);
        } else {
            return null;
        }
        //return new SailVertex(NTriplesUtil.parseValue(resource, new ValueFactoryImpl()), this.sailConnection);
    }
View Full Code Here

        if (!(outVertexValue instanceof Resource)) {
            throw new IllegalArgumentException(outVertex.toString() + " is not a legal URI or blank node");
        }
        try {
            URI labelURI = new URIImpl(this.expandPrefix(label));
            Statement statement = new StatementImpl((Resource) outVertexValue, labelURI, inVertexValue);
            SailHelper.addStatement(statement, this.sailConnection.get());
            return new SailEdge(statement, this);
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
View Full Code Here

TOP

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

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.