Package com.alibaba.fastjson.parser

Examples of com.alibaba.fastjson.parser.SymbolTable


                String symbol = symbols[i];
                table.findSymbol(symbol.toCharArray(), 0, symbol.length(), symbol.hashCode());
            }
        }

        SymbolTable table = new SymbolTable();
        for (int i = 0; i < symbols.length; ++i) {
            String symbol = symbols[i];
            char[] charArray = symbol.toCharArray();
            table.addSymbol(charArray, 0, charArray.length);
            //System.out.println((table.hash(symbol) & table.getIndexMask()) + "\t\t:" + symbol + "\t\t" + table.hash(symbol));
        }

        String symbol = "name";
        table.addSymbol(symbol.toCharArray(), 0, symbol.length());
        table.addSymbol(symbol.toCharArray(), 0, symbol.length());

        Assert.assertTrue(symbol == table.addSymbol("name".toCharArray(), 0, 4));
        Assert.assertTrue(symbol == table.addSymbol(" name".toCharArray(), 1, 4));
        Assert.assertTrue(symbol == table.addSymbol(" name ".toCharArray(), 1, 4));
        Assert.assertTrue(symbol != table.addSymbol(" namf ".toCharArray(), 1, 4));
    }
View Full Code Here


* @author wenshao<szujobs@hotmail.com>
*/
public class JSONScannerTest_symbol extends TestCase {

    public void test_0() throws Exception {
        SymbolTable symbolTable = new SymbolTable();

        JSONScanner lexer = new JSONScanner("\"name\"");
        String symbol = lexer.scanSymbol(symbolTable, '"');
        Assert.assertTrue("name".equals(symbol));

View Full Code Here

        String symbol2 = lexer.symbol(symbolTable);
        Assert.assertTrue("name".equals(symbol2));
    }

    public void test_0_1() throws Exception {
        SymbolTable symbolTable = new SymbolTable();

        JSONScanner lexer = new JSONScanner("\"name\"");
        lexer.scanString();
        String symbol = lexer.symbol(symbolTable);
        Assert.assertTrue("name".equals(symbol));
View Full Code Here

        Assert.assertTrue("name" != lexer.symbol(null));
    }

    public void test_1() throws Exception {
        SymbolTable symbolTable = new SymbolTable();

        JSONScanner lexer = new JSONScanner("\"nick name\"");
        String symbol = lexer.scanSymbol(symbolTable, '"');
        Assert.assertTrue("nick name".equals(symbol));
    }
View Full Code Here

        String symbol = lexer.scanSymbol(symbolTable, '"');
        Assert.assertTrue("nick name".equals(symbol));
    }

    public void test_2() throws Exception {
        SymbolTable symbolTable = new SymbolTable();

        JSONScanner lexer = new JSONScanner("\"nick \\\"name\"");
        String symbol = lexer.scanSymbol(symbolTable, '"');
        Assert.assertTrue("nick \"name" == symbol);
    }
View Full Code Here

        String symbol = lexer.scanSymbol(symbolTable, '"');
        Assert.assertTrue("nick \"name" == symbol);
    }

    public void test_2_1() throws Exception {
        SymbolTable symbolTable = new SymbolTable();

        JSONScanner lexer = new JSONScanner("\"nick \\\"name\"");
        lexer.scanString();
        String symbol = lexer.symbol(symbolTable);
        Assert.assertTrue("nick \"name" == symbol);
View Full Code Here

        Assert.assertTrue("nick \"name" != lexer.symbol(null));
    }

    public void test_3() throws Exception {
        SymbolTable symbolTable = new SymbolTable();

        JSONScanner lexer = new JSONScanner("\"nick \\\\name\"");
        String symbol = lexer.scanSymbol(symbolTable, '"');
        Assert.assertTrue("nick \\name" == symbol);
    }
View Full Code Here

        String symbol = lexer.scanSymbol(symbolTable, '"');
        Assert.assertTrue("nick \\name" == symbol);
    }

    public void test_4() throws Exception {
        SymbolTable symbolTable = new SymbolTable();

        JSONScanner lexer = new JSONScanner("\"nick \\/name\"");
        String symbol = lexer.scanSymbol(symbolTable, '"');
        Assert.assertTrue("nick /name" == symbol);
    }
View Full Code Here

        String symbol = lexer.scanSymbol(symbolTable, '"');
        Assert.assertTrue("nick /name" == symbol);
    }

    public void test_5() throws Exception {
        SymbolTable symbolTable = new SymbolTable();

        JSONScanner lexer = new JSONScanner("\"nick \\bname\"");
        String symbol = lexer.scanSymbol(symbolTable, '"');
        Assert.assertTrue("nick \bname" == symbol);
    }
View Full Code Here

        String symbol = lexer.scanSymbol(symbolTable, '"');
        Assert.assertTrue("nick \bname" == symbol);
    }

    public void test_6() throws Exception {
        SymbolTable symbolTable = new SymbolTable();

        JSONScanner lexer = new JSONScanner("\"nick \\f name\"");
        String symbol = lexer.scanSymbol(symbolTable, '"');
        Assert.assertTrue("nick \f name" == symbol);
    }
View Full Code Here

TOP

Related Classes of com.alibaba.fastjson.parser.SymbolTable

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.