[305] | 1 | package de.ugoe.cs.eventbench.jfc.data;
|
---|
[299] | 2 |
|
---|
[300] | 3 | import java.util.HashMap;
|
---|
| 4 | import java.util.Map;
|
---|
| 5 |
|
---|
[299] | 6 | import de.ugoe.cs.eventbench.data.IReplayable;
|
---|
| 7 | import de.ugoe.cs.eventbench.data.ReplayableEvent;
|
---|
| 8 |
|
---|
| 9 | /**
|
---|
| 10 | * <p>
|
---|
| 11 | * This class defines JFC events.
|
---|
| 12 | * </p>
|
---|
| 13 | *
|
---|
| 14 | * @author Steffen Herbold
|
---|
| 15 | * @version 1.0
|
---|
| 16 | */
|
---|
| 17 | public class JFCEvent extends ReplayableEvent<IReplayable> {
|
---|
| 18 |
|
---|
| 19 | /**
|
---|
| 20 | * <p>
|
---|
| 21 | * Id for object serialization.
|
---|
| 22 | * </p>
|
---|
| 23 | */
|
---|
| 24 | private static final long serialVersionUID = 1L;
|
---|
| 25 |
|
---|
| 26 | /**
|
---|
| 27 | * <p>
|
---|
[300] | 28 | * Internal map of parameters associated with the event.
|
---|
| 29 | * </p>
|
---|
| 30 | */
|
---|
| 31 | private Map<String, String> parameters;
|
---|
| 32 |
|
---|
| 33 | /**
|
---|
| 34 | * <p>
|
---|
| 35 | * Information about the event source.
|
---|
| 36 | * </p>
|
---|
| 37 | */
|
---|
| 38 | private Map<String, String> sourceParameters;
|
---|
| 39 |
|
---|
| 40 | /**
|
---|
| 41 | * <p>
|
---|
| 42 | * Information about the parent of the event source.
|
---|
| 43 | * </p>
|
---|
| 44 | */
|
---|
| 45 | private Map<String, String> parentParameters;
|
---|
| 46 |
|
---|
| 47 | /**
|
---|
| 48 | * <p>
|
---|
[299] | 49 | * Constructor. Creates a new JFCEvent.
|
---|
| 50 | * </p>
|
---|
| 51 | *
|
---|
| 52 | * @param type
|
---|
| 53 | * type of the event
|
---|
| 54 | */
|
---|
| 55 | public JFCEvent(String type) {
|
---|
| 56 | super(type);
|
---|
[300] | 57 | parameters = new HashMap<String, String>();
|
---|
[304] | 58 | sourceParameters = new HashMap<String, String>();
|
---|
| 59 | parentParameters = new HashMap<String, String>();
|
---|
[299] | 60 | }
|
---|
| 61 |
|
---|
[300] | 62 | /**
|
---|
| 63 | * <p>
|
---|
| 64 | * Adds a new parameter to the event.
|
---|
| 65 | * </p>
|
---|
| 66 | *
|
---|
| 67 | * @param name
|
---|
| 68 | * name of the parameter
|
---|
| 69 | * @param value
|
---|
| 70 | * value of the parameter
|
---|
| 71 | */
|
---|
| 72 | public void addParameter(String name, String value) {
|
---|
| 73 | parameters.put(name, value);
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | /**
|
---|
| 77 | * <p>
|
---|
| 78 | * Retrieves the value of a parameter.
|
---|
| 79 | * </p>
|
---|
| 80 | *
|
---|
| 81 | * @param name
|
---|
| 82 | * name of the parameter
|
---|
| 83 | * @return value of the parameter
|
---|
| 84 | */
|
---|
| 85 | public String getParameter(String name) {
|
---|
| 86 | return parameters.get(name);
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | /**
|
---|
| 90 | * <p>
|
---|
| 91 | * Adds new information about the source of the event.
|
---|
| 92 | * </p>
|
---|
| 93 | *
|
---|
| 94 | * @param name
|
---|
| 95 | * name of the information
|
---|
| 96 | * @param value
|
---|
| 97 | * value of the information
|
---|
| 98 | */
|
---|
| 99 | public void addSourceInformation(String name, String value) {
|
---|
| 100 | sourceParameters.put(name, value);
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | /**
|
---|
| 104 | * <p>
|
---|
| 105 | * Retrieves information about the source of the event.
|
---|
| 106 | * </p>
|
---|
| 107 | *
|
---|
| 108 | * @param name
|
---|
| 109 | * name of the information
|
---|
| 110 | * @return value of the information
|
---|
| 111 | */
|
---|
| 112 | public String getSourceInformation(String name) {
|
---|
| 113 | return sourceParameters.get(name);
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | /**
|
---|
| 117 | * <p>
|
---|
| 118 | * Adds new information about the parent of the source of the event.
|
---|
| 119 | * </p>
|
---|
| 120 | *
|
---|
| 121 | * @param name
|
---|
| 122 | * name of the information
|
---|
| 123 | * @param value
|
---|
| 124 | * value of the information
|
---|
| 125 | */
|
---|
| 126 | public void addParentInformation(String name, String value) {
|
---|
| 127 | parentParameters.put(name, value);
|
---|
| 128 | }
|
---|
| 129 |
|
---|
| 130 | /**
|
---|
| 131 | * <p>
|
---|
| 132 | * Retrieves information about the parent of the source of the event.
|
---|
| 133 | * </p>
|
---|
| 134 | *
|
---|
| 135 | * @param name
|
---|
| 136 | * name of the information
|
---|
| 137 | * @return value of the information
|
---|
| 138 | */
|
---|
| 139 | public String getParentInformation(String name) {
|
---|
| 140 | return parentParameters.get(name);
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 | /*
|
---|
| 144 | * (non-Javadoc)
|
---|
| 145 | *
|
---|
| 146 | * @see de.ugoe.cs.eventbench.data.ReplayableEvent#equals(java.lang.Object)
|
---|
| 147 | */
|
---|
| 148 | @Override
|
---|
| 149 | public boolean equals(Object other) {
|
---|
| 150 | if (other == this) {
|
---|
| 151 | return true;
|
---|
| 152 | }
|
---|
| 153 | if (other instanceof JFCEvent) {
|
---|
| 154 | return super.equals(other)
|
---|
| 155 | && parameters.equals(((JFCEvent) other).parameters);
|
---|
| 156 | }
|
---|
| 157 | return false;
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 | /*
|
---|
| 161 | * (non-Javadoc)
|
---|
| 162 | *
|
---|
| 163 | * @see de.ugoe.cs.eventbench.data.ReplayableEvent#hashCode()
|
---|
| 164 | */
|
---|
| 165 | @Override
|
---|
| 166 | public int hashCode() {
|
---|
| 167 | int hashCode = super.hashCode();
|
---|
| 168 | hashCode *= parameters.hashCode();
|
---|
| 169 | return hashCode;
|
---|
| 170 | }
|
---|
| 171 |
|
---|
[299] | 172 | }
|
---|