01: /*
02: ItsNat Java Web Application Framework
03: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
04: Author: Jose Maria Arranz Santamaria
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. See the GNU Affero General Public
10: License for more details. See the copy of the GNU Affero General Public License
11: included in this program. If not, see <http://www.gnu.org/licenses/>.
12: */
13:
14: package org.itsnat.impl.core.listener.domext;
15:
16: import org.itsnat.core.ItsNatException;
17: import org.itsnat.core.event.ParamTransport;
18: import org.itsnat.impl.core.ItsNatDocumentImpl;
19: import org.itsnat.impl.core.event.client2serv.*;
20: import org.itsnat.impl.core.event.client2serv.domext.UserEventImpl;
21: import org.w3c.dom.events.EventListener;
22: import org.w3c.dom.events.EventTarget;
23:
24: /**
25: *
26: * @author jmarranz
27: */
28: public class UserEventListenerWrapperImpl extends
29: DOMExtensionEventListenerWrapperImpl {
30: protected String name;
31:
32: /** Creates a new instance of UserEventListenerWrapperImpl */
33: public UserEventListenerWrapperImpl(ItsNatDocumentImpl itsNatDoc,
34: EventTarget element, String name, EventListener listener,
35: int syncMode, ParamTransport[] extraParams,
36: String preSendCode, long ajaxTimeout) {
37: super (itsNatDoc, element, listener, syncMode, extraParams,
38: preSendCode, ajaxTimeout);
39:
40: this .name = name;
41: }
42:
43: public String getName() {
44: return name;
45: }
46:
47: public void handleEvent(NormalEventImpl event) {
48: getEventListener().handleEvent((UserEventImpl) event);
49: }
50:
51: public static String getTypePrefix() {
52: return "itsnat:user:";
53: }
54:
55: public static boolean isUserType(String type) {
56: return type.startsWith(getTypePrefix());
57: }
58:
59: public static String getType(String name) {
60: return getTypePrefix() + name;
61: }
62:
63: public static String getNameFromType(String type) {
64: return getNameFromType(type, true);
65: }
66:
67: public static String getNameFromType(String type, boolean check) {
68: if (check && !isUserType(type))
69: throw new ItsNatException(
70: "Bad type format, must start with: "
71: + getTypePrefix());
72:
73: return type.substring(getTypePrefix().length());
74: }
75:
76: public String getType() {
77: return getType(getName());
78: }
79:
80: }
|