1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to you under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * $Id: Recorder.java 471997 2006-11-07 05:59:52Z craigmcc $
18 */
19
20 package org.apache.shale.examples.test.core;
21
22 /***
23 * <p>Simple bean to record and play back event messages.</p>
24 */
25 public class Recorder {
26
27
28 // ------------------------------------------------------ Instance Variables
29
30
31 /***
32 * <p>The logged events as a concatenated string.</p>
33 */
34 private StringBuffer events = new StringBuffer();
35
36
37 // -------------------------------------------------------------- Properties
38
39
40 /***
41 * <p>Return the complete set of events that has occurred since
42 * we were last erased.</p>
43 */
44 public String getEvents() {
45 return events.toString();
46 }
47
48
49
50 // ---------------------------------------------------------- Public Methods
51
52
53 /***
54 * <p>Clear all previously recorded events.</p>
55 */
56 public void clear() {
57 events.setLength(0);
58 }
59
60
61 /***
62 * <p>Record the specified event.</p>
63 *
64 * @param event Event to be recorded
65 */
66 public void record(String event) {
67 events.append(event);
68 events.append("/");
69 }
70
71
72 }