Examples of PeekReader


Examples of org.apache.jena.atlas.io.PeekReader

    public final Token setSubToken1(Token subToken)      { this.subToken1 = subToken ; return this ; }
    public final Token setSubToken2(Token subToken)      { this.subToken2 = subToken ; return this ; }
   
    static Token create(String s)
    {
        PeekReader pr = PeekReader.readString(s) ;
        TokenizerText tt = new TokenizerText(pr) ;
        if ( ! tt.hasNext() )
            throw new RiotException("No token") ;
        Token t = tt.next() ;
        if ( tt.hasNext() )
View Full Code Here

Examples of org.apache.jena.atlas.io.PeekReader

        return t ;
    }

    static Iter<Token> createN(String s)
    {
        PeekReader pr = PeekReader.readString(s) ;
        TokenizerText tt = new TokenizerText(pr) ;
        List<Token> x = new ArrayList<>() ;
        while(tt.hasNext())
            x.add(tt.next()) ;
        return Iter.iter(x) ;
View Full Code Here

Examples of org.apache.jena.atlas.io.PeekReader

        contains(r, "Zabc") ;
    }

    @Test public void unread2()
    {
        PeekReader r = make("abc") ;
        checkLineCol(r, INIT_LINE, INIT_COL) ;
        int ch = r.readChar() ;
        // Pushback does not move line/col backwards.
        checkLineCol(r, INIT_LINE, INIT_COL+1) ;
        assertEquals('b', r.peekChar()) ;
        checkLineCol(r, INIT_LINE, INIT_COL+1) ;
        r.pushbackChar('a') ;
        checkLineCol(r, INIT_LINE, INIT_COL+1) ;
        contains(r, "abc") ;
    }
View Full Code Here

Examples of org.apache.jena.atlas.io.PeekReader

        contains(r, "abc") ;
    }
   
    @Test public void unread3()
    {
        PeekReader r = make("") ;
        int ch = r.readChar() ;
        assertEquals(-1, r.peekChar()) ;
        r.pushbackChar('a') ;
        contains(r, "a") ;
    }
View Full Code Here

Examples of org.apache.jena.atlas.io.PeekReader

        contains(r, "a") ;
    }

    @Test public void unread4()
    {
        PeekReader r = make("") ;
        int ch = r.readChar() ;
        assertEquals(-1, r.peekChar()) ;
        r.pushbackChar('0') ;
        r.pushbackChar('1') ;
        r.pushbackChar('2') ;
        r.pushbackChar('3') ;
        contains(r, "3210") ;   // Backwards!
    }
View Full Code Here

Examples of org.apache.jena.atlas.io.PeekReader

        contains(r, "3210") ;   // Backwards!
    }

    @Test public void unread5()
    {
        PeekReader r = make("") ;
        long lineNum = r.getLineNum() ;
        long colNum = r.getColNum() ;
       
        checkLineCol(r, lineNum, colNum) ;
       
        r.pushbackChar('0') ;
        checkLineCol(r, lineNum, colNum) // Unmoved.
        r.pushbackChar('1') ;
        checkLineCol(r, lineNum, colNum) ;
        assertEquals('1', r.readChar()) ;
       
        checkLineCol(r, lineNum, colNum) // Unmoved.
        r.pushbackChar('2') ;
        r.pushbackChar('3') ;
        checkLineCol(r, lineNum, colNum) // Unmoved.
        assertEquals('3', r.peekChar()) ;
        contains(r, "320") ;
    }
View Full Code Here

Examples of org.apache.jena.atlas.io.PeekReader

        assertEquals("Column", colNum, r.getColNum()) ;
    }
   
    private void position(String contents)
    {
        PeekReader r = make(contents) ;
       
        int line = INIT_LINE ;
        int col = INIT_COL ;
        checkLineCol(r, line, col) ;
        assertEquals(0, r.getPosition()) ;
       
        for ( int i = 0 ; i < contents.length(); i++ )
        {
            int x = r.readChar() ;
            if ( x != -1 )
            {
                if ( x == '\n' )
                {
                    line++ ;
                    col = INIT_COL ;
                }
                else
                    col++ ;
            }
            assertEquals(contents.charAt(i), x) ;
            assertEquals(i+1, r.getPosition()) ;
            checkLineCol(r, line, col) ;
        }
        assertTrue(r.eof()) ;
    }
View Full Code Here

Examples of org.apache.jena.atlas.io.PeekReader

public class TestTokenizer extends BaseTest
{
    // WORKERS
    private static Tokenizer tokenizer(String string)
    {
        PeekReader r = PeekReader.readString(string) ;
        Tokenizer tokenizer = new TokenizerText(r) ;
        return tokenizer ;
    }
View Full Code Here

Examples of org.apache.jena.atlas.io.PeekReader

        assertEquals("Init col", 1, INIT_COL) ;
    }
   
    @Test public void read1()
    {
        PeekReader r = make("") ;
        checkLineCol(r, INIT_LINE, INIT_COL) ;
       
        int x = r.peekChar() ;
        assertEquals(-1, x) ;
        x = r.readChar() ;
        assertEquals(-1, x) ;
        x = r.readChar() ;
        assertEquals(-1, x) ;
    }
View Full Code Here

Examples of org.apache.jena.atlas.io.PeekReader

    }
   
    @Test public void read2()
    {
        // Assumes we start at (1,1)
        PeekReader r = make("a") ;
        checkLineCol(r, INIT_LINE, INIT_COL) ;
       
        int x = r.peekChar() ;
        assertEquals('a', x) ;
        checkLineCol(r, INIT_LINE, INIT_COL) ;
       
        x = r.readChar() ;
        checkLineCol(r, INIT_LINE, INIT_COL+1) ;
        assertEquals('a', x) ;
       
        x = r.peekChar() ;
        assertEquals(-1, x) ;
       
        x = r.readChar() ;
        assertEquals(-1, x) ;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.