Clover coverage report - brownies library - 1.0-beta-1 Coverage timestamp: 月 8 16 2004 17:14:42 GMT+09:00 FRAMES NO FRAMES |
file stats: | LOC: | 119 |  | Methods: | 11
| NCLOC: | 53 |  | Classes: | 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
Source file | Conditionals | Statements | Methods | TOTAL
QueueList.java | 100% | 36% | 27.3% | 40% |

1 |  |
     /*
2 |  |
      * Joey and its relative products are published under the terms
3 |  |
      * of the Apache Software License.
4 |  |
      */
5 |  |
     package org.asyrinx.brownie.core.collection;
6 |  |
7 |  |
     import java.util.Collection;
8 |  |
9 |  |
     import org.asyrinx.brownie.core.collection.wrapper.ListWrapper;
10 |  |
11 |  |
     /**
12 |  |
      * FIFOのキューを表現するクラスです
13 |  |
      *
14 |  |
      * @author akima
15 |  |
      */
16 |  |
     public class QueueList extends ListWrapper {
17 |  |
18 |  |
         /**
19 |  |
          * Constructor for QueueList.
20 |  |
          */
21 | 0 |
         public QueueList() {
22 | 0 |
             super();
23 |  |
         }
24 |  |
25 |  |
         /**
26 |  |
          * Constructor for QueueList.
27 |  |
          *
28 |  |
          * @param c
29 |  |
          */
30 | 0 |
         public QueueList(Collection c) {
31 | 0 |
             super(c);
32 | 0 |
             deleteSurplusItems();
33 |  |
         }
34 |  |
35 |  |
         /**
36 |  |
          * Constructor for QueueList.
37 |  |
          *
38 |  |
          * @param maxSize
39 |  |
          */
40 | 1 |
         public QueueList(int maxSize) {
41 | 1 |
             super();
42 | 1 |
             this.maxSize = maxSize;
43 |  |
         }
44 |  |
45 |  |
         /**
46 |  |
          * Constructor for QueueList.
47 |  |
          *
48 |  |
          * @param c
49 |  |
          */
50 | 0 |
         public QueueList(Collection c, int maxSize) {
51 | 0 |
             super(c);
52 | 0 |
             this.maxSize = maxSize;
53 | 0 |
             deleteSurplusItems();
54 |  |
         }
55 |  |
56 |  |
         private int maxSize = 100;
57 |  |
58 |  |
         /**
59 |  |
          */
60 | 0 |
         public void add(int index, Object element) {
61 | 0 |
             super.add(index, element);
62 | 0 |
             deleteSurplusItems();
63 |  |
         }
64 |  |
65 |  |
         /**
66 |  |
          */
67 | 6 |
         public boolean add(Object o) {
68 | 6 |
             final boolean result = super.add(o);
69 | 6 |
             deleteSurplusItems();
70 | 6 |
             return result;
71 |  |
         }
72 |  |
73 |  |
         /**
74 |  |
          */
75 | 0 |
         public boolean addAll(Collection c) {
76 | 0 |
             final boolean result = super.addAll(c);
77 | 0 |
             deleteSurplusItems();
78 | 0 |
             return result;
79 |  |
         }
80 |  |
81 |  |
         /**
82 |  |
          */
83 | 0 |
         public boolean addAll(int index, Collection c) {
84 | 0 |
             final boolean result = super.addAll(index, c);
85 | 0 |
             deleteSurplusItems();
86 | 0 |
             return result;
87 |  |
         }
88 |  |
89 |  |
         /**
90 |  |
          * 余分な項目を削除する。
91 |  |
          */
92 | 6 |
         private void deleteSurplusItems() {
93 | 6 |
             if (list.size() < maxSize)
94 | 2 |
                 return;
95 | 4 |
             while (list.size() > maxSize) {
96 | 3 |
                 list.remove(0);
97 |  |
             }
98 |  |
         }
99 |  |
100 |  |
         /**
101 |  |
          * Returns the maxSize.
102 |  |
          *
103 |  |
          * @return int
104 |  |
          */
105 | 0 |
         public int getMaxSize() {
106 | 0 |
             return maxSize;
107 |  |
         }
108 |  |
109 |  |
         /**
110 |  |
          * Sets the maxSize.
111 |  |
          *
112 |  |
          * @param maxSize
113 |  |
          *            The maxSize to set
114 |  |
          */
115 | 0 |
         public void setMaxSize(int maxSize) {
116 | 0 |
             this.maxSize = maxSize;
117 |  |
         }
118 |  |
119 |  |
     }