Changeset 79 for trunk/EventBenchCore/src/de/ugoe
- Timestamp:
- 06/21/11 11:25:45 (14 years ago)
- Location:
- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/data
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/data/Event.java
r23 r79 3 3 import java.security.InvalidParameterException; 4 4 5 6 5 /** 6 * <p> 7 * Base class for all events. An event is described by its {@link #type} and its 8 * {@link #target}. 9 * </p> 10 * 11 * @author Steffen Herbold 12 * @version 1.0 13 * 14 * @param <T> 15 * Can be used to declare that events belong to a specific platform 16 * without subclassing. 17 */ 7 18 public class Event<T> { 8 19 20 /** 21 * <p> 22 * Global start event that can be used to indicate the start of a sequence. 23 * </p> 24 */ 9 25 public static final Event<Object> STARTEVENT = new Event<Object>("START"); 26 27 /** 28 * <p> 29 * Global end event that can be used to indicate the end of a sequence. 30 */ 10 31 public static final Event<Object> ENDEVENT = new Event<Object>("END"); 11 32 12 33 /** 13 34 * <p> … … 16 37 */ 17 38 private String type; 18 19 /** 20 * </p> 21 * Target of the event. 39 40 /** 41 * </p> Target of the event. 22 42 */ 23 43 private String target = null; 24 44 25 45 /** 26 46 * <p> … … 30 50 private String targetShort = null; 31 51 32 52 /** 53 * Further information about the event that shall be included in its Id. 54 */ 33 55 private String idInfo = ""; 34 56 57 /** 58 * <p> 59 * Constructor. Creates a new Event with a given type. 60 * </p> 61 * 62 * @param type 63 * type of the event 64 */ 35 65 public Event(String type) { 36 if ( type==null) {66 if (type == null) { 37 67 throw new InvalidParameterException("Event type must not be null"); 38 68 } … … 40 70 } 41 71 72 /** 73 * <p> 74 * Two events are equal, if their {@link #type} and {@link #target} are 75 * equal. 76 * </p> 77 * <p> 78 * See {@link Object#equals(Object)} for further information. 79 * </p> 80 * 81 * @param other 82 * Event that is compared to this 83 * @return true, if events are equal, false otherwise 84 */ 42 85 @Override 43 86 public boolean equals(Object other) { 44 if ( this==other) {87 if (this == other) { 45 88 return true; 46 89 } 47 90 if (other instanceof Event<?>) { 48 91 Event<?> otherEvent = (Event<?>) other; 49 if ( target!=null) {92 if (target != null) { 50 93 return type.equals(otherEvent.type) 51 && target.equals(otherEvent.target);94 && target.equals(otherEvent.target); 52 95 } else { 53 96 return type.equals(otherEvent.type) 54 && otherEvent.target==null;97 && otherEvent.target == null; 55 98 } 56 99 } else { … … 58 101 } 59 102 } 60 103 104 /** 105 * <p> 106 * Returns {@link #getStandardId()} as String representation of the event. 107 * </p> 108 * 109 * @return String represenation of the event 110 */ 61 111 @Override 62 112 public String toString() { … … 64 114 } 65 115 116 /** 117 * Informations about the event important for its Id that is neither target 118 * nor type. 119 * 120 * @return {@link #idInfo} of the event 121 */ 66 122 public String getIdInfo() { 67 123 return idInfo; 68 124 } 69 125 126 /** 127 * <p> 128 * If {@link #targetShort} is set, a shortend version of the Id is returned 129 * of the form {@link #targetShort}.{@link #type}.{@link #idInfo} is 130 * returned. Otherwise the standard Id is returned (see 131 * {@link #getStandardId()}). 132 * </p> 133 * 134 * @return if available, shortend Id string; {@link #getStandardId()} 135 * otherwise 136 */ 70 137 public String getShortId() { 71 138 String shortId = null; 72 if (targetShort !=null) {73 shortId = targetShort +"."+getType();74 if ( 75 shortId += "." +idInfo;139 if (targetShort != null) { 140 shortId = targetShort + "." + getType(); 141 if (!"".equals(idInfo)) { 142 shortId += "." + idInfo; 76 143 } 77 144 } else { … … 81 148 } 82 149 150 /** 151 * <p> 152 * Returns the Id string of the event. It has the form {@link #target}. 153 * {@link #type}.{@link #idInfo}; 154 * <p> 155 * 156 * @return Id string of the event 157 */ 83 158 public String getStandardId() { 84 159 String id = ""; 85 if ( target!=null) {160 if (target != null) { 86 161 id += target + "."; 87 162 } 88 163 id += getType(); 89 if ( !"".equals(idInfo)) {164 if (!"".equals(idInfo)) { 90 165 id += "." + idInfo; 91 166 } … … 93 168 } 94 169 170 /** 171 * <p> 172 * Returns the {@link #target} of the event. 173 * </p> 174 * 175 * @return {@link #target} of the event 176 */ 95 177 public String getTarget() { 96 178 return target; 97 179 } 98 99 public String getTargetShort() { 180 181 /** 182 * <p> 183 * Returns the {@link #targetShort} of the event. 184 * </p> 185 * 186 * @return {@link #targetShort} of the event 187 */ 188 protected String getTargetShort() { 100 189 return targetShort; 101 190 } 102 191 192 /** 193 * <p> 194 * Returns the {@link #type} of the event. 195 * </p> 196 * 197 * @return {@link #type} of the event 198 */ 103 199 public String getType() { 104 200 return type; 105 201 } 106 202 203 /* 204 * (non-Javadoc) 205 * 206 * @see java.lang.Object#hashCode() 207 */ 107 208 @Override 108 209 public int hashCode() { … … 110 211 int hash = 42; 111 212 hash = multiplier * hash + type.hashCode(); 112 if ( target!=null) {213 if (target != null) { 113 214 hash = multiplier * hash + target.hashCode(); 114 215 } … … 117 218 } 118 219 220 /** 221 * <p> 222 * Sets the {@link #idInfo} of the event. The idInfo is optional and 223 * contains information important for the event's Id that is neither target 224 * nor type. 225 * </p> 226 * 227 * @param info 228 * {@link #idInfo} of the event 229 */ 119 230 public void setIdInfo(String info) { 120 231 idInfo = info; 121 232 } 122 233 123 234 /** 124 235 * <p> 125 236 * Sets the target of the event. Once set, the target cannot be changed. 126 * </p> 127 * @param target target of the event 237 * </p> 238 * 239 * @param target 240 * target of the event 128 241 * @return true, if target was changed, false otherwise 129 242 */ 130 243 public boolean setTarget(String target) { 131 if ( this.target!=null) {244 if (this.target != null) { 132 245 return false; 133 246 } … … 135 248 return true; 136 249 } 137 138 /** 139 * <p> 140 * Sets the short description of the event target. Once set, the target cannot be changed. 141 * </p> 142 * @param targetShort short target description 250 251 /** 252 * <p> 253 * Sets the short description of the event target. Once set, the target 254 * cannot be changed. 255 * </p> 256 * 257 * @param targetShort 258 * short target description 143 259 * @return true, if target was changed, false otherwise 144 260 */ 145 261 public boolean setTargetShort(String targetShort) { 146 if ( this.targetShort!=null) {262 if (this.targetShort != null) { 147 263 return false; 148 264 } -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/data/IReplayable.java
r1 r79 1 1 package de.ugoe.cs.eventbench.data; 2 2 3 /** 4 * <p> 5 * This interface is used by {@link ReplayableEvent}to describe how events can 6 * be replayed. It can be used to define a sequence of fine-grained platform 7 * events that make up an abstract event. 8 * </p> 9 * 10 * @author Steffen Herbold 11 * @version 1.0 12 */ 3 13 public interface IReplayable { 4 14 15 /** 16 * <p> 17 * Returns a string to be written to the replay script that describes the 18 * replayable platform event. 19 * </p> 20 * 21 * @return string for the replay script 22 */ 5 23 String getReplayXml(); 6 24 25 /** 26 * <p> 27 * Returns the target of the replayable. 28 * </p> 29 * 30 * @return target of the replayable 31 */ 7 32 String getTarget(); 8 33 } -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/data/ReplayableEvent.java
r57 r79 6 6 import de.ugoe.cs.eventbench.IReplayDecorator; 7 7 8 /** 9 * <p> 10 * Subclass of {@link Event} for events that contain all informations required 11 * for replaying them, i.e., generating scripts that can used for automated 12 * software execution. 13 * </p> 14 * 15 * @author Steffen Herbold 16 * @version 1.0 17 * 18 * @param <T> 19 * Allows only types that extend {@link IReplayable} and is used to 20 * define a list of replayables that describe the replay of the 21 * event. 22 */ 8 23 public class ReplayableEvent<T extends IReplayable> extends Event<T> { 9 24 25 /** 26 * <p> 27 * List of {@link IReplayable}s of type T that describes the replay of an 28 * event. The {@link IReplayable}s can be interpreted as <it>sub-events</it> 29 * on the platform level that make up the abstract event. 30 * </p> 31 */ 10 32 private List<T> replayEvents = new LinkedList<T>();; 11 33 34 /** 35 * <p> 36 * Defines whether the replay is valid or invalid. It may be invalid, e.g., 37 * due to errors during the generation of the event or lack of vital 38 * information. 39 * </p> 40 */ 12 41 private boolean replayValid = true; 13 42 43 /** 44 * <p> 45 * {@link IReplayDecorator} used when replays of this type are written. 46 * </p> 47 */ 14 48 private IReplayDecorator decorator = null; 15 49 50 /** 51 * <p> 52 * Constructor. Creates a new event with the given type. 53 * <p> 54 * 55 * @param type 56 * type of the event 57 * @see Event#Event(String) 58 */ 16 59 public ReplayableEvent(String type) { 17 60 super(type); 18 61 } 19 62 63 /** 64 * <p> 65 * Adds a new {@link IReplayable} of type T to the replay sequence. 66 * </p> 67 * 68 * @param replayable 69 * element that is added to the sequence 70 */ 71 public void addReplayEvent(T replayable) { 72 replayEvents.add(replayable); 73 } 74 75 /** 76 * <p> 77 * Adds a {@link List}ist of {@link IReplayable} to the replay sequence. 78 * </p> 79 * 80 * @param generatedReplaySeq 81 * {@link List} that is added to the sequence 82 */ 20 83 public void addReplaySequence(List<T> generatedReplaySeq) { 21 84 replayEvents.addAll(generatedReplaySeq); 22 85 } 23 86 24 public void addReplayEvent(T replayable) { 25 replayEvents.add(replayable); 87 /** 88 * <p> 89 * Returns the {@link IReplayDecorator} of the event. 90 * </p> 91 * 92 * @return {@link IReplayDecorator} of the event; null if no decorator has 93 * been set 94 */ 95 public IReplayDecorator getReplayDecorator() { 96 return decorator; 26 97 } 27 98 28 99 /** 29 100 * <p> 30 101 * Returns a the list of replay events. 31 * </p> 102 * </p> 32 103 * <p> 33 104 * The return value is a copy of the list used internally! 34 105 * </p> 35 * @return list of replay events. 106 * 107 * @return list of replay events. 36 108 */ 37 109 public List<T> getReplayMessages() { 38 110 return new LinkedList<T>(replayEvents); 39 111 } 40 112 113 /** 114 * <p> 115 * Returns whether the replay is valid or not. 116 * </p> 117 * 118 * @return true, if replay is valid; false otherwise. 119 */ 41 120 public boolean hasValidReplay() { 42 121 return replayValid; 43 122 } 44 123 124 /** 125 * <p> 126 * Marks the replay as invalid. Once marked as invalid, it remains so and 127 * cannot be changed back to valid. 128 * </p> 129 */ 45 130 public void invalidateReplay() { 46 131 replayValid = false; 47 132 } 48 133 134 /** 135 * <p> 136 * Sets the {@link IReplayDecorator} associated with the event. 137 * </p> 138 * 139 * @param decorator 140 * decorator associated with the event 141 */ 49 142 public void setDecorator(IReplayDecorator decorator) { 50 143 this.decorator = decorator; 51 144 } 52 53 public IReplayDecorator getReplayDecorator() {54 return decorator;55 }56 145 57 146 }
Note: See TracChangeset
for help on using the changeset viewer.