Skip to main content
summaryrefslogtreecommitdiffstats
blob: c6aa97640f18551b798cce9b2dff3e29900d3102 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.framework.messaging.event.res.event;

import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.osee.framework.jdk.core.util.AXml;
import org.eclipse.osee.framework.jdk.core.util.Collections;

/**
 * @author Donald G. Dunne
 */
public class NetworkBroadcastEvent extends FrameworkEventBase {

   public static String GUID = "AYxiaIdXukmXPJlYWbQA";
   private String message;
   private String broadcastEventType;
   private Collection<String> userIds;

   public NetworkBroadcastEvent(String broadcastEventType, String message, Collection<String> userIds, NetworkSender networkSender) {
      super(networkSender, GUID);
      this.broadcastEventType = broadcastEventType;
      this.message = message;
      if (userIds == null) {
         this.userIds = java.util.Collections.emptyList();
      } else {
         this.userIds = userIds;
      }
   }

   public NetworkBroadcastEvent(String broadcastEventType, String message, NetworkSender networkSender) {
      this(broadcastEventType, message, null, networkSender);
   }

   public NetworkBroadcastEvent(String xml) {
      super(xml);
   }

   @Override
   public void fromXml(String xml) {
      super.fromXml(xml);
      this.userIds = new ArrayList<String>();
      this.userIds.addAll(Collections.fromString(AXml.getTagData(xml, "bcUserId"), ";"));
      this.broadcastEventType = AXml.getTagData(xml, "bcEventType");
      this.message = AXml.getTagData(xml, "msg");
   }

   @Override
   public void toXml(StringBuffer sb) {
      super.toXml(sb);
      sb.append(AXml.addTagData("bcUserId", Collections.toString(";", userIds)));
      sb.append(AXml.addTagData("bcEventType", broadcastEventType));
      sb.append(AXml.addTagData("msg", message));
   }

   public Collection<String> getUserIds() {
      return userIds;
   }

   public String getMessage() {
      return message;
   }

   public void setMessage(String message) {
      this.message = message;
   }

   public String getBroadcastEventTypeName() {
      return broadcastEventType;
   }

}

Back to the top