001    /**
002     *
003     * Copyright 2003-2004 The Apache Software Foundation
004     *
005     *  Licensed under the Apache License, Version 2.0 (the "License");
006     *  you may not use this file except in compliance with the License.
007     *  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    
018    //
019    // This source code implements specifications defined by the Java
020    // Community Process. In order to remain compliant with the specification
021    // DO NOT add / change / or delete method signatures!
022    //
023    
024    package javax.enterprise.deploy.model;
025    
026    import java.beans.PropertyChangeEvent;
027    
028    /**
029     * An Event class describing DDBeans being added to or removed from a J2EE
030     * application, or updated in place.
031     *
032     * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
033     */
034    public class XpathEvent {
035        /**
036         * Adding a DDBean
037         */
038        public static final Object BEAN_ADDED = new Object();
039        /**
040         * Removing a DDBean
041         */
042        public static final Object BEAN_REMOVED = new Object();
043        /**
044         * Changing a DDBean
045         */
046        public static final Object BEAN_CHANGED = new Object();
047    
048        private PropertyChangeEvent pce;
049        private DDBean bean;
050        private Object type;
051    
052        /**
053         * A description of a change in the DDBean tree.
054         *
055         * @param bean The DDBean being added, removed, or updated.
056         * @param type Indicates whether this is an add, remove, or update event.
057         */
058        public XpathEvent(DDBean bean, Object type) {
059            this.bean = bean;
060            this.type = type;
061        }
062    
063        /**
064         * Gets the underlying property change event, with new and
065         * old values.  This is typically used for change events.
066         * It is not in the public API, but is included in the
067         * downloadable JSR-88 classes.
068         */
069        public PropertyChangeEvent getChangeEvent() {
070            return pce;
071        }
072    
073        /**
074         * Sets the underlying property change event, with new and
075         * old values.  This is typically used for change events.
076         * It is not in the public API, but is included in the
077         * downloadable JSR-88 classes.
078         *
079         * @param pce The property change event that triggered this XpathEvent.
080         */
081        public void setChangeEvent(PropertyChangeEvent pce) {
082            this.pce = pce;
083        }
084    
085        /**
086         * The bean being added/removed/changed.
087         *
088         * @return The bean being added/removed/changed.
089         */
090        public DDBean getBean() {
091            return bean;
092        }
093    
094        /**
095         * Is this an add event?
096         *
097         * @return <code>true</code> if this is an add event.
098         */
099        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    }