FileDocCategorySizeDatePackage
ANTLRHashString.javaAPI DocGlassfish v2 API2779Wed Aug 30 15:34:02 BST 2006persistence.antlr

ANTLRHashString

public class ANTLRHashString extends Object

Fields Summary
private String
s
private char[]
buf
private int
len
private CharScanner
lexer
private static final int
prime
Constructors Summary
public ANTLRHashString(char[] buf, int length, CharScanner lexer)



           
        this.lexer = lexer;
        setBuffer(buf, length);
    
public ANTLRHashString(CharScanner lexer)

        this.lexer = lexer;
    
public ANTLRHashString(String s, CharScanner lexer)

        this.lexer = lexer;
        setString(s);
    
Methods Summary
private final charcharAt(int index)

        return (s != null) ? s.charAt(index) : buf[index];
    
public booleanequals(java.lang.Object o)

        if (!(o instanceof ANTLRHashString) && !(o instanceof String)) {
            return false;
        }

        ANTLRHashString s;
        if (o instanceof String) {
            s = new ANTLRHashString((String)o, lexer);
        }
        else {
            s = (ANTLRHashString)o;
        }
        int l = length();
        if (s.length() != l) {
            return false;
        }
        if (lexer.getCaseSensitiveLiterals()) {
            for (int i = 0; i < l; i++) {
                if (charAt(i) != s.charAt(i)) {
                    return false;
                }
            }
        }
        else {
            for (int i = 0; i < l; i++) {
                if (lexer.toLower(charAt(i)) != lexer.toLower(s.charAt(i))) {
                    return false;
                }
            }
        }
        return true;
    
public inthashCode()

        int hashval = 0;
        int l = length();

        if (lexer.getCaseSensitiveLiterals()) {
            for (int i = 0; i < l; i++) {
                hashval = hashval * prime + charAt(i);
            }
        }
        else {
            for (int i = 0; i < l; i++) {
                hashval = hashval * prime + lexer.toLower(charAt(i));
            }
        }
        return hashval;
    
private final intlength()

        return (s != null) ? s.length() : len;
    
public voidsetBuffer(char[] buf, int length)

        this.buf = buf;
        this.len = length;
        s = null;
    
public voidsetString(java.lang.String s)

        this.s = s;
        buf = null;