Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Recorder |
|
| 1.0;1 |
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 489951 2006-12-23 23:41:37Z craigmcc $ | |
18 | */ | |
19 | ||
20 | package org.apache.shale.examples.test.view; | |
21 | ||
22 | /** | |
23 | * <p>Simple bean to record and play back event messages.</p> | |
24 | */ | |
25 | 0 | public class Recorder { |
26 | ||
27 | ||
28 | // ------------------------------------------------------ Instance Variables | |
29 | ||
30 | ||
31 | /** | |
32 | * <p>The logged events as a concatenated string.</p> | |
33 | */ | |
34 | 0 | private StringBuffer events = new StringBuffer(); |
35 | ||
36 | ||
37 | // -------------------------------------------------------------- Properties | |
38 | ||
39 | ||
40 | /** | |
41 | * <p>Dummy getter to force clearing when called.</p> | |
42 | */ | |
43 | public boolean isClear() { | |
44 | 0 | clear(); |
45 | 0 | return true; |
46 | } | |
47 | ||
48 | ||
49 | /** | |
50 | * <p>Return the complete set of events that has occurred since | |
51 | * we were last erased.</p> | |
52 | */ | |
53 | public String getEvents() { | |
54 | 0 | return events.toString(); |
55 | } | |
56 | ||
57 | ||
58 | ||
59 | // ---------------------------------------------------------- Public Methods | |
60 | ||
61 | ||
62 | /** | |
63 | * <p>Clear all previously recorded events.</p> | |
64 | */ | |
65 | public void clear() { | |
66 | 0 | events.setLength(0); |
67 | 0 | } |
68 | ||
69 | ||
70 | /** | |
71 | * <p>Record the specified event.</p> | |
72 | * | |
73 | * @param event Event to be recorded | |
74 | */ | |
75 | public void record(String event) { | |
76 | 0 | events.append(event); |
77 | 0 | events.append("/"); |
78 | 0 | } |
79 | ||
80 | ||
81 | } |