Package org.jrdf.graph

Examples of org.jrdf.graph.Literal


        return node;
    }

    public Literal createLocalLiteral(String escapedForm) {
        currentId = nodePool.getNewNodeId();
        Literal node = mapper.convertToLiteral(escapedForm, currentId);
        nodePool.registerLiteral(node);
        return node;
    }
View Full Code Here


    public Node visitStr(StrOperator str) {
        final Node value = getValue(str);
        if (value != null) {
            Node node = value;
            if (Literal.class.isAssignableFrom(node.getClass())) {
                Literal literal = (Literal) value;
                return new LiteralImpl(literal.getLexicalForm());
            }
        }
        return null;
    }
View Full Code Here

    public Node visitLang(LangOperator lang) {
        final Node value = getValue(lang);
        if (value != null) {
            Node node = value;
            if (Literal.class.isAssignableFrom(node.getClass())) {
                Literal literal = (Literal) node;
                return new LiteralImpl(literal.getLanguage());
            }
        }
        return null;
    }
View Full Code Here

    public Literal convertToLiteral(String string, Long nodeId) {
        String[] strings = literalMatcher.parse(string);
        String lexicalForm = strings[0];
        String language = strings[1];
        String datatype = strings[2];
        Literal literal;
        if (language != null) {
            literal = new LiteralImpl(lexicalForm, language);
        } else if (datatype != null) {
            literal = new LiteralImpl(lexicalForm, URI.create(datatype));
        } else {
View Full Code Here

            throw new SAXException("unexpected literal");
        }

        PropertyElement propEl = (PropertyElement) peekStack(0);
        String datatype = propEl.getDatatype();
        Literal lit = createLiteral(text, xmlLang, datatype);

        NodeElement subject = (NodeElement) peekStack(1);
        PropertyElement predicate = (PropertyElement) peekStack(0);

        reportStatement(subject.getResource(), predicate.getURI(), lit);
View Full Code Here

        Iterator iter = atts.iterator();

        while (iter.hasNext()) {
            Att att = (Att) iter.next();
            URIReference predicate = createURIReference(att.getURI());
            Literal lit = createLiteral(att.getValue(), xmlLang, null);
            reportStatement(subject, predicate, lit);
        }
    }
View Full Code Here

                }

                if (isEmptyElt) {
                    NodeElement subject = (NodeElement) peekStack(1);

                    Literal lit = createLiteral("", null, RDF.XML_LITERAL.toString());

                    reportStatement(subject.getResource(), propURI, lit);

                    handleReification(lit);
                } else {
                    // The next string is an rdf:XMLLiteral
                    predicate.setDatatype(RDF.XML_LITERAL.toString());
                    saxFilter.setParseLiteralMode();
                }
            }
        } else if (isEmptyElt) {
            // empty element without an rdf:parseType attribute
            if (0 == atts.size() || 1 == atts.size() && atts.getAtt(RDF.BASE_URI.toString(), "datatype") != null) {
                // element had no attributes, or only the optional rdf:ID
                NodeElement subject = (NodeElement) peekStack(1);
                Literal lit = createLiteral("", xmlLang, null);
                reportStatement(subject.getResource(), propURI, lit);
                handleReification(lit);
            } else {
                // Create resource for the statement's object.
                SubjectNode resourceRes = getPropertyResource(atts);
View Full Code Here

        }
        return getLocalURIReference(uri, validate);
    }

    public Literal createLiteral(Object object) {
        final Literal literal = new LiteralImpl(object);
        return getLocalLiteral(literal.getEscapedForm());
    }
View Full Code Here

        return newURIReference;
    }

    private Literal getLocalLiteral(String escapedForm) {
        Long nodeId = nodePool.getNodeIdByString(escapedForm);
        Literal newLiteral;
        if (null != nodeId) {
            newLiteral = (Literal) nodePool.getNodeById(nodeId);
        } else {
            newLiteral = localizer.createLocalLiteral(escapedForm);
        }
View Full Code Here

    private ObjectNode getLocalizedObject(Node n)
            throws GraphElementFactoryException {
        if (n instanceof URIReference) {
            return getLocalizedResource(n);
        } else if (n instanceof Literal) {
            Literal l = (Literal) n;
            GraphElementFactory elementFactory = _connector.getElementFactory();
            if (l.getDatatypeURI() != null) {
                return elementFactory.createLiteral(l.getLexicalForm(),
                                                    l.getDatatypeURI());
            } else if (l.getLanguage() != null) {
                return elementFactory.createLiteral(l.getLexicalForm(),
                                                    l.getLanguage());
            } else {
                return elementFactory.createLiteral(l.getLexicalForm());
            }
        } else {
            throw new RuntimeException("Error localizing triple; "
                    + n.getClass().getName() + " is not a URIReference "
                    + "or a Literal");
View Full Code Here

TOP

Related Classes of org.jrdf.graph.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.