KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sql99 > dql > listenerevents > ForeignKeyColumns


1 package com.daffodilwoods.daffodildb.server.sql99.dql.listenerevents;
2
3 import com.daffodilwoods.daffodildb.server.sql99.common.*;
4 import com.daffodilwoods.database.resource.*;
5
6 /**
7  * It represents the indexes of chained column who belongs to same table.
8  * <p>Title: </p>
9  * <p>Description: </p>
10  * <p>Copyright: Copyright (c) 2003</p>
11  * <p>Company: </p>
12  * @author unascribed
13  * @version 1.0
14  */

15
16 public class ForeignKeyColumns implements java.io.Serializable JavaDoc {
17
18    /**
19     * Represents the qualified name of chained column.
20     */

21
22    private String JavaDoc[] columns;
23
24    /**
25     * Represents the indexes of chained column.
26     */

27
28    private int[] indexes;
29
30    public ForeignKeyColumns(String JavaDoc[] columns0, Integer JavaDoc[] integer) {
31       columns = columns0;
32       int length = integer.length;
33       indexes = new int[length];
34       for (int i = 0; i < length; i++) {
35          indexes[i] = integer[i].hashCode();
36       }
37    }
38
39    /**
40     * Returns the indexes of chained columns.
41     * @return
42     * @throws DException
43     */

44
45    public int[] getIndexes() throws DException {
46       return indexes;
47    }
48
49    /**
50     * Returns the qualified name of chained column.
51     * @return
52     * @throws DException
53     */

54
55    public String JavaDoc[] getColumns() throws DException {
56       return columns;
57    }
58
59    /**
60     * Checks whether the passed array representing the qualified name is equal
61     * to qualified name of chained column.
62     * @param target
63     * @return
64     * @throws DException
65     */

66
67    public boolean ifMatches(String JavaDoc[] target) throws DException {
68       return GeneralPurposeStaticClass.compareArrays(columns, target);
69    }
70
71    /**
72     * It is used to check whether passed index belongs to the indexes of
73     * chained columns.
74     * @param index
75     * @return
76     * @throws DException
77     */

78
79    public boolean liesInRange(int index) throws DException {
80       int len = indexes.length;
81       for (int i = 0; i < len; i++) {
82          if (index == indexes[i]) {
83             return true;
84          }
85       }
86       return false;
87    }
88
89    /**
90     * It is used to check whether any foreign table is involved in chained
91     * column.
92     * @return
93     */

94
95    public boolean hasForeignTable() {
96       return columns.length > 1;
97    }
98 }
99
Popular Tags