NWTEventInstance Class
Event object wrapper
@param event Event object
@param object (Optional) attributes to populate the event object with
@constructor
335909
function NWTEventInstance (e, attrs) {
	this._e = e;
	this.target = new NWTNodeInstance(e.target);

	for (var i in attrs) {
		this[i] = attrs[i];
	}
}
631039
function createEvent (type, data) {
  let event = document.createEvent(specialEvents[type] || 'Event')
  event.initEvent(type, true, true)
  data && (event.data = data)
  return event
}
954681
public static <T> Listener<T> createListenerToFire(Event<T> event) {
		return new Listener<T>() {
			@Override
			public void fire(T obj) {
				event.fire(obj);
			}
		};
	}
180841
function (eventType, event, target) {

                if (!(event instanceof EventDispatcher.Event)) {
                    event = new EventDispatcher.Event(event);
                }

                if (!event.target) {
                    event.target = target || this;
                }

                event.type = eventType;


                if (!(this._eventHandlers[eventType] || this._eventHandlers["*"])) {
                    return event;
                }

                var list,
                    result, i;

                if (this._eventHandlers[eventType]) {

                    list = this._eventHandlers[eventType].slice();
                    for (i = 0; i < list.length; i++) {
                        if (list[i]) {
                            result = list[i].trigger(event, event.target);
                            if (result !== undefinedValue) {

                                if (result === false) {
                                    event.preventDefault();
                                    event.stopPropagation();
                                }
                            }

                            if (event.isImmediatePropagationStopped) {
                                break;
                            }
                        }
                    }
                }

                if (this._eventHandlers["*"]) {

                    list = this._eventHandlers["*"].slice();
                    for (i = 0; i < list.length; i++) {
                        if (list[i]) {
                            result = list[i].trigger(event, target);
                            if (result !== undefinedValue) {

                                if (result === false) {
                                    event.preventDefault();
                                    event.stopPropagation();
                                }
                            }

                            if (event.isImmediatePropagationStopped) {
                                break;
                            }
                        }
                    }
                }

                return event;
            }
1258420
function Event (eventstream, event, eventMappings) {
  if (!eventstream) {
    var errStreamMsg = 'eventstream not injected!';
    debug(errStreamMsg);
    throw new Error(errStreamMsg);
  }

  if (!event) {
    var errEvtMsg = 'event not injected!';
    debug(errEvtMsg);
    throw new Error(errEvtMsg);
  }

  if (!eventstream.aggregateId) {
    var errAggIdMsg = 'eventstream.aggregateId not injected!';
    debug(errAggIdMsg);
    throw new Error(errAggIdMsg);
  }

  if (!_.isArray(eventstream.uncommittedEvents)) {
    var errAggIdMsg = 'eventstream.uncommittedEvents not injected!';
    debug(errAggIdMsg);
    throw new Error(errAggIdMsg);
  }

  eventMappings = eventMappings || {};

  this.streamId = eventstream.aggregateId;
  this.aggregateId = eventstream.aggregateId;
  this.aggregate = eventstream.aggregate;
  this.context = eventstream.context;
  this.streamRevision = null;
  this.commitId = null;
  this.commitSequence = null;
  this.commitStamp = null;
  this.payload = event || null;
  this.position = null;

  this.applyMappings = function applyMappings() {
    _.keys(eventMappings).forEach(function (key) {
      if (this[key] !== undefined && this[key] !== null) {
        dotty.put(this.payload, eventMappings[key], this[key]);
      }
    }.bind(this));
  };

  eventstream.uncommittedEvents.push(this);
}
45625
function (eventName, fn) {
            if (typeof eventName === 'object') {
                if (eventName === null) {
                    throw "IllegalArgumentException: eventName must be a String, or an Object.";
                }

                for (var name in eventName) {
                    if (eventName.hasOwnProperty(name)) {
                        this.bind(name, eventName[name]);
                    }
                }
                return this;
            }
            
            if (!this.isSupported(eventName)) {
                throw "IllegalArgumentException: unrecognized event name (" + eventName + ").";
            }
            
            if (typeof fn !== 'function') {
                throw "IllegalArgumentException: fn must be a Function.";
            }
            
            this._events[eventName].push(fn);

            if (this.numListeners(eventName) === 1) {
                this._sendActivation('_activate', eventName);
            }
            
            return this;
        }
