01: /*
02: * Copyright Javelin Software, All rights reserved.
03: */
04:
05: package com.javelin.swinglets.event;
06:
07: import java.awt.*;
08: import java.util.*;
09:
10: import javax.servlet.*;
11:
12: /**
13: * FormEvent is fired when a Form changes.
14: *
15: * @author Robin Sharp
16: */
17:
18: public abstract class FormEvent extends AWTEvent {
19: public final static int FORM_GET = RESERVED_ID_MAX + 1;
20: public final static int FORM_POST = RESERVED_ID_MAX + 2;
21: public final static int FORM_PUT = RESERVED_ID_MAX + 3;
22: public final static int FORM_DELETE = RESERVED_ID_MAX + 4;
23: public final static int FORM_TRACE = RESERVED_ID_MAX + 5;
24: public final static int FORM_OPTIONS = RESERVED_ID_MAX + 6;
25:
26: /**
27: * Construct a fully qualified FormEvent
28: */
29: public FormEvent(Object source, int id) {
30: super (source, id);
31: }
32:
33: /**
34: * Construct a fully qualified FormEvent
35: */
36: public FormEvent(Object source, String method) {
37: super (source, getIdFromMethod(method));
38: }
39:
40: /**
41: * Get the parameter names.
42: */
43: public abstract Enumeration getParameterNames();
44:
45: /**
46: * Get the parameter value.
47: */
48: public abstract String getParameter(String name);
49:
50: /**
51: * Get the parameter values.
52: */
53: public abstract String[] getParameterValues(String name);
54:
55: /**
56: * Get the action for the event.
57: */
58: public abstract String getAction();
59:
60: // PRIVATE ////////////////////////////////////////////////////////
61:
62: protected static synchronized int getIdFromMethod(
63: final String method) {
64: if (method.equals("GET"))
65: return FORM_GET;
66: if (method.equals("POST"))
67: return FORM_POST;
68: if (method.equals("PUT"))
69: return FORM_PUT;
70: if (method.equals("DELETE"))
71: return FORM_DELETE;
72: if (method.equals("TRACE"))
73: return FORM_TRACE;
74: if (method.equals("OPTIONS"))
75: return FORM_OPTIONS;
76:
77: return -1;
78: }
79:
80: }
|