01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: package org.apache.cocoon.profiling.statistics;
18:
19: import java.util.ArrayList;
20: import java.util.Date;
21: import java.util.List;
22:
23: /**
24: *
25: * @version $Id: PageReportImpl.java 485636 2006-12-11 12:20:15Z cziegeler $
26: * @since 2.1.10
27: */
28: public class PageReportImpl implements PageReport {
29:
30: protected final List statistics = new ArrayList();
31: protected final String id;
32: protected final Date date = new Date();
33:
34: public PageReportImpl(String id) {
35: this .id = id;
36: }
37:
38: /**
39: * @see org.apache.cocoon.profiling.statistics.PageReport#getId()
40: */
41: public String getId() {
42: return this .id;
43: }
44:
45: /**
46: * @see org.apache.cocoon.profiling.statistics.PageReport#getDate()
47: */
48: public Date getDate() {
49: return this .date;
50: }
51:
52: /**
53: * @see org.apache.cocoon.profiling.statistics.PageReport#getStatistics()
54: */
55: public List getStatistics() {
56: return this .statistics;
57: }
58:
59: /**
60: * @param stats
61: */
62: public void addStatistics(Statistics stats) {
63: if (stats != null) {
64: this .statistics.add(new SimpleStats(stats.getCategory(),
65: stats.getDuration()));
66: }
67: }
68:
69: protected final static class SimpleStats implements Statistics {
70:
71: protected final String category;
72: protected final long duration;
73:
74: public SimpleStats(String category, long duration) {
75: this .category = category;
76: this .duration = duration;
77: }
78:
79: /**
80: * @see org.apache.cocoon.profiling.statistics.Statistics#getCategory()
81: */
82: public String getCategory() {
83: return this .category;
84: }
85:
86: /**
87: * @see org.apache.cocoon.profiling.statistics.Statistics#getDuration()
88: */
89: public long getDuration() {
90: return this.duration;
91: }
92: }
93: }
|