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