KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mckoi > database > TableCommitModificationEvent


1 /**
2  * com.mckoi.database.TableCommitModificationEvent 25 Feb 2003
3  *
4  * Mckoi SQL Database ( http://www.mckoi.com/database )
5  * Copyright (C) 2000, 2001, 2002 Diehl and Associates, Inc.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * Version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License Version 2 for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * Version 2 along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  *
20  * Change Log:
21  *
22  *
23  */

24
25 package com.mckoi.database;
26
27 import com.mckoi.util.IntegerVector;
28
29 /**
30  * An object that encapsulates all row modification information about a table
31  * when a change to the table is about to be committed. The object provides
32  * information about what rows in the table were changed
33  * (inserted/updated/deleted).
34  *
35  * @author Tobias Downer
36  */

37
38 public class TableCommitModificationEvent {
39
40   /**
41    * A SimpleTransaction that can be used to query tables in the database -
42    * the view of which will be the view when the transaction is committed.
43    */

44   private SimpleTransaction transaction;
45
46   /**
47    * The name of the table that is being changed.
48    */

49   private TableName table_name;
50
51   /**
52    * A normalized list of all rows that were added by the transaction being
53    * committed.
54    */

55   private int[] added_rows;
56
57   /**
58    * A normalized list of all rows that were removed by the transaction being
59    * committed.
60    */

61   private int[] removed_rows;
62
63   /**
64    * Constructs the event.
65    */

66   public TableCommitModificationEvent(SimpleTransaction transaction,
67                           TableName table_name, int[] added, int[] removed) {
68     this.transaction = transaction;
69     this.table_name = table_name;
70     this.added_rows = added;
71     this.removed_rows = removed;
72   }
73
74   /**
75    * Returns the Transaction that represents the view of the database when
76    * the changes to the table have been committed.
77    */

78   public SimpleTransaction getTransaction() {
79     return transaction;
80   }
81
82   /**
83    * Returns the name of the table.
84    */

85   public TableName getTableName() {
86     return table_name;
87   }
88
89   /**
90    * Returns the normalized list of all rows that were inserted or updated
91    * in this table of the transaction being committed. This is a normalized
92    * list which means if a row is inserted and then deleted in the transaction
93    * then it is not considered important and does not appear in this list.
94    */

95   public int[] getAddedRows() {
96     return added_rows;
97   }
98
99   /**
100    * Returns the normalized list of all rows that were deleted or updated
101    * in this table of the transaction being committed. This is a normalized
102    * list which means if a row is inserted and then deleted in the transaction
103    * then it is not considered important and does not appear in this list.
104    */

105   public int[] getRemovedRows() {
106     return removed_rows;
107   }
108
109 }
110
Popular Tags