FileDocCategorySizeDatePackage
TableAliasLookup.javaAPI DocGlassfish v2 API6405Tue May 22 16:54:34 BST 2007oracle.toplink.essentials.internal.expressions

TableAliasLookup

public class TableAliasLookup extends Object implements Serializable
INTERNAL: Represents the aliased tables an ObjectExpression will be translated to, along with any of its derived TableExpressions. For bug 2778339 / CR 2456, this Lookup also represents identity. Two expressions with the same Lookup will be translated to the same table(s).

Fields Summary
protected DatabaseTable[]
keys
protected DatabaseTable[]
values
protected int
lastUsed
protected boolean
haveBeenAddedToStatement
Constructors Summary
public TableAliasLookup()
TableAliasLookup constructor comment.

        super();
        keys = new DatabaseTable[5];
        values = new DatabaseTable[5];
        lastUsed = 0;
    
public TableAliasLookup(int initialSize)
TableAliasLookup constructor comment.

        super();
        keys = new DatabaseTable[initialSize];
        values = new DatabaseTable[initialSize];
        lastUsed = 0;
    
Methods Summary
public voidaddToHashtable(java.util.Hashtable aHashTable)

        for (int i = 0; i < lastUsed; i++) {
            aHashTable.put(keys[i], values[i]);
        }
    
public oracle.toplink.essentials.internal.helper.DatabaseTableget(oracle.toplink.essentials.internal.helper.DatabaseTable key)

        int index = lookupIndexOf(key);
        if (index == -1) {
            return null;
        }
        return values[index];
    
private voidgrow()

        DatabaseTable[] newKeys = new DatabaseTable[(lastUsed * 2)];
        DatabaseTable[] newValues = new DatabaseTable[(lastUsed * 2)];

        for (int i = 0; i < lastUsed; i++) {
            newKeys[i] = keys[i];
            newValues[i] = values[i];
        }
        keys = newKeys;
        values = newValues;
    
public booleanhaveBeenAddedToStatement()
INTERNAL: Answers if the aliases have already been added to a statement. This insures that a subselect will not re-add aliases already in a parent FROM clause. For CR#4223

        return haveBeenAddedToStatement;
    
public booleanisEmpty()
isEmpty method comment.

        return keys[0] == null;
    
public oracle.toplink.essentials.internal.helper.DatabaseTablekeyAtValue(oracle.toplink.essentials.internal.helper.DatabaseTable value)

        int index = lookupValueIndexOf(value);
        if (index == -1) {
            return null;
        }
        return keys[index];
    
public oracle.toplink.essentials.internal.helper.DatabaseTable[]keys()

        return keys;
    
private intlookupIndexOf(oracle.toplink.essentials.internal.helper.DatabaseTable table)

        for (int i = 0; i < lastUsed; i++) {
            if (keys[i].equals(table)) {
                return i;
            }
        }
        return -1;
    
private intlookupValueIndexOf(oracle.toplink.essentials.internal.helper.DatabaseTable table)

        for (int i = 0; i < lastUsed; i++) {
            if (values[i].equals(table)) {
                return i;
            }
        }
        return -1;
    
public oracle.toplink.essentials.internal.helper.DatabaseTableput(oracle.toplink.essentials.internal.helper.DatabaseTable key, oracle.toplink.essentials.internal.helper.DatabaseTable value)
put method comment.

        int index = lookupIndexOf(key);
        if (index == -1) {
            keys[lastUsed] = key;
            values[lastUsed++] = value;
            if (lastUsed >= keys.length) {
                grow();
            }
        } else {
            values[index] = value;
        }
        return value;
    
public voidsetHaveBeenAddedToStatement(boolean value)
INTERNAL: Called when aliases are added to a statement. This insures that a subselect will not re-add aliases already in a parent FROM clause. For CR#4223

        haveBeenAddedToStatement = value;
    
public intsize()
size method comment.

        return lastUsed;
    
public java.lang.StringtoString()

        int max = size() - 1;
        StringBuffer buf = new StringBuffer();
        buf.append("{");

        for (int i = 0; i <= max; i++) {
            String s1 = keys[i].toString();
            String s2 = values[i].toString();
            buf.append(s1 + "=" + s2);
            if (i < max) {
                buf.append(", ");
            }
        }
        buf.append("}");
        return buf.toString();
    
public oracle.toplink.essentials.internal.helper.DatabaseTable[]values()

        return values;