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