Clover Coverage Report - Kuali Student 1.2-M6-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Sep 12 2011 05:03:53 EDT
../../../../../../../img/srcFileCovDistChart0.png 42% of files have more coverage
6   71   6   1.2
2   26   1   5
5     1.2  
1    
 
  LogBuffer       Line # 25 6 0% 6 13 0% 0.0
 
No Tests
 
1    /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10    * software distributed under the License is distributed on an "AS IS"
11    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12    * or implied. See the License for the specific language governing
13    * permissions and limitations under the License.
14    */
15   
16    package org.kuali.student.common.ui.client.logging;
17   
18    import java.io.Serializable;
19    import java.util.ArrayList;
20    import java.util.List;
21   
22    /**
23    * Stores log messages, can be sent to log service.
24    */
 
25    public class LogBuffer implements Serializable {
26    private static final long serialVersionUID = 1L;
27   
28    int maxSize = Integer.MAX_VALUE;
29    List<LogMessage> buffer = new ArrayList<LogMessage>();
30   
31    /**
32    * Creates an empty LogBuffer with a size limit of Integer.MAX_VALUE
33    */
 
34  0 toggle public LogBuffer() {
35   
36    }
37   
38    /**
39    * Creates an empty LogBuffer with the specified size limit.
40    * When size limit is reached, older messages are removed as newer ones are added.
41    * @param maxSize
42    */
 
43  0 toggle public LogBuffer(int maxSize) {
44  0 this.maxSize = maxSize;
45    }
46   
47    /**
48    * Adds a message to the buffer
49    * @param message
50    */
 
51  0 toggle public void add(LogMessage message) {
52  0 buffer.add(message);
53  0 checkLimit();
54    }
55   
56    /**
57    * Returns the underlying log buffer.
58    * @return the underlying log buffer as List<LogMessage>
59    */
 
60  0 toggle public List<LogMessage> getLogMessages() {
61  0 return buffer;
62    }
63    /**
64    * Removes excess messages, oldest first.
65    */
 
66  0 toggle private void checkLimit() {
67  0 while (buffer.size() > maxSize) {
68  0 buffer.remove(0);
69    }
70    }
71    }