KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > agent > mo > MOTableModelEvent


1 /*_############################################################################
2   _##
3   _## SNMP4J-Agent - MOTableModelEvent.java
4   _##
5   _## Copyright (C) 2005-2007 Frank Fock (SNMP4J.org)
6   _##
7   _## Licensed under the Apache License, Version 2.0 (the "License");
8   _## you may not use this file except in compliance with the License.
9   _## You may obtain a copy of the License at
10   _##
11   _## http://www.apache.org/licenses/LICENSE-2.0
12   _##
13   _## Unless required by applicable law or agreed to in writing, software
14   _## distributed under the License is distributed on an "AS IS" BASIS,
15   _## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   _## See the License for the specific language governing permissions and
17   _## limitations under the License.
18   _##
19   _##########################################################################*/

20
21 package org.snmp4j.agent.mo;
22
23 import java.util.EventObject JavaDoc;
24
25 /**
26  * The <code>MOTableModelEvent</code> event object describes events that change
27  * a table model. Such events include adding, removing, and changing of rows
28  * as well as clearing a whole model.
29  *
30  * @author Frank Fock
31  * @version 1.0
32  */

33 public class MOTableModelEvent extends EventObject JavaDoc {
34
35   private static final long serialVersionUID = -2260159403182301993L;
36
37   public static final int ROW_CHANGED = 0;
38   public static final int ROW_ADDED = 1;
39   public static final int ROW_REMOVED = 2;
40   public static final int TABLE_CLEAR = 3;
41
42   private int type;
43   private MOTableRow affectedRow;
44   private int columnIndex = -1;
45
46   /**
47    * Creates a model event associated with a single row and column.
48    * @param source
49    * the event source.
50    * @param type
51    * the event type as defined by the ROW_* constants of this object.
52    * @param affectedRow
53    * the row that is associated with this event.
54    * @param columnIndex
55    * the column index associated with this event.
56    */

57   public MOTableModelEvent(Object JavaDoc source, int type, MOTableRow affectedRow,
58                            int columnIndex) {
59     super(source);
60     this.type = type;
61     this.affectedRow = affectedRow;
62     this.columnIndex = columnIndex;
63   }
64
65   /**
66    * Creates a model event associated with a single row.
67    * @param source
68    * the event source.
69    * @param type
70    * the event type as defined by the ROW_* constants of this object.
71    * @param affectedRow
72    * the row that is associated with this event.
73    */

74   public MOTableModelEvent(Object JavaDoc source, int type, MOTableRow affectedRow) {
75     this(source, type, affectedRow, -1);
76   }
77
78   /**
79    * Creates the model wide event.
80    * @param source
81    * the event source.
82    * @param type
83    * the event type as defined by the constants of this object.
84    */

85   public MOTableModelEvent(Object JavaDoc source, int type) {
86     this(source, type, null);
87   }
88
89   /**
90    * Returns the type of event.
91    * @return
92    * one of the event type constants defined by this object.
93    */

94   public int getType() {
95     return type;
96   }
97
98   /**
99    * Gets the affected row (if a single row is affected by the event).
100    * @return
101    * the <code>MOTableRow</code> instance associated with this event, or
102    * <code>null</code> if the whole model is affected.
103    */

104   public MOTableRow getAffectedRow() {
105     return affectedRow;
106   }
107
108   /**
109    * Returns the column index associated with this event.
110    * @return
111    * a column index >= 0 if a column is associated with this event or -1
112    * if not.
113    */

114   public int getColumnIndex() {
115     return columnIndex;
116   }
117
118   public String JavaDoc toString() {
119     return MOTableModelEvent.class.getName()+"[type="+type+
120         ",affectedRow="+affectedRow+",columnIndex="+columnIndex+"]";
121   }
122 }
123
Popular Tags