Package com.mckoi.database
Class TableModificationEvent
- java.lang.Object
-
- com.mckoi.database.TableModificationEvent
-
public class TableModificationEvent extends java.lang.ObjectThe event information of when a table is modified inside a transaction.
-
-
Field Summary
Fields Modifier and Type Field Description static intAFTEREvent that occurs after the actionstatic intAFTER_DELETEEvent for after a delete.static intAFTER_INSERTEvent for after an insert.static intAFTER_UPDATEEvent for after an update.static intBEFOREEvent that occurs before the actionstatic intBEFORE_DELETEEvent for before a delete.static intBEFORE_INSERTEvent for before an insert.static intBEFORE_UPDATEEvent for before an update.private DatabaseConnectionconnectionThe DatabaseConnection of the table that the modification occurred in.static intDELETEEvent type for delete action.private intevent_typeThe type of event that occurred.static intINSERTEvent type for insert action.private RowDatarow_dataA RowData object representing the row that is being inserted by this modification.private introw_indexThe row index of the table that is before removed by this modification.private TableNametable_nameThe name of the table that was modified.static intUPDATEEvent type for update action.
-
Constructor Summary
Constructors Modifier Constructor Description (package private)TableModificationEvent(DatabaseConnection connection, TableName table_name, int row_index, boolean before)Constructs a delete event.(package private)TableModificationEvent(DatabaseConnection connection, TableName table_name, int row_index, RowData row_data, boolean before)Constructs an update event.privateTableModificationEvent(DatabaseConnection connection, TableName table_name, int row_index, RowData row_data, int type, boolean before)General Constructor.(package private)TableModificationEvent(DatabaseConnection connection, TableName table_name, RowData row_data, boolean before)Constructs an insert event.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DatabaseConnectiongetDatabaseConnection()Returns the DatabaseConnection that this event fired in.RowDatagetRowData()Returns the RowData object that represents the change that is being made to the table either by an INSERT or UPDATE.intgetRowIndex()Returns the index of the row in the table that was affected by this event or -1 if event type is INSERT.TableNamegetTableName()Returns the name of the table of this modification.intgetType()Returns the event type.booleanisAfter()Returns true if this is a AFTER event.booleanisBefore()Returns true if this is a BEFORE event.booleanisDelete()Returns true if this is an DELETE event.booleanisInsert()Returns true if this is an INSERT event.booleanisUpdate()Returns true if this is an UPDATE event.booleanlistenedBy(int listen_t)Returns true if the given listener type should be notified of this type of table modification event.
-
-
-
Field Detail
-
BEFORE
public static final int BEFORE
Event that occurs before the action- See Also:
- Constant Field Values
-
AFTER
public static final int AFTER
Event that occurs after the action- See Also:
- Constant Field Values
-
INSERT
public static final int INSERT
Event type for insert action.- See Also:
- Constant Field Values
-
UPDATE
public static final int UPDATE
Event type for update action.- See Also:
- Constant Field Values
-
DELETE
public static final int DELETE
Event type for delete action.- See Also:
- Constant Field Values
-
BEFORE_INSERT
public static final int BEFORE_INSERT
Event for before an insert.- See Also:
- Constant Field Values
-
AFTER_INSERT
public static final int AFTER_INSERT
Event for after an insert.- See Also:
- Constant Field Values
-
BEFORE_UPDATE
public static final int BEFORE_UPDATE
Event for before an update.- See Also:
- Constant Field Values
-
AFTER_UPDATE
public static final int AFTER_UPDATE
Event for after an update.- See Also:
- Constant Field Values
-
BEFORE_DELETE
public static final int BEFORE_DELETE
Event for before a delete.- See Also:
- Constant Field Values
-
AFTER_DELETE
public static final int AFTER_DELETE
Event for after a delete.- See Also:
- Constant Field Values
-
connection
private DatabaseConnection connection
The DatabaseConnection of the table that the modification occurred in.
-
table_name
private TableName table_name
The name of the table that was modified.
-
event_type
private int event_type
The type of event that occurred.
-
row_data
private RowData row_data
A RowData object representing the row that is being inserted by this modification. This is set for INSERT and UPDATE events. If the event type is BEFORE then this data represents the new data in the table and can be modified. This represents the NEW information.
-
row_index
private int row_index
The row index of the table that is before removed by this modification. This is set for UPDATE and DELETE events. This represents the OLD information.
-
-
Constructor Detail
-
TableModificationEvent
private TableModificationEvent(DatabaseConnection connection, TableName table_name, int row_index, RowData row_data, int type, boolean before)
General Constructor.
-
TableModificationEvent
TableModificationEvent(DatabaseConnection connection, TableName table_name, RowData row_data, boolean before)
Constructs an insert event.
-
TableModificationEvent
TableModificationEvent(DatabaseConnection connection, TableName table_name, int row_index, RowData row_data, boolean before)
Constructs an update event.
-
TableModificationEvent
TableModificationEvent(DatabaseConnection connection, TableName table_name, int row_index, boolean before)
Constructs a delete event.
-
-
Method Detail
-
getDatabaseConnection
public DatabaseConnection getDatabaseConnection()
Returns the DatabaseConnection that this event fired in.
-
getType
public int getType()
Returns the event type.
-
isBefore
public boolean isBefore()
Returns true if this is a BEFORE event.
-
isAfter
public boolean isAfter()
Returns true if this is a AFTER event.
-
isInsert
public boolean isInsert()
Returns true if this is an INSERT event.
-
isUpdate
public boolean isUpdate()
Returns true if this is an UPDATE event.
-
isDelete
public boolean isDelete()
Returns true if this is an DELETE event.
-
getTableName
public TableName getTableName()
Returns the name of the table of this modification.
-
getRowIndex
public int getRowIndex()
Returns the index of the row in the table that was affected by this event or -1 if event type is INSERT.
-
getRowData
public RowData getRowData()
Returns the RowData object that represents the change that is being made to the table either by an INSERT or UPDATE. For a DELETE event this return null.
-
listenedBy
public boolean listenedBy(int listen_t)
Returns true if the given listener type should be notified of this type of table modification event. For example, if this is a BEFORE event then the BEFORE bit on the given type must be set and if this is an INSERT event then the INSERT bit on the given type must be set.
-
-