//////////////////////////// Event Serializeing
14013
function serializeTopics(topics) {
    return topics.map(function (topic) {
        if (typeof (topic) === 'string') {
            return topic;
        }
        else if (Array.isArray(topic)) {
            topic.forEach(function (topic) {
                if (topic !== null && bytes_1.hexDataLength(topic) !== 32) {
                    errors.throwError('invalid topic', errors.INVALID_ARGUMENT, { argument: 'topic', value: topic });
                }
            });
            return topic.join(',');
        }
        else if (topic === null) {
            return '';
        }
        return errors.throwError('invalid topic value', errors.INVALID_ARGUMENT, { argument: 'topic', value: topic });
    }).join('&');
}
732296
def _events(self):
        
        with self.app.events_lock:
            res = self.app.get_events()
        return serialize(res, True)
1126000
function serializeElement (node, context, eventTarget) {
  var c, i, l;
  var name = node.nodeName.toLowerCase();

  // opening tag
  var r = '<' + name;

  // attributes
  for (i = 0, c = node.attributes, l = c.length; i < l; i++) {
    r += ' ' + exports.serializeAttribute(c[i]);
  }

  r += '>';

  // child nodes
  r += exports.serializeNodeList(node.childNodes, context, null, eventTarget);

  // closing tag, only for non-void elements
  if (!voidElements[name]) {
    r += '</' + name + '>';
  }

  return r;
}
175690
@Override
    public void contextInitialized(ServletContextEvent evt) {
        File usersDir = new File(SetupOptions.getBaseConfigDirectory(), "users");
        if (!usersDir.isDirectory()) {
            return;
        }
        DocumentBuilder domBuilder = null;
        try {
            domBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        } catch (ParserConfigurationException e) {
            LOGR.warning(e.getMessage());
            return;
        }
        DOMImplementationLS lsFactory = buildDOM3LoadAndSaveFactory();
        LSSerializer serializer = lsFactory.createLSSerializer();
        serializer.getDomConfig().setParameter(Constants.DOM_XMLDECL, Boolean.FALSE);
        serializer.getDomConfig().setParameter(Constants.DOM_FORMAT_PRETTY_PRINT, Boolean.TRUE);
        LSOutput output = lsFactory.createLSOutput();
        output.setEncoding("UTF-8");
        for (File userDir : usersDir.listFiles()) {
            File userFile = new File(userDir, "user.xml");
            if (!userFile.isFile()) {
                continue;
            }
            try {
                Document doc = domBuilder.parse(userFile);
                Node pwNode = doc.getElementsByTagName("password").item(0);
                if (null == pwNode) {
                    continue;
                }
                String password = pwNode.getTextContent();
                if (password.split(":").length == 5) {
                    break;
                }
                pwNode.setTextContent(PasswordStorage.createHash(password));
                // overwrite contents of file
                // Fortify Mod: Make sure that the output stream is closed
                // output.setByteStream(new FileOutputStream(userFile, false));
                FileOutputStream os = new FileOutputStream(userFile, false);
                output.setByteStream(os);
                serializer.write(doc, output);
                os.close();
            } catch (Exception e) {
                LOGR.info(e.getMessage());
                continue;
            }
        }
    }
523364
@Override
    protected XMLEvent internalNextEvent() throws XMLStreamException {
        // If there is an iterator to read from reset was called, use the iterator
        // until it runs out of events.
        if (this.bufferReader != null) {
            final XMLEvent event = this.bufferReader.next();

            // If nothing left in the iterator, remove the reference and fall through to direct
            // reading
            if (!this.bufferReader.hasNext()) {
                this.bufferReader = null;
            }

            return event;
        }

        // Get the next event from the underlying reader
        final XMLEvent event = this.getParent().nextEvent();

        // if buffering add the event
        if (this.eventLimit != 0) {
            this.eventBuffer.offer(event);

            // If limited buffer size and buffer is too big trim the buffer.
            if (this.eventLimit > 0 && this.eventBuffer.size() > this.eventLimit) {
                this.eventBuffer.poll();
            }
        }

        return event;
    }
