001: /*_############################################################################
002: _##
003: _## SNMP4J-Agent - RowStatusEvent.java
004: _##
005: _## Copyright (C) 2005-2007 Frank Fock (SNMP4J.org)
006: _##
007: _## Licensed under the Apache License, Version 2.0 (the "License");
008: _## you may not use this file except in compliance with the License.
009: _## You may obtain a copy of the License at
010: _##
011: _## http://www.apache.org/licenses/LICENSE-2.0
012: _##
013: _## Unless required by applicable law or agreed to in writing, software
014: _## distributed under the License is distributed on an "AS IS" BASIS,
015: _## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016: _## See the License for the specific language governing permissions and
017: _## limitations under the License.
018: _##
019: _##########################################################################*/
020:
021: package org.snmp4j.agent.mo.snmp;
022:
023: import java.util.*;
024:
025: import org.snmp4j.agent.mo.*;
026: import org.snmp4j.PDU;
027:
028: public class RowStatusEvent extends DeniableEventObject {
029:
030: // private static final long serialVersionUID = 8808826350825049569L;
031:
032: private MOTable table;
033: private MOTableRow row;
034: private MOTableRow changeSet;
035: private int oldStatus;
036: private int newStatus;
037:
038: public RowStatusEvent(Object source, MOTable table, MOTableRow row,
039: MOTableRow changeSet, int oldStatus, int newStatus) {
040: this (source, table, row, changeSet, oldStatus, newStatus, false);
041: }
042:
043: public RowStatusEvent(Object source, MOTable table, MOTableRow row,
044: MOTableRow changeSet, int oldStatus, int newStatus,
045: boolean deniable) {
046: super (source, deniable);
047: this .table = table;
048: this .row = row;
049: this .changeSet = changeSet;
050: this .oldStatus = oldStatus;
051: this .newStatus = newStatus;
052: }
053:
054: public int getNewStatus() {
055: return newStatus;
056: }
057:
058: public int getOldStatus() {
059: return oldStatus;
060: }
061:
062: public MOTableRow getRow() {
063: return row;
064: }
065:
066: public MOTable getTable() {
067: return table;
068: }
069:
070: public MOTableRow getChangeSet() {
071: return changeSet;
072: }
073:
074: /**
075: * Checks whether the row event represents an activation of a row.
076: * To distinguish between a committing and a preparing row status event,
077: * use {@link #isDeniable()}. If that method returns <code>true</code>,
078: * then the event is fired on behalf of the preparation phase.
079: * @return
080: * <code>true</code> if the new row status is createAndGo(4) or active(1)
081: * and the old status is not active(1).
082: */
083: public boolean isRowActivated() {
084: return (((getNewStatus() == RowStatus.createAndGo) || (getNewStatus() == RowStatus.active)) && (getOldStatus() != RowStatus.active));
085: }
086:
087: /**
088: * Checks whether the row event represents a deactivation of a row.
089: * To distinguish between a committing and a preparing row status event,
090: * use {@link #isDeniable()}. If that method returns <code>true</code>,
091: * then the event is fired on behalf the preparation phase.
092: * @return
093: * <code>true</code> if the new row status is destroy(6) or notInService(2)
094: * and the old status is active(1).
095: */
096: public boolean isRowDeactivated() {
097: return (((getNewStatus() == RowStatus.destroy) || (getNewStatus() == RowStatus.notInService)) && (getOldStatus() == RowStatus.active));
098: }
099:
100: }
|