<commit_before>/**
 *  Copyright (C) 2005 Orbeon, Inc.
 *
 *  This program is free software; you can redistribute it and/or modify it under the terms of the
 *  GNU Lesser General Public License as published by the Free Software Foundation; either version
 *  2.1 of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *  See the GNU Lesser General Public License for more details.
 *
 *  The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
 */
package org.orbeon.oxf.xforms.event;

import org.dom4j.Element;
import org.orbeon.oxf.common.OXFException;
import org.orbeon.oxf.xforms.control.XFormsControl;
import org.orbeon.oxf.xforms.event.events.*;

import java.util.HashMap;
import java.util.Map;

/**
 * Factory for XForms events
 */
public class XFormsEventFactory {

    private static Map nameToClassMap = new HashMap();

    static {
        nameToClassMap.put(XFormsEvents.XFORMS_DOM_ACTIVATE, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsDOMActivateEvent(targetObject);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_COMPUTE_EXCEPTION, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsComputeExceptionEvent(targetObject, contextString, contextThrowable);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_DELETE, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsDeleteEvent(targetObject, contextString);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_DESELECT, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsDeselectEvent(targetObject);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_INSERT, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsInsertEvent(targetObject, contextString);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_LINK_ERROR, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsLinkErrorEvent(targetObject, contextString, contextElement, contextThrowable);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_LINK_EXCEPTION, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsLinkExceptionEvent(targetObject, contextString, contextElement, contextThrowable);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_BINDING_EXCEPTION, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsBindingExceptionEvent(targetObject);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_REFRESH, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsRefreshEvent(targetObject);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_SELECT, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsSelectEvent(targetObject);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_SUBMIT_ERROR, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsSubmitErrorEvent(targetObject, contextString);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_SUBMIT, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsSubmitEvent(targetObject);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_SUBMIT_SERIALIZE, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsSubmitSerializeEvent(targetObject);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_SUBMIT_DONE, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsSubmitDoneEvent(targetObject);
            }
        });
        nameToClassMap.put(XFormsEvents.XXFORMS_READY, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XXFormsReadyEvent(targetObject);
            }
        });
        nameToClassMap.put(XFormsEvents.XXFORMS_VALUE_CHANGE_WITH_FOCUS_CHANGE, new Factory() {<commit_msg>Fixed build.<commit_after>/**
 *  Copyright (C) 2005 Orbeon, Inc.
 *
 *  This program is free software; you can redistribute it and/or modify it under the terms of the
 *  GNU Lesser General Public License as published by the Free Software Foundation; either version
 *  2.1 of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *  See the GNU Lesser General Public License for more details.
 *
 *  The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
 */
package org.orbeon.oxf.xforms.event;

import org.dom4j.Element;
import org.orbeon.oxf.common.OXFException;
import org.orbeon.oxf.xforms.control.XFormsControl;
import org.orbeon.oxf.xforms.event.events.*;

import java.util.HashMap;
import java.util.Map;

/**
 * Factory for XForms events
 */
public class XFormsEventFactory {

    private static Map nameToClassMap = new HashMap();

    static {
        nameToClassMap.put(XFormsEvents.XFORMS_DOM_ACTIVATE, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsDOMActivateEvent(targetObject);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_COMPUTE_EXCEPTION, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsComputeExceptionEvent(targetObject, contextString, contextThrowable);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_DELETE, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsDeleteEvent(targetObject, contextString);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_DESELECT, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsDeselectEvent(targetObject);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_INSERT, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsInsertEvent(targetObject, contextString);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_LINK_ERROR, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsLinkErrorEvent(targetObject, contextString, contextElement, contextThrowable);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_LINK_EXCEPTION, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsLinkExceptionEvent(targetObject, contextString, contextElement, contextThrowable);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_BINDING_EXCEPTION, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsBindingExceptionEvent(targetObject);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_REFRESH, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsRefreshEvent(targetObject);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_SELECT, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsSelectEvent(targetObject);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_SUBMIT_ERROR, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsSubmitErrorEvent(targetObject, contextString);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_SUBMIT, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsSubmitEvent(targetObject);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_SUBMIT_SERIALIZE, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsSubmitSerializeEvent(targetObject);
            }
        });
        nameToClassMap.put(XFormsEvents.XFORMS_SUBMIT_DONE, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XFormsSubmitDoneEvent(targetObject, contextString);
            }
        });
        nameToClassMap.put(XFormsEvents.XXFORMS_READY, new Factory() {
            public XFormsEvent createEvent(String eventName, XFormsEventTarget targetObject, XFormsEventTarget otherTargetObject, boolean allowCustomEvents, boolean bubbles, boolean cancelable, String contextString, Element contextElement, Throwable contextThrowable, Element filesElement) {
                return new XXFormsReadyEvent(targetObject);
            }
        });
        nameToClassMap.put(XFormsEvents.XXFORMS_VALUE_CHANGE_WITH_FOCUS_CHANGE, new Factory() {
{'fraction_non_alphanumeric': 0.06053593179049939, 'fraction_numerical': 0.0008526187576126675, 'mean_word_length': 4.144423558897243, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2274329', 'n_tokens_mistral': 3943, 'n_tokens_neox': 3868, 'n_words': 1120}