private void syntaxError(String s) { errorHandler.error( new SyntaxError( syntaxErrorMessage( "Syntax error", s, in.getLinepos(), in.getCharpos()))); inErr = true; } private String readLang() {
private char readUnicode4Escape() { char buf[] = new char[] { in.readChar(), in.readChar(), in.readChar(), in.readChar()}; if (badEOF()) { return 0; } try { return (char) Integer.parseInt(new String(buf), 16); } catch (NumberFormatException e) { syntaxError("bad unicode escape sequence"); return 0; } } private void deprecated(String s) {
private boolean badEOF() { if (in.eof()) { syntaxError("premature end of file"); } return inErr; } protected String readURI() {
@Override public void read(Model model, Reader reader, String base) { if (!(reader instanceof BufferedReader)) { reader = new BufferedReader(reader); } this.model = model; this.base = base == null ? "" : (base + ": "); in = new IStream(reader); readRDF(); if (errCount != 0) { throw new SyntaxError( "unknown" ); } }
public RDFNode readNode() { skipWhiteSpace(); switch (in.nextChar()) { case '"' : return readLiteral(); case '<' : case '_' : return readResource(); default : syntaxError("unexpected input"); return null; } }
private boolean expect(String str) { for (int i = 0; i < str.length(); i++) { char want = str.charAt(i); if (badEOF()) return false; char inChar = in.readChar(); if (inChar != want) { //System.err.println("N-triple reader error"); syntaxError("expected \"" + str + "\""); return false; } } return true; } protected void skipWhiteSpace() {
char inChar = in.readChar(); if (badEOF()) return null; if (inChar == '\\') { char c = in.readChar(); if (in.eof()) { inErr = true; return null; if ('@' == in.nextChar()) { expect("@"); lang = readLang(); } else if ('-' == in.nextChar()) { expect("-"); deprecated("Language tags should be introduced with @ not -."); lang = ""; if ('^' == in.nextChar()) { String datatypeURI = null; if (!expect("^^<")) {
private void deprecated(String s) { errorHandler.warning( new SyntaxError( syntaxErrorMessage( "Deprecation warning", s, in.getLinepos(), in.getCharpos()))); }