source: trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/EventUtils.java @ 2252

Last change on this file since 2252 was 1997, checked in by sherbold, 9 years ago
  • added new utility for convenience functions for working with events
  • Property svn:mime-type set to text/plain
File size: 2.1 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.eventcore;
16
17import java.util.Collection;
18import java.util.List;
19import java.util.logging.Level;
20
21import de.ugoe.cs.util.console.Console;
22
23/**
24 * <p>
25 * Convenience functions for working with events and sequences of events.
26 * </p>
27 *
28 * @author Steffen Herbold
29 */
30public class EventUtils {
31
32    /**
33     * <p>
34     * prints a collection of sequences to the trace stream of the console
35     * </p>
36     *
37     * @param logLevel
38     *            the trace log level
39     * @param sequences
40     *            sequences to be printed
41     */
42    public static void traceSequences(Level logLevel, Collection<List<Event>> sequences) {
43        if (sequences != null) {
44            for (List<Event> sequence : sequences) {
45                traceSequence(logLevel, sequence);
46            }
47        }
48    }
49
50    /**
51     * <p>
52     * prints a sequence to the trace stream of the console
53     * </p>
54     *
55     * @param logLevel
56     *            the trace log level
57     * @param sequence
58     *            sequence to be printed
59     */
60    public static void traceSequence(Level logLevel, List<Event> sequence) {
61        if (sequence != null) {
62            for (Event event : sequence) {
63                Console.traceln(logLevel, event.toString());
64            }
65        }
66    }
67
68    /**
69     * <p>
70     * private constructor to prevent initialization
71     * </p>
72     */
73    private EventUtils() {}
74}
Note: See TracBrowser for help on using the repository browser.