951118
function(view, event_name, event_object) {

		var targets = view.getContainer().getEventTargets(event_name);

		if (targets) {

			this.dispatchEvent(view, event_name, event_object, targets);

		}

	}
718682
public void dispatchEvent(Event event, String eventName) {
    int typeInt = Event.getTypeInt(eventName);
    Object[] handlerData = $(element).data(EVENT_DATA);
    for (int i = 0, l = elementEvents.length(); i < l; i++) {
      BindFunction listener = elementEvents.get(i);
      String namespace = JsUtils.prop(event, "namespace");
      boolean matchEV = listener != null && (listener.hasEventType(typeInt) || listener.isTypeOf(eventName));
      boolean matchNS = matchEV && (isNullOrEmpty(namespace) || listener.nameSpace.equals(namespace));
      if (matchEV && matchNS) {
        if (!listener.fire(event, typeInt, eventName, handlerData)) {
          event.stopPropagation();
          event.preventDefault();
        }
      }
    }
  }
1099845
function Events (el, obj) {
  if (!(this instanceof Events)) return new Events(el, obj)
  if (!el) throw new Error('element required')
  if (!obj) throw new Error('object required')
  this.el = el
  this.obj = obj
  this._events = {}
}
929713
public <T> void handleEvent(final T event) throws EventException {
		final Class<?> type = event.getClass();
		if (!this.cachedListeners.containsKey(event.getClass())) {
			this.cachedListeners.put(type, new LinkedList<ListenerInstancePair<?>>());
			for (final ListenerInstancePair<?> listener : this.listeners) {
				final Type observableType = GenericsUtil.getEntityGenericType(listener.listener.getClass(), 0, Listener.class);
				final Class<?> observable = GenericsUtil.guessClazz(observableType);
				if (observable.isAssignableFrom(type)) {
					this.cachedListeners.get(type).add(listener);
				}
			}
		}
		@SuppressWarnings("unchecked")
		final List<ListenerInstancePair<T>> resolvedListeners = List.class.cast(this.cachedListeners.get(event.getClass()));
		for (final ListenerInstancePair<T> listener : resolvedListeners) {
			listener.handleEvent(event, null);
		}
	}
1155696
function(event, property, value) {
    try {
      Object.defineProperty(event, property, {
        get : function() {
          return value;
        }
      });
    } catch(e) {
      event[property] = value;
    }
  }
525758
function _addEvent(object, type, callback) {
        if (object.addEventListener) {
            object.addEventListener(type, callback, false);
            return;
        }

        object.attachEvent('on' + type, callback);
    }
1338182
public void setAttribute(String key, Object attribute) {
		if(!isValid()) {
			throw new IllegalStateException("Can not bind object to session that has been invalidated!!");
		}
		if(key == null) {
			throw new NullPointerException("Name of attribute to bind cant be null!!!");
		}
		if(attribute == null) {
			throw new NullPointerException("Attribute that is to be bound cant be null!!!");
		}

		// Construct an event with the new value
		SipSessionBindingEvent event = null;

        // Call the valueBound() method if necessary
        if (attribute instanceof SipSessionBindingListener) {
            // Don't call any notification if replacing with the same value
            Object oldValue = getAttributeMap().get(key);
            if (attribute != oldValue) {
            	event = new SipSessionBindingEvent(this, key);
                try {
                    ((SipSessionBindingListener) attribute).valueBound(event);
                } catch (Throwable t){
                	logger.error("SipSessionBindingListener threw exception", t);
                }
            }
        }

		Object previousValue = this.getAttributeMap().put(key, attribute);

		if (previousValue != null && previousValue != attribute &&
	            previousValue instanceof SipSessionBindingListener) {
            try {
                ((SipSessionBindingListener) previousValue).valueUnbound
                    (new SipSessionBindingEvent(this, key));
            } catch (Throwable t) {
            	logger.error("SipSessionBindingListener threw exception", t);
            }
        }

		// Notifying Listeners of attribute addition or modification
		SipListeners sipListenersHolder = this.getSipApplicationSession().getSipContext().getListeners();
		List<SipSessionAttributeListener> listenersList = sipListenersHolder.getSipSessionAttributeListeners();
		if(listenersList.size() > 0) {
			if(event == null) {
				event = new SipSessionBindingEvent(this, key);
			}
			if (previousValue == null) {
				// This is initial, we need to send value bound event
				for (SipSessionAttributeListener listener : listenersList) {
					if(logger.isDebugEnabled()) {
						logger.debug("notifying SipSessionAttributeListener " + listener.getClass().getCanonicalName() + " of attribute added on key "+ key);
					}
					try {
						listener.attributeAdded(event);
					} catch (Throwable t) {
						logger.error("SipSessionAttributeListener threw exception", t);
					}
				}
			} else {
				for (SipSessionAttributeListener listener : listenersList) {
					if(logger.isDebugEnabled()) {
						logger.debug("notifying SipSessionAttributeListener " + listener.getClass().getCanonicalName() + " of attribute replaced on key "+ key);
					}
					try {
						listener.attributeReplaced(event);
					} catch (Throwable t) {
						logger.error("SipSessionAttributeListener threw exception", t);
					}
				}
			}
		}
	}
