Search in sources :

Example 21 with Token

use of org.apache.jena.riot.tokens.Token in project jena by apache.

the class JSONInputIterator method parseNodeInfo.

private String parseNodeInfo(String name) {
    if (lookingAt(TokenType.STRING)) {
        Token t = nextToken();
        String value = t.getImage();
        checkComma(TokenType.RBRACE);
        return value;
    } else {
        exception(peekToken(), "Unexpected Token, expected a string as the value for the %s property", name);
        return null;
    }
}
Also used : Token(org.apache.jena.riot.tokens.Token)

Example 22 with Token

use of org.apache.jena.riot.tokens.Token in project jena by apache.

the class JSONInputIterator method parseHeader.

private void parseHeader() {
    do {
        if (isPropertyName()) {
            Token t = nextToken();
            String name = t.getImage();
            checkColon();
            if (name.equals("vars")) {
                parseVars();
            } else if (name.equals("link")) {
                // Throw away the links
                skipLinks();
            } else {
                exception(t, "Unexpected property %s encountered in head object", name);
            }
            checkComma(TokenType.RBRACE);
        } else if (lookingAt(TokenType.RBRACE)) {
            nextToken();
            return;
        } else {
            exception(peekToken(), "Unexpected Token encountered while parsing head object");
        }
    } while (true);
}
Also used : Token(org.apache.jena.riot.tokens.Token)

Example 23 with Token

use of org.apache.jena.riot.tokens.Token in project jena by apache.

the class JSONInputIterator method parseToFirstResult.

private void parseToFirstResult() {
    if (lookingAt(TokenType.LBRACE)) {
        nextToken();
        if (isPropertyName()) {
            Token t = nextToken();
            String name = t.getImage();
            if (name.equals("bindings")) {
                checkColon();
                if (lookingAt(TokenType.LBRACKET)) {
                    nextToken();
                } else {
                    exception(peekToken(), "Unexpected Token encountered, expected a [ for the start of the bindings array");
                }
            } else {
                exception(t, "Unexpected Token encountered, expected the bindings property");
            }
        } else {
            exception(peekToken(), "Unexpected Token ecnountered, expected the bindings property");
        }
    } else {
        exception(peekToken(), "Unexpected Token encountered, expected a { to start the results list object");
    }
}
Also used : Token(org.apache.jena.riot.tokens.Token)

Example 24 with Token

use of org.apache.jena.riot.tokens.Token in project jena by apache.

the class JSONInputIterator method eof.

protected final boolean eof() {
    if (tokenEOF != null)
        return true;
    if (!moreTokens()) {
        tokenEOF = new Token(tokens.getLine(), tokens.getColumn());
        tokenEOF.setType(TokenType.EOF);
        return true;
    }
    return false;
}
Also used : Token(org.apache.jena.riot.tokens.Token)

Example 25 with Token

use of org.apache.jena.riot.tokens.Token in project jena by apache.

the class JSONParserBase method nextToken.

protected final Token nextToken() {
    if (eof())
        return tokenEOF;
    Token t = peekTokens.next();
    currLine = t.getLine();
    currCol = t.getColumn();
    //        if ( VERBOSE ) log.info("Move: " + t) ;
    return t;
}
Also used : Token(org.apache.jena.riot.tokens.Token)

Aggregations

Token (org.apache.jena.riot.tokens.Token)40 Node (org.apache.jena.graph.Node)16 RiotException (org.apache.jena.riot.RiotException)4 Tokenizer (org.apache.jena.riot.tokens.Tokenizer)4 AtlasException (org.apache.jena.atlas.AtlasException)2 RiotParseException (org.apache.jena.riot.RiotParseException)2 InputStream (java.io.InputStream)1 NoSuchElementException (java.util.NoSuchElementException)1 NotImplemented (org.apache.jena.atlas.lib.NotImplemented)1 Timer (org.apache.jena.atlas.lib.Timer)1 RDFDatatype (org.apache.jena.datatypes.RDFDatatype)1 IRI (org.apache.jena.iri.IRI)1 LabelToNode (org.apache.jena.riot.lang.LabelToNode)1 StreamRowRDF (org.apache.jena.riot.system.StreamRowRDF)1 StringType (org.apache.jena.riot.tokens.StringType)1 IRI (org.apache.jena.riot.tokens.TokenType.IRI)1 BindingMap (org.apache.jena.sparql.engine.binding.BindingMap)1 TDBException (org.apache.jena.tdb.TDBException)1