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         * Called whenever StockItems were added to the Stock.
026         *
027         * @override Sometimes
028         *
029         * @param e an event object describing the event.
030         */
031        public void addedStockItems(StockChangeEvent e) {}
032    
033        /**
034         * Called whenever the adding of StockItems was commited.
035         *
036         * @override Sometimes
037         *
038         * @param e an event object describing the event.
039         */
040        public void commitAddStockItems(StockChangeEvent e) {}
041    
042        /**
043         * Called whenever the adding of StockItems was rolled back.
044         *
045         * @override Sometimes
046         *
047         * @param e an event object describing the event.
048         */
049        public void rollbackAddStockItems(StockChangeEvent e) {}
050    
051        /**
052         * Called to ask whether certain StockItems may be removed. If one of the listeners vetos the removal, all
053         * listeners that had already been asked will receive a {@link #noRemoveStockItems noRemoveStockItems}
054         * event.
055         *
056         * @override Sometimes
057         *
058         * @param e an event object describing the event.
059         *
060         * @exception VetoException if the listener wants to veto the removal.
061         */
062        public void canRemoveStockItems(StockChangeEvent e) throws VetoException {}
063    
064        /**
065         * Called for each listener that already agreed with a removal that was then rejected by another listener.
066         *
067         * @override Sometimes
068         *
069         * @param e an event object describing the event.
070         */
071        public void noRemoveStockItems(StockChangeEvent e) {}
072    
073        /**
074         * Called whenever StockItems were removed from the Stock.
075         *
076         * @override Sometimes
077         *
078         * @param e an event object describing the event.
079         */
080        public void removedStockItems(StockChangeEvent e) {}
081    
082        /**
083         * Called whenever the removal of StockItems was commited.
084         *
085         * @override Sometimes
086         *
087         * @param e an event object describing the event.
088         */
089        public void commitRemoveStockItems(StockChangeEvent e) {}
090    
091        /**
092         * Called whenever the removal of StockItems was rolled back.
093         *
094         * @override Sometimes
095         *
096         * @param e an event object describing the event.
097         */
098        public void rollbackRemoveStockItems(StockChangeEvent e) {}
099    
100        /**
101         * Called to ask whether certain StockItems may be edited. If one of the listeners vetos the editing, all
102         * listeners that had already been asked will receive a {@link #noEditStockItems noEditStockItems}
103         * event.
104         *
105         * @override Sometimes
106         *
107         * @param e an event object describing the event.
108         *
109         * @exception VetoException if the listener wants to veto the editing.
110         */
111        public void canEditStockItems(StockChangeEvent e) throws VetoException {}
112    
113        /**
114         * Called for each listener that already agreed with an editing that was then rejected by another listener.
115         *
116         * @override Sometimes
117         *
118         * @param e an event object describing the event.
119         */
120        public void noEditStockItems(StockChangeEvent e) {}
121    
122        /**
123         * Called whenever the Stock began editing StockItems. This event may be accompanied by a
124         * <code>removedStockItems</code> and a <code>addedStockItems</code> event, but this is implementation
125         * specific.
126         *
127         * @override Sometimes
128         *
129         * @param e an event object describing the event.
130         */
131        public void editingStockItems(StockChangeEvent e) {}
132    
133        /**
134         * Called whenever the editing of StockItems was commited.
135         *
136         * @override Sometimes
137         *
138         * @param e an event object describing the event.
139         */
140        public void commitEditStockItems(StockChangeEvent e) {}
141    
142        /**
143         * Called whenever the editing of StockItems was rolled back.
144         *
145         * @override Sometimes
146         *
147         * @param e an event object describing the event.
148         */
149        public void rollbackEditStockItems(StockChangeEvent e) {}
150    }