private void staxError(int line, int col, String msg) { errorHandler.error(msg, line, col) ; } }
public boolean checkBlank(Node node, long line, long col) { String x = node.getBlankNodeLabel() ; if ( x.indexOf(' ') >= 0 ) { handler.error("Illegal blank node label (contains a space): " + node, line, col) ; return false ; } return true ; } }
public boolean checkBlank(Node node, long line, long col) { String x = node.getBlankNodeLabel() ; if ( x.indexOf(' ') >= 0 ) { handler.error("Illegal blank node label (contains a space): "+node, line, col) ; return false ; } return true ; } }
public static boolean checkLiteral(String lexicalForm, String lang, RDFDatatype datatype, ErrorHandler handler, long line, long col) { if ( ! WarnOnBadLiterals ) return true ; boolean hasLang = lang != null && ! lang.equals("") ; if ( datatype != null && hasLang ) handler.error("Literal has datatype and language", line, col) ; // Datatype check (and plain literals are always well formed) if ( datatype != null ) return validateByDatatype(lexicalForm, datatype, handler, line, col) ; // No datatype. Language? if ( hasLang ) { // Not a perfect test. if ( lang.length() > 0 && ! langPattern.matcher(lang).matches() ) { handler.warning("Language not valid: "+lang, line, col) ; return false; } } return true ; }
private void error(String message, Object... args) { String msg = String.format(message, args); long line = reader.getLineNum(); long col = reader.getColNum(); errorHandler.error(msg, line, col); // We require that errors cause the tokenizer to stop so in case the // provided error handler does not, we throw an exception. throw new RiotParseException(message, line, col); } }
@Override public void error(Exception e) { Pair<Integer, Integer> p = getLineCol(e) ; errorHandler.error(e.getMessage(), p.getLeft(), p.getRight()) ; }
/** Check a triple against the RDF rules for a triple : subject is a IRI or bnode, predicate is a IRI and object is an bnode, literal or IRI */ public boolean checkTriple(Node subject, Node predicate, Node object, long line, long col) { boolean rc = true ; if ( subject == null || ( ! subject.isURI() && ! subject.isBlank() ) ) { handler.error("Subject is not a URI or blank node", line, col) ; rc = false ; } if ( predicate == null || ( ! predicate.isURI() ) ) { handler.error("Predicate not a URI", line, col) ; rc = false ; } if ( object == null || ( ! object.isURI() && ! object.isBlank() && ! object.isLiteral() ) ) { handler.error("Object is not a URI, blank node or literal", line, col) ; rc = false ; } return rc ; }
@Override public void error(Exception e) { Pair<Integer, Integer> p = getLineCol(e) ; errorHandler.error(e.getMessage(), p.getLeft(), p.getRight()) ; }
private void error(String message, Object... args) { String msg = String.format(message, args); long line = reader.getLineNum(); long col = reader.getColNum(); errorHandler.error(msg, line, col); // We require that errors cause the tokenizer to stop so in case the // provided error handler does not, we throw an exception. throw new RiotParseException(message, line, col); } }
private void error(String message, Object... args) { String msg = String.format(message, args); long line = reader.getLineNum(); long col = reader.getColNum(); errorHandler.error(msg, line, col); // We require that errors cause the tokenizer to stop so in case the // provided error handler does not, we throw an exception. throw new RiotParseException(message, line, col); } }
/** Check a triple against the RDF rules for a triple : subject is a IRI or bnode, predicate is a IRI and object is an bnode, literal or IRI */ public boolean checkTriple(Node subject, Node predicate, Node object, long line, long col) { boolean rc = true ; if ( subject == null || ( ! subject.isURI() && ! subject.isBlank() ) ) { handler.error("Subject is not a URI or blank node", line, col) ; rc = false ; } if ( predicate == null || ( ! predicate.isURI() ) ) { handler.error("Predicate not a URI", line, col) ; rc = false ; } if ( object == null || ( ! object.isURI() && ! object.isBlank() && ! object.isLiteral() ) ) { handler.error("Object is not a URI, blank node or literal", line, col) ; rc = false ; } return rc ; }
protected void checkTriple(Node subject, Node predicate, Node object, long line, long col) { if ( subject == null || (!subject.isURI() && !subject.isBlank()) ) { errorHandler.error("Subject is not a URI or blank node", line, col); throw new RiotException("Bad subject: " + subject); } if ( predicate == null || (!predicate.isURI()) ) { errorHandler.error("Predicate not a URI", line, col); throw new RiotException("Bad predicate: " + predicate); } if ( object == null || (!object.isURI() && !object.isBlank() && !object.isLiteral()) ) { errorHandler.error("Object is not a URI, blank node or literal", line, col); throw new RiotException("Bad object: " + object); } }
private void checkTriple(Node subject, Node predicate, Node object, long line, long col) { if ( subject == null || ( ! subject.isURI() && ! subject.isBlank() ) ) { errorHandler.error("Subject is not a URI or blank node", line, col) ; throw new RiotException("Bad subject: "+subject) ; } if ( predicate == null || ( ! predicate.isURI() ) ) { errorHandler.error("Predicate not a URI", line, col) ; throw new RiotException("Bad predicate: "+predicate) ; } if ( object == null || ( ! object.isURI() && ! object.isBlank() && ! object.isLiteral() ) ) { errorHandler.error("Object is not a URI, blank node or literal", line, col) ; throw new RiotException("Bad object: "+object) ; } }
private Node convert(AResource r) { if (!r.isAnonymous()) { // URI. String uriStr = r.getURI() ; if ( errorForSpaceInURI ) { // Special check for spaces in a URI. // Convert to an error like TokernizerText. if ( uriStr.contains(" ") ) { int i = uriStr.indexOf(' '); String s = uriStr.substring(0,i); String msg = String.format("Bad character in IRI (space): <%s[space]...>", s); riotErrorHandler.error(msg, -1, -1); throw new RiotParseException(msg, -1, -1); } } return NodeFactory.createURI(uriStr); } // String id = r.getAnonymousID(); Node rr = (Node) r.getUserData(); if (rr == null) { rr = NodeFactory.createBlankNode(); r.setUserData(rr); } return rr; }
@Override public void read(Reader reader, String baseURI, ContentType ct, StreamRDF output, Context context) { try { Object jsonObject = JsonUtils.fromReader(reader) ; read$(jsonObject, baseURI, ct, output, context) ; } catch (JsonProcessingException ex) { // includes JsonParseException // The Jackson JSON parser, or addition JSON-level check, throws up something. JsonLocation loc = ex.getLocation() ; errorHandler.error(ex.getOriginalMessage(), loc.getLineNr(), loc.getColumnNr()); throw new RiotException(ex.getOriginalMessage()) ; } catch (IOException e) { errorHandler.error(e.getMessage(), -1, -1); IO.exception(e) ; } }
protected void checkQuad(Node graph, Node subject, Node predicate, Node object, long line, long col) { // Allow blank nodes - syntax may restrict more. if ( graph != null && !graph.isURI() && !graph.isBlank() ) { errorHandler.error("Graph name is not a URI or blank node: " + FmtUtils.stringForNode(graph), line, col); throw new RiotException("Bad graph name: " + graph); } checkTriple(subject, predicate, object, line, col); }
public static boolean checkLiteral(Node node, ErrorHandler handler, long line, long col) { if ( !node.isLiteral() ) { handler.error("Not a literal: " + node, line, col) ; return false ; } return checkLiteral(node.getLiteralLexicalForm(), node.getLiteralLanguage(), node.getLiteralDatatype(), handler, line, col) ; }
public static boolean checkLiteral(Node node, ErrorHandler handler, long line, long col) { if ( ! node.isLiteral() ) { handler.error("Not a literal: "+node, line, col) ; return false ; } return checkLiteral(node.getLiteralLexicalForm(), node.getLiteralLanguage(), node.getLiteralDatatype(), handler, line, col) ; }
private void checkQuad(Node graph, Node subject, Node predicate, Node object, long line, long col) { if ( graph != null && ! graph.isURI() && ! graph.isBlank() ) // Allow blank nodes - syntax may restrict more. { errorHandler.error("Graph name is not a URI or blank node: "+FmtUtils.stringForNode(graph), line, col) ; throw new RiotException("Bad graph name: "+graph) ; } checkTriple(subject,predicate,object,line,col) ; }