View Javadoc

1   /**
2    *
3    * Copyright 2003-2004 The Apache Software Foundation
4    *
5    *  Licensed under the Apache License, Version 2.0 (the "License");
6    *  you may not use this file except in compliance with the License.
7    *  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  distributed under the License is distributed on an "AS IS" BASIS,
13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   */
17  
18  //
19  // This source code implements specifications defined by the Java
20  // Community Process. In order to remain compliant with the specification
21  // DO NOT add / change / or delete method signatures!
22  //
23  
24  package javax.enterprise.deploy.model;
25  
26  import java.beans.PropertyChangeEvent;
27  
28  /**
29   * An Event class describing DDBeans being added to or removed from a J2EE
30   * application, or updated in place.
31   *
32   * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
33   */
34  public class XpathEvent {
35      /**
36       * Adding a DDBean
37       */
38      public static final Object BEAN_ADDED = new Object();
39      /**
40       * Removing a DDBean
41       */
42      public static final Object BEAN_REMOVED = new Object();
43      /**
44       * Changing a DDBean
45       */
46      public static final Object BEAN_CHANGED = new Object();
47  
48      private PropertyChangeEvent pce;
49      private DDBean bean;
50      private Object type;
51  
52      /**
53       * A description of a change in the DDBean tree.
54       *
55       * @param bean The DDBean being added, removed, or updated.
56       * @param type Indicates whether this is an add, remove, or update event.
57       */
58      public XpathEvent(DDBean bean, Object type) {
59          this.bean = bean;
60          this.type = type;
61      }
62  
63      /**
64       * Gets the underlying property change event, with new and
65       * old values.  This is typically used for change events.
66       * It is not in the public API, but is included in the
67       * downloadable JSR-88 classes.
68       */
69      public PropertyChangeEvent getChangeEvent() {
70          return pce;
71      }
72  
73      /**
74       * Sets the underlying property change event, with new and
75       * old values.  This is typically used for change events.
76       * It is not in the public API, but is included in the
77       * downloadable JSR-88 classes.
78       *
79       * @param pce The property change event that triggered this XpathEvent.
80       */
81      public void setChangeEvent(PropertyChangeEvent pce) {
82          this.pce = pce;
83      }
84  
85      /**
86       * The bean being added/removed/changed.
87       *
88       * @return The bean being added/removed/changed.
89       */
90      public DDBean getBean() {
91          return bean;
92      }
93  
94      /**
95       * Is this an add event?
96       *
97       * @return <code>true</code> if this is an add event.
98       */
99      public boolean isAddEvent() {
100         return BEAN_ADDED == type;
101     }
102 
103     /**
104      * Is this a remove event?
105      *
106      * @return <code>true</code> if this is a remove event.
107      */
108     public boolean isRemoveEvent() {
109         return BEAN_REMOVED == type;
110     }
111 
112     /**
113      * Is this a change event?
114      *
115      * @return <code>true</code> if this is a change event.
116      */
117     public boolean isChangeEvent() {
118         return BEAN_CHANGED == type;
119     }
120 }