394479
private static DataHandler getDataHandlerForString(Event event) {
        try {
            return new DataHandler(new ByteDataSource(event.getContent().getBytes("UTF-8")));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
239484
public void releaseEvent(EventId eventId) throws Exception {
		Lockable<V> eventWrapper = sharedBuffer.getEvent(eventId);
		if (eventWrapper != null) {
			if (eventWrapper.release()) {
				sharedBuffer.removeEvent(eventId);
			} else {
				sharedBuffer.upsertEvent(eventId, eventWrapper);
			}
		}
	}
338356
@SuppressWarnings("unchecked")
	@Override
	public void publishEvent(ApplicationEvent event) {

		if (event instanceof MappingContextEvent) {
			this.schmeaCreator
					.onApplicationEvent((MappingContextEvent<SolrPersistentEntity<?>, SolrPersistentProperty>) event);
		}
	}
461456
@Override
    public PipelineEventReader<CharacterEventReader, CharacterEvent> getEventReader(
            HttpServletRequest request, HttpServletResponse response) {
        final PipelineEventReader<CharacterEventReader, CharacterEvent> pipelineEventReader =
                this.wrappedComponent.getEventReader(request, response);

        final CharacterEventReader eventReader = pipelineEventReader.getEventReader();

        final List<CharacterEvent> eventBuffer = new LinkedList<CharacterEvent>();
        while (eventReader.hasNext()) {
            final CharacterEvent event = eventReader.next();

            switch (event.getEventType()) {
                case PORTLET_HEADER:
                    {
                        final PortletHeaderPlaceholderEvent headerEvent =
                                (PortletHeaderPlaceholderEvent) event;
                        final IPortletWindowId portletWindowId = headerEvent.getPortletWindowId();

                        if (!this.portletExecutionManager.isPortletRenderHeaderRequested(
                                portletWindowId, request, response)) {
                            this.portletExecutionManager.startPortletHeaderRender(
                                    portletWindowId, request, response);
                        }

                        break;
                    }
                case PORTLET_CONTENT:
                    {
                        final PortletContentPlaceholderEvent headerEvent =
                                (PortletContentPlaceholderEvent) event;
                        final IPortletWindowId portletWindowId = headerEvent.getPortletWindowId();

                        if (!this.portletExecutionManager.isPortletRenderRequested(
                                portletWindowId, request, response)) {
                            this.portletExecutionManager.startPortletRender(
                                    portletWindowId, request, response);
                        }

                        break;
                    }
                default:
                    // Do nothing
            }

            eventBuffer.add(event);
        }

        final Map<String, String> outputProperties = pipelineEventReader.getOutputProperties();
        final CharacterEventBufferReader bufferEventReader =
                new CharacterEventBufferReader(eventBuffer.listIterator());
        return new PipelineEventReaderImpl<CharacterEventReader, CharacterEvent>(
                bufferEventReader, outputProperties);
    }
1225319
@Override
    public void writeExternal(ObjectOutput s) throws IOException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(this, tc, "Serializing " + this);
        }
        super.writeExternal(s);
    }
668555
@Override
	public void servletEvent(final ServletEvent event) {
		if (LOG.isDebugEnabled()) {
			LOG.debug("Sending web event " + event + " for bundle "
					+ event.getBundleName());
		}
		synchronized (listeners) {
			callListeners(event);
			Map<String, ServletEvent> events = states.get(event.getBundleId());
			if (events == null) {
				events = new LinkedHashMap<>();
				states.put(event.getBundleId(), events);
			}
			events.put(event.getAlias(), event);
		}
	}
1110579
String eventSubject(long sessionId) {
    if (prefix == null) {
      return String.format("event-%d", sessionId);
    } else {
      return String.format("%s-event-%d", prefix, sessionId);
    }
  }
701895
public void processEvent(EventObject event) {
    if (event instanceof RequestEvent) {
      processRequestEvent((RequestEvent) event);
    } else {
      LOG.error("invalid event type received: " + event.getClass().getName() + ": "
          + event.toString());
    }
  }
502045
@Override
	public void ZWaveIncomingEvent(ZWaveEvent event) {
		if (event.getEventType() != ZWaveEvent.ZWaveEventType.TRANSACTION_COMPLETED_EVENT)
			return;
		
		SerialMessage serialMessage = (SerialMessage)event.getEventValue();
		
		if (serialMessage.getMessageClass() != SerialMessage.SerialMessageClass.SendData && serialMessage.getMessageType() != SerialMessage.SerialMessageType.Request)
			return;
		
		byte[] payload = serialMessage.getMessagePayload();
		
		if (payload.length < 4)
			return;
		if ((payload[0] & 0xFF) != this.getNode().getNodeId())
			return;
		if ((payload[2] & 0xFF) != this.getCommandClass().getKey())
			return;
		if ((payload[3] & 0xFF) != WAKE_UP_NO_MORE_INFORMATION)
			return;
		
		logger.debug("Node {} went to sleep", this.getNode().getNodeId());
		this.setAwake(false);
	}
266953
@Override
	protected void serializeTo(RawDataBuffer out)
    {
        super.serializeTo(out);
    	if (message != null)
        {
            out.writeBoolean(true);
            MessageSerializer.serializeTo(message, out);
        }
        else
            out.writeBoolean(false);
    }
