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 | |
16 | /** |
17 | * A bean that is used by {@link org.jtiger.report.xml.XmlFixtureResultsHandler the XML result handler} to produce a report. |
18 | * |
19 | * @author %javadoc.author.tag% |
20 | * @version %version%<br/> |
21 | * <i>Build Number %build.number%</i><br/> |
22 | * <i>Build Time %build.time% CET (GMT + 1)</i> |
23 | */ |
24 | public final class FixtureResultBeanImpl implements FixtureResultBean |
25 | { |
26 | private static final long serialVersionUID = 2L; |
27 | |
28 | private TestResultBean[] testResults; |
29 | |
30 | /** |
31 | * Create a default <tt>FixtureResultBeanImpl</tt>. |
32 | */ |
33 | public FixtureResultBeanImpl() |
34 | { |
35 | testResults = new TestResultBean[0]; |
36 | } |
37 | |
38 | FixtureResultBeanImpl(final FixtureResult fr) |
39 | { |
40 | testResults = new TestResultBean[fr.size()]; |
41 | |
42 | for(int index = 0; index < testResults.length; index++) |
43 | { |
44 | testResults[index] = new TestResultBeanImpl(fr.get(0)); |
45 | } |
46 | } |
47 | |
48 | /** |
49 | * Returns the testResults property of the bean. |
50 | * |
51 | * @return The testResults property of the bean. |
52 | */ |
53 | public TestResultBean[] getTestResults() |
54 | { |
55 | return testResults; |
56 | } |
57 | |
58 | /** |
59 | * Sets the testResults property of the bean. |
60 | * |
61 | * @param testResults The testResults property of the bean. |
62 | */ |
63 | public void setTestResults(final TestResultBean[] testResults) |
64 | { |
65 | this.testResults = testResults; |
66 | } |
67 | |
68 | /** |
69 | * Returns a <a href="%j2se.api.spec%/java/lang/String.html">java.lang.String</a> representation of the bean, which |
70 | * consists of the testResults property. |
71 | * |
72 | * @return A <a href="%j2se.api.spec%/java/lang/String.html">java.lang.String</a> representation of the bean, which |
73 | * consists of the testResults property. |
74 | */ |
75 | @Override |
76 | public String toString() |
77 | { |
78 | return Arrays.toString(testResults); |
79 | } |
80 | |
81 | /** |
82 | * Compares two instance of <tt>FixtureResultBeanImpl</tt> returning <code>true</code> iff the testResults |
83 | * properties are equal, <code>false</code> otherwise. |
84 | * |
85 | * @param o An instance of <tt>FixtureResultBeanImpl</tt> to compare for equality. |
86 | * @return <code>true</code> iff the testResults properties are equal, <code>false</code> otherwise. |
87 | */ |
88 | @Override |
89 | public boolean equals(final Object o) |
90 | { |
91 | if(this == o) |
92 | { |
93 | return true; |
94 | } |
95 | |
96 | if(o == null || o.getClass() != FixtureResultBeanImpl.class) |
97 | { |
98 | return false; |
99 | } |
100 | |
101 | final FixtureResultBeanImpl r = (FixtureResultBeanImpl)o; |
102 | |
103 | return Arrays.equals(testResults, r.testResults); |
104 | } |
105 | |
106 | /** |
107 | * Returns a hash code for this <tt>FixtureResultBeanImpl</tt> based on the testResults property. |
108 | * |
109 | * @return A hash code for this <tt>FixtureResultBeanImpl</tt> based on the testResults property. |
110 | */ |
111 | @Override |
112 | public int hashCode() |
113 | { |
114 | return Arrays.hashCode(testResults); |
115 | } |
116 | } |