001: /*
002: * Copyright 2000,2005 wingS development team.
003: *
004: * This file is part of wingS (http://wingsframework.org).
005: *
006: * wingS is free software; you can redistribute it and/or modify
007: * it under the terms of the GNU Lesser General Public License
008: * as published by the Free Software Foundation; either version 2.1
009: * of the License, or (at your option) any later version.
010: *
011: * Please see COPYING for the complete licence.
012: */
013: package org.wings.event;
014:
015: import org.wings.externalizer.ExternalizedResource;
016:
017: import java.awt.*;
018:
019: /**
020: * A request event meaning aspecific phase that has been reached during the request processing.
021: * Possible states are defined as constants in this class (i.e. {@link #DELIVER_START}).
022: *
023: * @author <a href="mailto:haaf@mercatis.de">Armin Haaf</a>
024: */
025: public class SRequestEvent extends AWTEvent {
026:
027: /**
028: * Delivery of the HTML response started.
029: */
030: public static final int DELIVER_START = 50000;
031:
032: /**
033: * Delivery of the HTML response finished.
034: */
035: public static final int DELIVER_DONE = DELIVER_START + 1;
036:
037: /**
038: * Dispathcing of the low level events contained in the originating servlet request starts.
039: * This will trigger i.e. button events later on.
040: */
041:
042: public static final int DISPATCH_START = DELIVER_START + 2;
043:
044: /**
045: * All low level events have been dispatches and hence the immediate event should
046: * have been fired. Intermediate events will be fired soon.
047: */
048: public static final int DISPATCH_DONE = DELIVER_START + 3;
049:
050: /**
051: * The initial request paramters have been processed.
052: */
053: public static final int PROCESS_REQUEST = DELIVER_START + 4;
054:
055: /**
056: * The http request started.
057: */
058: public static final int REQUEST_START = DELIVER_START + 5;
059:
060: /**
061: * The http request ist finished.
062: */
063: public static final int REQUEST_END = DELIVER_START + 6;
064:
065: /**
066: * if type is {@link #DELIVER_START} or {@link #DELIVER_DONE} this field is
067: * filled with info about the resource actually delivered, otherwise it is
068: * null.
069: */
070: protected transient ExternalizedResource requestedResource;
071:
072: /**
073: * Constructs a ComponentEvent object.
074: *
075: * @param aSource the Component object that originated the event
076: * @param type an integer indicating the type of event
077: */
078: public SRequestEvent(Object aSource, int type,
079: ExternalizedResource requestedResource) {
080: super (aSource, type);
081:
082: this .requestedResource = requestedResource;
083: }
084:
085: public int getType() {
086: return getID();
087: }
088:
089: public ExternalizedResource getRequestedResource() {
090: return requestedResource;
091: }
092:
093: /**
094: * Returns a string representing the state of this event. This
095: * method is intended to be used only for debugging purposes, and the
096: * content and format of the returned string may vary between
097: * implementations. The returned string may be empty but may
098: * not be <tt>null</tt>.
099: */
100: public String paramString() {
101: if (getSource() == null)
102: return "no source";
103:
104: String typeStr;
105:
106: switch (getID()) {
107: case DISPATCH_START:
108: typeStr = "DISPATCH_START";
109: break;
110: case DISPATCH_DONE:
111: typeStr = "DISPATCH_DONE";
112: break;
113: case DELIVER_START:
114: typeStr = "DELIVER_START";
115: break;
116: case DELIVER_DONE:
117: typeStr = "DELIVER_DONE";
118: break;
119: default:
120: typeStr = "unknown type";
121: }
122: return typeStr;
123: }
124:
125: public String toString() {
126: return "SRequestEvent[source=" + source + "; " + paramString()
127: + "]";
128: }
129: }
|