823999
function() {
      if (this.allObjectEvents_.length === 0)
        return;

      function processEvent(objectEventState) {
        var event = objectEventState.event;
        var thread = objectEventState.thread;
        if (event.name === undefined) {
          this.model_.importWarning({
            type: 'object_parse_error',
            message: 'While processing ' + JSON.stringify(event) + ': ' +
                'Object events require an name parameter.'
          });
        }

        if (event.id === undefined) {
          this.model_.importWarning({
            type: 'object_parse_error',
            message: 'While processing ' + JSON.stringify(event) + ': ' +
                'Object events require an id parameter.'
          });
        }
        var process = thread.parent;
        var ts = timestampFromUs(event.ts);
        var instance;
        if (event.ph === 'N') {
          try {
            instance = process.objects.idWasCreated(
                event.id, event.cat, event.name, ts);
          } catch (e) {
            this.model_.importWarning({
              type: 'object_parse_error',
              message: 'While processing create of ' +
                  event.id + ' at ts=' + ts + ': ' + e
            });
            return;
          }
        } else if (event.ph === 'O') {
          if (event.args.snapshot === undefined) {
            this.model_.importWarning({
              type: 'object_parse_error',
              message: 'While processing ' + event.id + ' at ts=' + ts + ': ' +
                  'Snapshots must have args: {snapshot: ...}'
            });
            return;
          }
          var snapshot;
          try {
            var args = this.deepCopyIfNeeded_(event.args.snapshot);
            var cat;
            if (args.cat) {
              cat = args.cat;
              delete args.cat;
            } else {
              cat = event.cat;
            }

            var baseTypename;
            if (args.base_type) {
              baseTypename = args.base_type;
              delete args.base_type;
            } else {
              baseTypename = undefined;
            }
            snapshot = process.objects.addSnapshot(
                event.id, cat, event.name, ts,
                args, baseTypename);
            snapshot.snapshottedOnThread = thread;
          } catch (e) {
            this.model_.importWarning({
              type: 'object_parse_error',
              message: 'While processing snapshot of ' +
                  event.id + ' at ts=' + ts + ': ' + e
            });
            return;
          }
          instance = snapshot.objectInstance;
        } else if (event.ph === 'D') {
          try {
            process.objects.idWasDeleted(event.id, event.cat, event.name, ts);
            var instanceMap = process.objects.getOrCreateInstanceMap_(event.id);
            instance = instanceMap.lastInstance;
          } catch (e) {
            this.model_.importWarning({
              type: 'object_parse_error',
              message: 'While processing delete of ' +
                  event.id + ' at ts=' + ts + ': ' + e
            });
            return;
          }
        }

        if (instance)
          instance.colorId = getEventColor(event, instance.typeName);
      }

      this.allObjectEvents_.sort(function(x, y) {
        var d = x.event.ts - y.event.ts;
        if (d != 0)
          return d;
        return x.sequenceNumber - y.sequenceNumber;
      });

      var allObjectEvents = this.allObjectEvents_;
      for (var i = 0; i < allObjectEvents.length; i++) {
        var objectEventState = allObjectEvents[i];
        try {
          processEvent.call(this, objectEventState);
        } catch (e) {
          this.model_.importWarning({
            type: 'object_parse_error',
            message: e.message
          });
        }
      }
    }
1279253
@Override
	@SuppressWarnings({ "unchecked" })
	protected void append(final LoggingEvent event) {
		if (null == this.client) {
			try {
				connectToAerospike();
			} catch (UnknownHostException e) {
				throw new RuntimeException(e.getMessage(), e);
			}
		}
		List<Bin> binList = new ArrayList<Bin>();
		StringBuilder keyString = new StringBuilder();
		if (null != applicationId) {
			MDC.put(APP_ID, applicationId);
			keyString.append(applicationId).append(":");
			binList.add(new Bin(APP_ID, applicationId));
		}
		String eventName = event.getLogger().getName();
		binList.add(new Bin(NAME, eventName));
		keyString.append(eventName).append(":");
		binList.add(new Bin(LEVEL, event.getLevel().toString()));
		keyString.append(event.getLevel().toString()).append(":");
		Calendar tstamp = Calendar.getInstance();
		tstamp.setTimeInMillis(event.getTimeStamp());
		binList.add(new Bin(TIMESTAMP, event.getTimeStamp()));
		keyString.append(event.getTimeStamp());
		
		// Copy properties into the record
		Map<Object, Object> props = event.getProperties();
		if (null != props && props.size() > 0) {
			Map<String, String> propsMap = new HashMap<String, String>();
			for (Map.Entry<Object, Object> entry : props.entrySet()) {
				propsMap.put(entry.getKey().toString(), entry.getValue().toString());
			}
			binList.add(new Bin(PROPERTIES, propsMap));
		}

		// Copy traceback info (if there is any) into the record
		String[] traceback = event.getThrowableStrRep();
		if (null != traceback && traceback.length > 0) {
			List<String> tb = new ArrayList<String>();
			tb.addAll(Arrays.asList(traceback));
			binList.add(new Bin(TRACEBACK, tb));
		}

		// Put the rendered message into the record
		binList.add(new Bin(MESSAGE, event.getRenderedMessage()));

		// Insert a record
		Calendar now = Calendar.getInstance();
		MDC.put(YEAR, now.get(Calendar.YEAR));
		MDC.put(MONTH, String.format("%1$02d", now.get(Calendar.MONTH) + 1));
		MDC.put(DAY, String.format("%1$02d", now.get(Calendar.DAY_OF_MONTH)));
		MDC.put(HOUR, String.format("%1$02d", now.get(Calendar.HOUR_OF_DAY)));

		MDC.remove(YEAR);
		MDC.remove(MONTH);
		MDC.remove(DAY);
		MDC.remove(HOUR);
		if (null != applicationId) {
			MDC.remove(APP_ID);
		}
		Key key = new Key(this.namespace, this.set, keyString.toString());
		this.client.put(null, key, binList.toArray(new Bin[0]));
	}