001    package data.events;
002    
003    import util.*;
004    
005    /**
006     * An <i>abstract</i> adapter class for receiving stock change events. The methods in this class are empty.
007     * This class exists as convenience for creating listener objects.
008     *
009     * <p>Extend this class to create a StockChangeEvent listener and override the methods for the events of
010     * interest. (If you implement the StockChangeListener interface, you have to define all of the methods in
011     * it. This abstract class defines empty method bodies for them all, so you can concentrate on defining
012     * methods only for events you care about.)</p>
013     *
014     * <p>Create a listener object using the extended class and then register it with a ListenableStock using
015     * the Stock's {@link data.ListenableStock#addStockChangeListener} method. When the Stock's contents
016     * change, the relevant method in the listener object is invoked, and a {@link StockChangeEvent} is passed
017     * to it.</p>
018     *
019     * @author Steffen Zschaler
020     * @version 2.0 19/08/1999
021     * @since v2.0
022     */
023    public class StockChangeAdapter extends Object implements StockChangeListener, SerializableListener {
024        /**
025             * ID for serialization.
026             */
027            private static final long serialVersionUID = -3696397741490620296L;
028    
029            /**
030         * Called whenever StockItems were added to the Stock.
031         *
032         * @override Sometimes
033         *
034         * @param e an event object describing the event.
035         */
036        public void addedStockItems(StockChangeEvent e) {}
037    
038        /**
039         * Called whenever the adding of StockItems was commited.
040         *
041         * @override Sometimes
042         *
043         * @param e an event object describing the event.
044         */
045        public void commitAddStockItems(StockChangeEvent e) {}
046    
047        /**
048         * Called whenever the adding of StockItems was rolled back.
049         *
050         * @override Sometimes
051         *
052         * @param e an event object describing the event.
053         */
054        public void rollbackAddStockItems(StockChangeEvent e) {}
055    
056        /**
057         * Called to ask whether certain StockItems may be removed. If one of the listeners vetos the removal, all
058         * listeners that had already been asked will receive a {@link #noRemoveStockItems noRemoveStockItems}
059         * event.
060         *
061         * @override Sometimes
062         *
063         * @param e an event object describing the event.
064         *
065         * @exception VetoException if the listener wants to veto the removal.
066         */
067        public void canRemoveStockItems(StockChangeEvent e) throws VetoException {}
068    
069        /**
070         * Called for each listener that already agreed with a removal that was then rejected by another listener.
071         *
072         * @override Sometimes
073         *
074         * @param e an event object describing the event.
075         */
076        public void noRemoveStockItems(StockChangeEvent e) {}
077    
078        /**
079         * Called whenever StockItems were removed from the Stock.
080         *
081         * @override Sometimes
082         *
083         * @param e an event object describing the event.
084         */
085        public void removedStockItems(StockChangeEvent e) {}
086    
087        /**
088         * Called whenever the removal of StockItems was commited.
089         *
090         * @override Sometimes
091         *
092         * @param e an event object describing the event.
093         */
094        public void commitRemoveStockItems(StockChangeEvent e) {}
095    
096        /**
097         * Called whenever the removal of StockItems was rolled back.
098         *
099         * @override Sometimes
100         *
101         * @param e an event object describing the event.
102         */
103        public void rollbackRemoveStockItems(StockChangeEvent e) {}
104    
105        /**
106         * Called to ask whether certain StockItems may be edited. If one of the listeners vetos the editing, all
107         * listeners that had already been asked will receive a {@link #noEditStockItems noEditStockItems}
108         * event.
109         *
110         * @override Sometimes
111         *
112         * @param e an event object describing the event.
113         *
114         * @exception VetoException if the listener wants to veto the editing.
115         */
116        public void canEditStockItems(StockChangeEvent e) throws VetoException {}
117    
118        /**
119         * Called for each listener that already agreed with an editing that was then rejected by another listener.
120         *
121         * @override Sometimes
122         *
123         * @param e an event object describing the event.
124         */
125        public void noEditStockItems(StockChangeEvent e) {}
126    
127        /**
128         * Called whenever the Stock began editing StockItems. This event may be accompanied by a
129         * <code>removedStockItems</code> and a <code>addedStockItems</code> event, but this is implementation
130         * specific.
131         *
132         * @override Sometimes
133         *
134         * @param e an event object describing the event.
135         */
136        public void editingStockItems(StockChangeEvent e) {}
137    
138        /**
139         * Called whenever the editing of StockItems was commited.
140         *
141         * @override Sometimes
142         *
143         * @param e an event object describing the event.
144         */
145        public void commitEditStockItems(StockChangeEvent e) {}
146    
147        /**
148         * Called whenever the editing of StockItems was rolled back.
149         *
150         * @override Sometimes
151         *
152         * @param e an event object describing the event.
153         */
154        public void rollbackEditStockItems(StockChangeEvent e) {}
155    }