1 | /* |
2 | * JTiger Unit Testing Framework for J2SE 1.5 |
3 | * Copyright (C) 2005 Tony Morris |
4 | * |
5 | * This software is licenced under the |
6 | * Common Public Licence version 1.0 |
7 | * http://www.opensource.org/licenses/cpl1.0.php |
8 | * |
9 | * You received a copy of this licence with this software. |
10 | */ |
11 | package org.jtiger.report.xml; |
12 | |
13 | import java.util.Arrays; |
14 | import org.jtiger.framework.FixtureResult; |
15 | import org.jtiger.framework.FixtureResults; |
16 | |
17 | /** |
18 | * A bean that is used by {@link XmlFixtureResultsHandler the XML result handler} to produce a report. |
19 | * |
20 | * @author %javadoc.author.tag% |
21 | * @version %version%<br/> |
22 | * <i>Build Number %build.number%</i><br/> |
23 | * <i>Build Time %build.time% CET (GMT + 1)</i> |
24 | */ |
25 | public final class FixtureResultsBeanImpl |
26 | implements FixtureResultsBean |
27 | { |
28 | private static final long serialVersionUID = 2L; |
29 | |
30 | private FixtureResultBean[] fixtureResults; |
31 | |
32 | /** |
33 | * Create a default <tt>FixtureResultsBeanImpl</tt>. |
34 | */ |
35 | public FixtureResultsBeanImpl() |
36 | { |
37 | fixtureResults = new FixtureResultBean[0]; |
38 | } |
39 | |
40 | FixtureResultsBeanImpl(final FixtureResults fr) |
41 | { |
42 | fixtureResults = new FixtureResultBean[fr.size()]; |
43 | |
44 | int index = 0; |
45 | |
46 | for(FixtureResult result : fr) |
47 | { |
48 | fixtureResults[index] = new FixtureResultBeanImpl(result); |
49 | |
50 | index++; |
51 | } |
52 | } |
53 | |
54 | /** |
55 | * Returns the fixtureResults property of the bean. |
56 | * |
57 | * @return The fixtureResults property of the bean. |
58 | */ |
59 | public FixtureResultBean[] getFixtureResults() |
60 | { |
61 | return fixtureResults; |
62 | } |
63 | |
64 | /** |
65 | * Sets the fixtureResults property of the bean. |
66 | * |
67 | * @param fixtureResults The fixtureResults property of the bean. |
68 | */ |
69 | public void setFixtureResults(final FixtureResultBean[] fixtureResults) |
70 | { |
71 | this.fixtureResults = fixtureResults; |
72 | } |
73 | |
74 | /** |
75 | * Returns a <a href="%j2se.api.spec%/java/lang/String.html">java.lang.String</a> representation of the bean, which |
76 | * consists of the fixtureResults property. |
77 | * |
78 | * @return A <a href="%j2se.api.spec%/java/lang/String.html">java.lang.String</a> representation of the bean, which |
79 | * consists of the fixtureResults property. |
80 | */ |
81 | @Override |
82 | public String toString() |
83 | { |
84 | return Arrays.toString(fixtureResults); |
85 | } |
86 | |
87 | /** |
88 | * Compares two instance of <tt>FixtureResultsBeanImpl</tt> returning <code>true</code> iff the fixtureResults |
89 | * properties are equal, <code>false</code> otherwise. |
90 | * |
91 | * @param o An instance of <tt>FixtureResultsBeanImpl</tt> to compare for equality. |
92 | * @return <code>true</code> iff the fixtureResults properties are equal, <code>false</code> otherwise. |
93 | */ |
94 | @Override |
95 | public boolean equals(final Object o) |
96 | { |
97 | if(this == o) |
98 | { |
99 | return true; |
100 | } |
101 | |
102 | if(o == null || o.getClass() != FixtureResultsBeanImpl.class) |
103 | { |
104 | return false; |
105 | } |
106 | |
107 | final FixtureResultsBeanImpl r = (FixtureResultsBeanImpl)o; |
108 | |
109 | return Arrays.equals(fixtureResults, r.fixtureResults); |
110 | } |
111 | |
112 | /** |
113 | * Returns a hash code for this <tt>FixtureResultsBeanImpl</tt> based on the fixtureResults property. |
114 | * |
115 | * @return A hash code for this <tt>FixtureResultsBeanImpl</tt> based on the fixtureResults property. |
116 | */ |
117 | @Override |
118 | public int hashCode() |
119 | { |
120 | return Arrays.hashCode(fixtureResults); |
121 | } |
122 | } |