883038
function Event(type) {
      var event = this;
      if (type instanceof Event) {
        return type;
      }
      return (event instanceof Event)
        ? _.assign(event, { 'timeStamp': _.now() }, typeof type == 'string' ? { 'type': type } : type)
        : new Event(type);
    }
961676
function(eventType, attributeKey, attributeValue) {
    var attrsKey = this._event_attributes_key(eventType);
    for(var i = 0; i < this._events.length ; i++) {
      var evt = this._events[i];
      if ( (evt.eventType === eventType) && (evt[attrsKey][attributeKey] === attributeValue) ) {
        return evt;
      }
    }
    return null;
  }
1273490
public static IEventTrigger createEventTrigger(final EventType eventType, final AttributeImpl attribute)
            throws DevFailed {
        LOGGER.debug("create event trigger for attribute {} of type {}", attribute.getName(), eventType);
        final EventProperties props = attribute.getProperties().getEventProp();
        IEventTrigger eventTrigger;
        switch (eventType) {
            case PERIODIC_EVENT:
                final long period = Long.parseLong(props.per_event.period);
                eventTrigger = new PeriodicEventTrigger(period, attribute);
                break;
            case CHANGE_EVENT:
                eventTrigger = new ChangeEventTrigger(attribute, props.ch_event.abs_change, props.ch_event.rel_change);
                break;
            case ARCHIVE_EVENT:
                long periodA;
                try {
                    // Check if specified and a number
                    periodA = Long.parseLong(props.arch_event.period);
                } catch (final NumberFormatException e) {
                    periodA = -1;
                }
                eventTrigger = new ArchiveEventTrigger(periodA, props.arch_event.abs_change,
                        props.arch_event.rel_change, attribute);
                break;
            case ATT_CONF_EVENT:
            case DATA_READY_EVENT:
            case USER_EVENT:
            case INTERFACE_CHANGE_EVENT:
            case PIPE_EVENT:
            default:
                eventTrigger = new DefaultEventTrigger();
                break;

        }
        return eventTrigger;
    }
358038
function emitEvent(payload, eventNameBase, debugParams) {

        // create a copy of the payload so that nothing modifies the original object
        try {
            payload = JSON.parse(JSON.stringify(payload));
        }
        catch (err) {
            /* eslint no-console:0 */
            console.log('issue parsing during emit ' + JSON.stringify(eventNameBase));
        }

        // we don't want to emit the potentially huge resource file
        if (payload && payload.resource) {
            delete payload.resource;
        }

        // create the event data and emit the event
        var name = _.extend({}, eventNameBase, debugParams);
        var eventData = {
            name: name,
            payload: payload
        };
        var eventName = name.resource + '.' + name.adapter + '.' + name.method;
        eventName += debugParams ? '.' + name.type + '.' + name.timing : '';
        eventBus.emit(eventName, eventData);
    }