com.alibaba.druid.sql.parser
Class SymbolTable

java.lang.Object
  extended by com.alibaba.druid.sql.parser.SymbolTable

public class SymbolTable
extends Object

Author:
wenshao

Field Summary
static int DEFAULT_TABLE_SIZE
          Default table size.
static int MAX_SIZE
           
 
Constructor Summary
SymbolTable()
          Constructs a symbol table with a default number of buckets.
SymbolTable(int tableSize)
          Constructs a symbol table with a specified number of buckets.
 
Method Summary
 String addSymbol(char[] buffer, int offset, int len)
           
 String addSymbol(char[] buffer, int offset, int len, int hash)
          Adds the specified symbol to the symbol table and returns a reference to the unique symbol.
 String addSymbol(String symbol)
          Adds the specified symbol to the symbol table and returns a reference to the unique symbol.
 int getIndexMask()
           
static int hash(char[] buffer, int offset, int len)
           
static int hash(String symbol)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TABLE_SIZE

public static final int DEFAULT_TABLE_SIZE
Default table size.

See Also:
Constant Field Values

MAX_SIZE

public static final int MAX_SIZE
See Also:
Constant Field Values
Constructor Detail

SymbolTable

public SymbolTable()
Constructs a symbol table with a default number of buckets.


SymbolTable

public SymbolTable(int tableSize)
Constructs a symbol table with a specified number of buckets.

Method Detail

addSymbol

public String addSymbol(String symbol)
Adds the specified symbol to the symbol table and returns a reference to the unique symbol. If the symbol already exists, the previous symbol reference is returned instead, in order guarantee that symbol references remain unique.

Parameters:
symbol - The new symbol.

getIndexMask

public int getIndexMask()

addSymbol

public String addSymbol(char[] buffer,
                        int offset,
                        int len)

addSymbol

public String addSymbol(char[] buffer,
                        int offset,
                        int len,
                        int hash)
Adds the specified symbol to the symbol table and returns a reference to the unique symbol. If the symbol already exists, the previous symbol reference is returned instead, in order guarantee that symbol references remain unique.

Parameters:
buffer - The buffer containing the new symbol.
offset - The offset into the buffer of the new symbol.
len - The length of the new symbol in the buffer.

hash

public static final int hash(String symbol)

hash

public static final int hash(char[] buffer,
                             int offset,
                             int len)


Copyright © 2012 Alibaba Group. All Rights Reserved.