Package org.jrdf.parser

Examples of org.jrdf.parser.ParseException


        checkNotEmptyString("s", s);
        try {
            String literal = nTripleUtil.unescapeLiteral(s);
            return graphElementFactory.createURIReference(create(literal));
        } catch (IllegalArgumentException iae) {
            throw new ParseException("Failed to create URI Reference: " + s, 1);
        } catch (GraphElementFactoryException e) {
            throw new ParseException("Failed to create URI Reference: " + s, 1);
        }
    }
View Full Code Here


            predicateMatcher);
        final ObjectNode object = (ObjectNode) nodeParser.parseNode(nodeMaps.getObjectMap(), objectMatcher);
        if (subject != null && predicate != null && object != null) {
            return tripleFactory.createTriple(subject, predicate, object);
        } else {
            throw new ParseException("Failed to parse all triples in line: " + printNode(subjectMatcher, subject) +
                ", " + printNode(predicateMatcher, predicate) + ", " + printNode(objectMatcher, object), 0);
        }
    }
View Full Code Here

            factory.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
            XMLReader xmlReader = factory.newSAXParser().getXMLReader();
            xmlReader.setContentHandler(saxFilter);
            xmlReader.parse(inputSource);
        } catch (ParserConfigurationException pce) {
            throw new ParseException(pce, -1, -1);
        } catch (SAXParseException e) {
            Exception wrappedExc = e.getException();
            if (null == wrappedExc) {
                wrappedExc = e;
            }
            throw new ParseException(wrappedExc, e.getLineNumber(), e.getColumnNumber());
        } catch (SAXException e) {
            Exception wrappedExc = e.getException();
            if (null == wrappedExc) {
                wrappedExc = e;
            }
            if (wrappedExc instanceof StatementHandlerException) {
                throw (StatementHandlerException) wrappedExc;
            } else {
                throw new ParseException(wrappedExc, -1, -1);
            }
        } finally {
            // Clean up
            saxFilter.clear();
            baseURI = null;
View Full Code Here

    public Literal parseLiteral(String s) throws ParseException {
        checkNotEmptyString("s", s);
        String[] matches = literalMatcher.parse(s);
        if (matches[0] == null && matches[1] == null && matches[2] == null) {
            throw new ParseException("Didn't find a matching literal: [" + s + "]", 1);
        }
        return createLiteral(matches[0], matches[1], matches[2], s);
    }
View Full Code Here

                return graphElementFactory.createLiteral(literal, URI.create(datatype));
            } else {
                return graphElementFactory.createLiteral(literal);
            }
        } catch (GraphElementFactoryException gefe) {
            throw new ParseException("Failed to create literal from line: " + originalString, 1);
        }
    }
View Full Code Here

        }
    }

    private void checkEitherLanguageOrDatatype(String language, String datatype, String s) throws ParseException {
        if (language != null && datatype != null) {
            throw new ParseException("Cannot create a literal with both language and data type from line: " + s, 1);
        }
    }
View Full Code Here

        } else if (matcher.group(BLANK_NODE_GROUP) != null) {
            return blankNodeParser.parseBlankNode(matcher.group(BLANK_NODE_GROUP));
        } else if (matcher.group(LITERAL_GROUP) != null) {
            return literalParser.parseLiteral(matcher.group(LITERAL_GROUP));
        } else {
            throw new ParseException("Failed to parse line: " + matcher.group(LINE_GROUP), 1);
        }
    }
View Full Code Here

            final String match = matcher.group(work.getKey());
            if (match != null) {
                return work.getValue().parse(match);
            }
        }
        throw new ParseException("Failed to parse line: " + matcher.group(LINE_GROUP), 1);
    }
View Full Code Here

    public BlankNode parseBlankNode(String s) throws ParseException {
        checkNotEmptyString("s", s);
        try {
            return parserBlankNodeFactory.createBlankNode(s);
        } catch (GraphElementFactoryException e) {
            throw new ParseException("Failed to create blank node: " + s, 1);
        }
    }
View Full Code Here

        checkNotEmptyString("s", s);
        try {
            String literal = nTripleUtil.unescapeLiteral(s);
            return graphElementFactory.createURIReference(create(literal));
        } catch (IllegalArgumentException iae) {
            throw new ParseException("Failed to create URI Reference: " + s, PREFIX_GROUP);
        } catch (GraphElementFactoryException e) {
            throw new ParseException("Failed to create URI Reference: " + s, PREFIX_GROUP);
        }
    }
View Full Code Here

TOP

Related Classes of org.jrdf.parser.ParseException

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.