2
* AccessODF - Accessibility checker for OpenOffice.org and LibreOffice Writer.
4
* Copyright (c) 2011 by DocArch <http://www.docarch.be>.
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as
8
* published by the Free Software Foundation, either version 3 of the
9
* License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
package be.docarch.accessodf;
22
import java.util.Date;
23
import java.util.Collection;
24
import java.util.ArrayList;
32
private Collection<IssueListener> listeners;
34
private final Element element;
35
private final Check check;
36
private final Checker checker;
37
private final Date checkDate;
38
private final int count;
40
private boolean ignored = false;
41
private boolean repaired = false;
43
public Issue(Element element, Check check, Checker checker) {
44
this(element, check, checker, 1);
47
public Issue(Element element, Check check, Checker checker, int count) {
48
this(element, check, checker, new Date(), count);
51
public Issue(Element element, Check check, Checker checker, Date checkDate) {
52
this(element, check, checker, checkDate, 1);
55
public Issue(Element element,
61
this.element = element;
63
this.checker = checker;
64
this.checkDate = checkDate;
68
public Element getElement() {
72
public boolean ignored() {
76
public boolean repaired() {
80
public Date getCheckDate() {
84
public Check getCheck() {
88
public Checker getChecker() {
92
public int getCount() {
96
public void ignored(boolean ignored) {
97
this.ignored = ignored;
98
fireEvent(IssueEvent.Type.IGNORE);
101
public void repaired(boolean repaired) {
102
this.repaired = repaired;
103
fireEvent(IssueEvent.Type.REPAIR);
106
public void remove() {
107
fireEvent(IssueEvent.Type.REMOVE);
110
public String getName() {
112
if (element == null) {
115
return element.toString();
119
private void fireEvent(IssueEvent.Type type) {
120
if (listeners == null) { return; }
121
IssueEvent event = new IssueEvent(this, type);
122
for (IssueListener listener : listeners) {
123
listener.issueUpdated(event);
127
public void addListener(IssueListener listener) {
128
if (listeners == null) { listeners = new ArrayList<IssueListener>(); }
129
listeners.add(listener);
133
public int hashCode() {
135
final int PRIME = 31;
137
hash = hash * PRIME + getCheck().hashCode();
138
if (element != null) {
139
hash = hash * PRIME + element.hashCode();
145
public boolean equals(Object obj) {
147
if (this == obj) { return true; }
148
if (obj == null) { return false; }
149
if (!(obj instanceof Issue)){ return false; }
150
final Issue that = (Issue)obj;
151
if (!this.getCheck().equals(that.getCheck())) {
154
if (element == null) {
155
return (that.getElement() == null);
157
return element.equals(that.getElement());