Examples of PeekInputStream


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

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

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

        assertEquals("Init col", 1, INIT_COL) ;
    }
   
    @Test public void read1()
    {
        PeekInputStream in = make("") ;
        checkLineCol(in, INIT_LINE, INIT_COL) ;
       
        int x = in.peekByte() ;
        assertEquals(-1, x) ;
        x = in.readByte() ;
        assertEquals(-1, x) ;
        x = in.readByte() ;
        assertEquals(-1, x) ;
    }
View Full Code Here

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

    }
   
    @Test public void read2()
    {
        // Assumes we start at (1,1)
        PeekInputStream in = make("a") ;
        checkLineCol(in, INIT_LINE, INIT_COL) ;
       
        int x = in.peekByte() ;
        assertEquals('a', x) ;
        checkLineCol(in, INIT_LINE, INIT_COL) ;
       
        x = in.readByte() ;
        checkLineCol(in, INIT_LINE, INIT_COL+1) ;
        assertEquals('a', x) ;
       
        x = in.peekByte() ;
        assertEquals(-1, x) ;
       
        x = in.readByte() ;
        assertEquals(-1, x) ;
    }
View Full Code Here

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

    }

    @Test public void read3()
    {
        String c = "abcde" ;
        PeekInputStream in = make(c) ;
       
        for ( int i = 0 ; i < c.length(); i++ )
        {
            checkLineCol(in, INIT_LINE, i+INIT_COL) ;
            long z = in.getPosition() ;
            assertEquals(i, in.getPosition()) ;
            assertEquals(c.charAt(i), in.readByte()) ;
        }
        assertTrue(in.eof()) ;
    }
View Full Code Here

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

    }


    @Test public void read9()
    {
        PeekInputStream in = make("a\nb\n") ;
        checkLineCol(in, INIT_LINE, INIT_COL) ;
        int x = in.peekByte() ;
        assertEquals('a', x) ;
        checkLineCol(in, INIT_LINE, INIT_COL) ;
       
        x = in.readByte() ;
        assertEquals('a', x) ;
        checkLineCol(in, INIT_LINE, INIT_COL+1) ;

        x = in.readByte() ;
        assertEquals('\n', x) ;
        checkLineCol(in, INIT_LINE+1, INIT_COL) ;
    }
View Full Code Here

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

        checkLineCol(in, INIT_LINE+1, INIT_COL) ;
    }
   
    @Test public void unread1()
    {
        PeekInputStream in = make("abc") ;
        assertEquals('a', in.peekByte()) ;
        in.pushbackByte('Z') ;
        assertEquals('Z', in.peekByte()) ;
        contains(in, "Zabc") ;
    }
View Full Code Here

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

        contains(in, "Zabc") ;
    }

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

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

        contains(in, "abc") ;
    }
   
    @Test public void unread3()
    {
        PeekInputStream in = make("") ;
        int ch = in.readByte() ;
        assertEquals(-1, in.peekByte()) ;
        in.pushbackByte('a') ;
        contains(in, "a") ;
    }
View Full Code Here

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

        contains(in, "a") ;
    }

    @Test public void unread4()
    {
        PeekInputStream in = make("") ;
        int ch = in.readByte() ;
        assertEquals(-1, in.peekByte()) ;
        in.pushbackByte('0') ;
        in.pushbackByte('1') ;
        in.pushbackByte('2') ;
        in.pushbackByte('3') ;
        contains(in, "3210") ;   // Backwards!
    }
View Full Code Here

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

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

    @Test public void unread5()
    {
        PeekInputStream in = make("") ;
        long lineNum = in.getLineNum() ;
        long colNum = in.getColNum() ;
       
        checkLineCol(in, lineNum, colNum) ;
       
        in.pushbackByte('0') ;
        checkLineCol(in, lineNum, colNum) // Unmoved.
        in.pushbackByte('1') ;
        checkLineCol(in, lineNum, colNum) ;
        assertEquals('1', in.readByte()) ;
       
        checkLineCol(in, lineNum, colNum) // Unmoved.
        in.pushbackByte('2') ;
        in.pushbackByte('3') ;
        checkLineCol(in, lineNum, colNum) // Unmoved.
        assertEquals('3', in.peekByte()) ;
        contains(in, "320") ;
    }
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.