Package org.apache.jena.riot.tokens

Examples of org.apache.jena.riot.tokens.Token


        }

        Tokenizer tokenizer = TokenizerFactory.makeTokenizerString(str) ;
        if ( ! tokenizer.hasNext() )
            throw new TDBException("Failed to tokenise: "+str) ;
        Token t = tokenizer.next() ;

        try {
            Node n = t.asNode() ;
            if ( n == null ) throw new TDBException("Not a node: "+str) ;
            return n ;
        } catch (RiotException ex)
        {
            throw new TDBException("Bad string for node: "+str) ;
View Full Code Here


    public static Node parse(String string)
    {
        Tokenizer tokenizer = TokenizerFactory.makeTokenizerString(string) ;
        if ( ! tokenizer.hasNext() )
            return null ;
        Token t = tokenizer.next();
        Node n = profile.create(null, t) ;
        if ( tokenizer.hasNext() )
            Log.warn(RiotLib.class, "String has more than one token in it: "+string) ;
        return n ;
    }
View Full Code Here

    // Version for proposed Turtle-in-TriG and keyword GRAPH
    protected final void oneNamedGraphBlock2() {
        // Which may not be a graph block.
        Node graphNode = null ;
        Token token = peekToken() ;
        Token t = token ; // Keep for error message.
        boolean mustBeNamedGraph = false ;

        if ( lookingAt(KEYWORD) ) {
            if ( token.getImage().equalsIgnoreCase("GRAPH") ) {
                nextToken() ;
                mustBeNamedGraph = true ;
                token = peekToken() ;
                // GRAPH <g>
                // GRAPH []
               
            } else
                exception(t, "Keyword '" + token.getImage() + "' not allowed here") ;
        }
        // GRAPH dealt with.
        // Starting points:
        // [ ] { .... }
        // :g { ... }
        // :s :p :o .
        // [ ] :p :o .
        // [ :p 123 ] :p :o .
        // () :p :o .
        // (1 2) :p :o .

        // XXX Find the Turtle code to do this for the Trutle case and refactor.
       
        if ( lookingAt(LBRACKET) ) {
            nextToken() ;
            token = peekToken() ;
            Node blank = profile.createBlankNode(graphNode, t.getLine(), t.getColumn()) ;
            if ( lookingAt(RBRACKET) ) {
                // Can be Turtle, "[] :predicate", or named graph "[] {"
                nextToken() ;
                if ( lookingAt(LBRACE) )
                    graphNode = blank ;
View Full Code Here

    // Old version , tradition trig with RDF 1.1 Turtle tokens.
    protected final void oneNamedGraphBlock() {
        // Directives are only between graph blocks.
        Node graphNode = null ;
        Token token = peekToken() ;
        Token t = token ; // Keep for error message.

        // [ ] { ... }
        if ( lookingAt(LBRACKET) ) {
            nextToken() ;
            token = peekToken() ;
            if ( lookingAt(RBRACKET) )
                exception(t, "Broken term: [ not followed by ]") ;

            graphNode = profile.createBlankNode(graphNode, t.getLine(), t.getColumn()) ;
            nextToken() ;
        } else {
            // <uri> { ... }
            // { ... }
            if ( token.isNode() ) {
View Full Code Here

            else
                exception(t, "Not a legal graph name: " + graphNode) ;
        } else
            setCurrentGraph(Quad.tripleInQuad) ;

        Token token = peekToken() ;

        // = is optional and old style.
        if ( lookingAt(EQUALS) ) {
            if ( profile.isStrictMode() )
                exception(token, "Use of = {} is not part of standard TriG: " + graphNode) ;
View Full Code Here

        if ( tokenEOF != null )
            return true ;
       
        if ( ! moreTokens() )
        {
            tokenEOF = new Token(tokens.getLine(), tokens.getColumn()) ;
            return true ;
        }
        return false ;
    }
View Full Code Here

        return peekTokens.hasNext() ;
    }
   
    final protected boolean lookingAt(TokenType tokenType)
    {
        Token t = peekTokens.peek() ;
        if ( t == null  )
            return tokenType == EOF ;
        return t.hasType(tokenType) ;
    }
View Full Code Here

        return t.hasType(tokenType) ;
    }
   
    final protected boolean lookingAtString()
    {
        Token t = peekTokens.peek() ;
        if ( t == null  )
            return false ;
        if ( t.hasType(TokenType.STRING1) ) return true ;
        if ( t.hasType(TokenType.STRING2) ) return true ;
        if ( t.hasType(TokenType.LONG_STRING1) ) return true ;
        if ( t.hasType(TokenType.LONG_STRING2) ) return true ;
        return false ;
    }
View Full Code Here

        return false ;
    }
   
    final protected boolean lookingAtNumber()
    {
        Token t = peekTokens.peek() ;
        if ( t == null  )
            return false ;
        if ( t.hasType(TokenType.INTEGER) ) return true ;
        if ( t.hasType(TokenType.HEX) )     return true ;
        if ( t.hasType(TokenType.DECIMAL) ) return true ;
        if ( t.hasType(TokenType.DOUBLE) )  return true ;
        return false ;
    }
View Full Code Here

    final protected Token nextToken()
    {
        if ( eof() )
            return tokenEOF ;
       
        Token t = peekTokens.next() ;
        currLine = t.getLine() ;
        currCol = t.getColumn() ;
//        if ( VERBOSE ) log.info("Move: " + t) ;
        return t ;
    }
View Full Code Here

TOP

Related Classes of org.apache.jena.riot.tokens.Token

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.