01 
02 /*
03  *  JScripter Standard 1.0 - To Script In Java
04  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.jscripter.org>
05  *  
06  *  This program is free software: you can redistribute it and/or modify
07  *  it under the terms of the GNU Affero General Public License as published by
08  *  the Free Software Foundation, either version 3 of the License, or
09  *  (at your option) any later version.
10  *  
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU Affero General Public License for more details.
15  *  
16  *  You should have received a copy of the GNU Affero General Public License
17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 package jsx.http.event;
21 
22 import jsx.Configurable;
23 import jsx.Source;
24 import jsx.http.Ajax;
25 
26 /**
27  * <p>An abstract type of high level events that may be fired from a {@link Ajax} object 
28  * to notify a state of HTTP transmission.</p>
29  * <p>This class is designed generic with the type parameter being the type of its 
30  * corresponding listener type. A subclass must be concrete and final if it is to be an 
31  * event type. As an event type, the subclass must also declare the type parameter of 
32  * this class as the type of its own listener.</p>
33  * <p>An event listener is typically of an interface with a declared method to react on 
34  * the event it handles so that the class of the event can implement the {@link jsx.Source.Event#execute(Object)} 
35  * method by simply calling that declared method passing the event itself as the argument. 
36  * A subclass of this class defines events uniquely typed by the subclass itself and 
37  * designates a listener type corresponding to that type of events.</p>
38  * <p>For an event source to fire an event, the listener of the event must have been 
39  * registered onto the source object with a call to the {@link Source#addListener(Class, Object)} 
40  * method which asks both the type of the event and the listener object for arguments.</p>
41  * <p>Note that, high level events are {@link Configurable}.</p>
42  * 
43  * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.jscripter.org" target="_blank">http://www.jscripter.org</a>
44  */
45 public abstract class HTTPState<T> extends Source.Event<T>
46 {
47     /**
48      * <p>The default constructor which simply invokes the default constructor of the 
49      * superclass.</p>
50      * <p>Note that, this constructor does not change the configurable properties 
51      * {@link jsx.Source.Event#BUBBLE} and {@link jsx.Source.Event#UPDATE} of this event object.</p>
52      * @since 1.0
53      */
54     protected HTTPState() {}
55 
56     /**
57      * <p>Gets the source object of an event of this type.</p>
58      * <p>This method simply returns the configurable property {@link jsx.Source.Event#SOURCE} 
59      * of the specified event.</p>
60      * @param evt The event to get source.
61      * @return The source of the specified event. This method returns <tt>null</tt> 
62      * if the event has not been fired. Fire a fired event is meaningless.
63      * @since 1.0
64      */
65     public static final Ajax getSource(HTTPState<?> evt) {
66         return (Ajax)Source.Event.source(evt);
67     }
68 }