1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| package org.qedeq.kernel.dto.module; |
19 |
| |
20 |
| import java.util.ArrayList; |
21 |
| import java.util.List; |
22 |
| |
23 |
| import org.qedeq.kernel.base.module.Latex; |
24 |
| import org.qedeq.kernel.base.module.LatexList; |
25 |
| import org.qedeq.kernel.utility.EqualsUtility; |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| public class LatexListVo implements LatexList { |
35 |
| |
36 |
| |
37 |
| private final List list; |
38 |
| |
39 |
| |
40 |
| |
41 |
| |
42 |
6253
| public LatexListVo() {
|
43 |
6253
| this.list = new ArrayList();
|
44 |
| } |
45 |
| |
46 |
| |
47 |
| |
48 |
| |
49 |
| |
50 |
| |
51 |
10464
| public final void add(final LatexVo latex) {
|
52 |
10464
| list.add(latex);
|
53 |
| } |
54 |
| |
55 |
492743
| public final int size() {
|
56 |
492743
| return list.size();
|
57 |
| } |
58 |
| |
59 |
336370
| public final Latex get(final int index) {
|
60 |
336370
| return (Latex) list.get(index);
|
61 |
| } |
62 |
| |
63 |
2009
| public boolean equals(final Object obj) {
|
64 |
2009
| if (!(obj instanceof LatexListVo)) {
|
65 |
42
| return false;
|
66 |
| } |
67 |
1967
| final LatexListVo otherList = (LatexListVo) obj;
|
68 |
1967
| if (size() != otherList.size()) {
|
69 |
7
| return false;
|
70 |
| } |
71 |
1960
| for (int i = 0; i < size(); i++) {
|
72 |
1962
| if (!EqualsUtility.equals(get(i), otherList.get(i))) {
|
73 |
2
| return false;
|
74 |
| } |
75 |
| } |
76 |
1958
| return true;
|
77 |
| } |
78 |
| |
79 |
1752
| public int hashCode() {
|
80 |
1752
| int hash = 0;
|
81 |
1752
| for (int i = 0; i < size(); i++) {
|
82 |
1750
| hash = hash ^ (i + 1);
|
83 |
1750
| if (get(i) != null) {
|
84 |
1749
| hash = hash ^ get(i).hashCode();
|
85 |
| } |
86 |
| } |
87 |
1752
| return hash;
|
88 |
| } |
89 |
| |
90 |
1317
| public String toString() {
|
91 |
1317
| final StringBuffer buffer = new StringBuffer("Latex:\n");
|
92 |
1317
| for (int i = 0; i < size(); i++) {
|
93 |
1314
| if (i != 0) {
|
94 |
6
| buffer.append("\n");
|
95 |
| } |
96 |
1314
| buffer.append((i + 1) + ":\t");
|
97 |
1314
| buffer.append(get(i) != null ? get(i).toString() : null);
|
98 |
| } |
99 |
1317
| return buffer.toString();
|
100 |
| } |
101 |
| |
102 |
| } |