001: /********************************************************************************
002: * CruiseControl, a Continuous Integration Toolkit
003: * Copyright (c) 2004, ThoughtWorks, Inc.
004: * 200 E. Randolph, 25th Floor
005: * Chicago, IL 60601 USA
006: * All rights reserved.
007: *
008: * Redistribution and use in source and binary forms, with or without
009: * modification, are permitted provided that the following conditions
010: * are met:
011: *
012: * + Redistributions of source code must retain the above copyright
013: * notice, this list of conditions and the following disclaimer.
014: *
015: * + Redistributions in binary form must reproduce the above
016: * copyright notice, this list of conditions and the following
017: * disclaimer in the documentation and/or other materials provided
018: * with the distribution.
019: *
020: * + Neither the name of ThoughtWorks, Inc., CruiseControl, nor the
021: * names of its contributors may be used to endorse or promote
022: * products derived from this software without specific prior
023: * written permission.
024: *
025: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
026: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
027: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
028: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
029: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
030: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
031: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
032: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
033: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
034: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
035: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
036: ********************************************************************************/package net.sourceforge.cruisecontrol;
037:
038: import java.io.Serializable;
039: import java.util.Collections;
040: import java.util.Iterator;
041: import java.util.List;
042:
043: public final class BuildInfoSummary implements Serializable {
044: private static final long serialVersionUID = 994064080136410358L;
045:
046: private final List buildInfoList;
047: private final int numBrokenBuilds;
048: private final int numSuccessfulBuilds;
049:
050: public BuildInfoSummary(List buildInfoList) {
051: this .buildInfoList = Collections
052: .unmodifiableList(buildInfoList);
053: int brokenBuildsCounter = 0;
054: int successfulBuildsCounter = 0;
055: for (Iterator i = buildInfoList.iterator(); i.hasNext();) {
056: BuildInfo buildInfo = (BuildInfo) i.next();
057: if (buildInfo.isSuccessful()) {
058: successfulBuildsCounter++;
059: } else {
060: brokenBuildsCounter++;
061: }
062: }
063: numBrokenBuilds = brokenBuildsCounter;
064: numSuccessfulBuilds = successfulBuildsCounter;
065: }
066:
067: /**
068: * @return Returns the buildInfoList.
069: */
070: public List getBuildInfoList() {
071: return buildInfoList;
072: }
073:
074: /**
075: * @return Returns the numBrokenBuilds.
076: */
077: public int getNumBrokenBuilds() {
078: return numBrokenBuilds;
079: }
080:
081: /**
082: * @return Returns the numSuccessfulBuilds.
083: */
084: public int getNumSuccessfulBuilds() {
085: return numSuccessfulBuilds;
086: }
087:
088: public Iterator iterator() {
089: return buildInfoList.iterator();
090: }
091:
092: public int size() {
093: return buildInfoList.size();
094: }
095:
096: public BuildInfo[] asArray() {
097: return (BuildInfo[]) buildInfoList
098: .toArray(new BuildInfo[buildInfoList.size()]);
099: }
100: }
|