KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > serversystem > deeprecordcopy > TableCopy


1 package com.daffodilwoods.daffodildb.server.serversystem.deeprecordcopy;
2
3 import java.util.*;
4
5 import com.daffodilwoods.daffodildb.server.datadictionarysystem.*;
6 import com.daffodilwoods.database.general.*;
7 import com.daffodilwoods.database.resource.*;
8 public class TableCopy {
9
10     QualifiedIdentifier tablename;
11     ArrayList parents = new ArrayList(3);
12     ArrayList children = new ArrayList(3);
13     int level;
14     TableInformation tableInf;
15
16     public TableCopy(QualifiedIdentifier tablename0) {
17         tablename = tablename0;
18     }
19
20
21     public void addChild(TableCopy childtable, _ReferentialConstraint referencedConstraint) throws DException{
22         children.add(new ChildInfo(childtable,referencedConstraint));
23     }
24
25     public void addParent(TableCopy parentTable) throws DException {
26         if(!parents.contains(parentTable))
27             parents.add(parentTable);
28             if(!parentTable.tablename.getName().equalsIgnoreCase(tablename.getName()) && parentTable.level >= level)
29                 level = parentTable.level+1;
30     }
31
32     public TableCopy[] getParents(){
33         return (TableCopy[])parents.toArray();
34     }
35
36     public ChildInfo[] getchildren(){
37         return (ChildInfo[])children.toArray(new ChildInfo[0]);
38     }
39
40
41     public void setTableInfo(TableInformation tableInfo){
42         tableInf = tableInfo;
43     }
44
45     public ChildInfo getChildInfo(TableCopy tablecopy) throws DException{
46         for (int i = 0; i < children.size(); i++) {
47             ChildInfo ch = (ChildInfo)children.get(i);
48             if(ch.childTableCopy == tablecopy)
49                 return ch;
50         }
51         throw new RuntimeException JavaDoc("TableCopy not found");
52     }
53
54     public TableCopy getParent(QualifiedIdentifier tableName) throws DException{
55         for (int i = 0; i < parents.size(); i++) {
56             TableCopy tc = (TableCopy)parents.get(i);
57              if(tc.tablename.getName().equalsIgnoreCase(tableName.getName()))
58             return tc;
59         }
60     return null;
61     }
62
63     public boolean isRecursive() {
64       return true;
65     }
66 }
67
Popular Tags