Package org.htmlparser.lexer

Examples of org.htmlparser.lexer.Source


     * Test multi-byte read with a StringSource.
     */
    public void testStringSourceMultByte () throws IOException
    {
        String reference;
        Source source;
        char[] buffer;

        reference = "Now is the time for all good men to come to the aid of the party";
        source = new StringSource (reference);
        buffer = new char[reference.length ()];
        source.read (buffer, 0, buffer.length);
        assertTrue ("string incorrect", reference.equals (new String (buffer)));
        assertTrue ("extra character", -1 == source.read ());
        source.close ();
    }
View Full Code Here


    {
        String part1;
        String part2;
        String part3;
        String reference;
        Source source;
        char[] buffer;
        int length;

        part1 = "Now is the time ";
        part2 = "for all good men ";
        part3 = "to come to the aid of the party";
        reference = part1 + part2 + part3;
        source = new StringSource (reference);
        buffer = new char[reference.length ()];
        for (int i = 0; i < part1.length (); i++)
            buffer[i] = (char)source.read ();
        length = source.read (buffer, part1.length (), part2.length ());
        assertTrue ("incorrect length", part2.length () == length);
        length += part1.length ();
        for (int i = 0; i < part3.length (); i++)
            buffer[i + length] = (char)source.read ();
        assertTrue ("string incorrect", reference.equals (new String (buffer)));
        assertTrue ("extra character", -1 == source.read ());
        source.close ();
    }
View Full Code Here

    /**
     * Test ready of a StringSource.
     */
    public void testStringSourceReady () throws IOException
    {
        Source source;

        source = new StringSource ("Bb");
        assertTrue ("ready?", source.ready ());
        assertTrue ("erroneous character", 'B' == source.read ());
        assertTrue ("not ready", source.ready ());
        assertTrue ("erroneous character", 'b' == source.read ());
        assertTrue ("ready?", !source.ready ());
        assertTrue ("extra character", -1 == source.read ());
    }
View Full Code Here

TOP

Related Classes of org.htmlparser.lexer.Source

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.