blob: e14a0f687cc89625ed92ea40b2ec742c08475022 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
/*******************************************************************************
* Copyright (c) 2004, 2009 Frank Becker and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Frank Becker - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.internal.bugzilla.core;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* Class describing the html response of Bugzilla requests which are used within Mylyn. Strings should be in the
* language which is the default for an Bugzilla instance.
*
* @author Frank Becker
*/
public class BugzillaLanguageSettings {
private String languageName = "<unknown>"; //$NON-NLS-1$
public static final String COMMAND_ERROR_LOGIN = "error_login"; //$NON-NLS-1$
public static final String COMMAND_ERROR_COLLISION = "error_collision"; //$NON-NLS-1$
public static final String COMMAND_ERROR_COMMENT_REQUIRED = "error_comment_required"; //$NON-NLS-1$
public static final String COMMAND_ERROR_LOGGED_OUT = "error_logged_out"; //$NON-NLS-1$
public static final String COMMAND_BAD_LOGIN = "bad_login"; //$NON-NLS-1$
public static final String COMMAND_PROCESSED = "processed"; //$NON-NLS-1$
public static final String COMMAND_CHANGES_SUBMITTED = "changes_submitted"; //$NON-NLS-1$
public static final String COMMAND_SUSPICIOUS_ACTION = "suspicious_action"; //$NON-NLS-1$
public static final String COMMAND_BUG = "bug"; //$NON-NLS-1$
public static final String COMMAND_SUBMITTED = "submitted"; //$NON-NLS-1$
public static final String COMMAND_ERROR_CONFIRM_MATCH = "error_confirm_match"; //$NON-NLS-1$
public static final String COMMAND_ERROR_MATCH_FAILED = "error_match_failed"; //$NON-NLS-1$
private final Map<String, List<String>> languageAttributes = new LinkedHashMap<String, List<String>>();
public BugzillaLanguageSettings(String languageName) {
super();
this.languageName = languageName;
}
public String getLanguageName() {
return languageName;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((languageName == null) ? 0 : languageName.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
BugzillaLanguageSettings other = (BugzillaLanguageSettings) obj;
if (languageName == null) {
if (other.languageName != null) {
return false;
}
} else if (!languageName.equals(other.languageName)) {
return false;
}
return true;
}
public void setLanguageName(String languageName) {
this.languageName = languageName;
}
public void addLanguageAttribute(String command, String response) {
List<String> commandList = languageAttributes.get(command);
if (commandList == null) {
commandList = new LinkedList<String>();
languageAttributes.put(command.toLowerCase(), commandList);
}
commandList.add(response);
}
public List<String> getResponseForCommand(String command) {
return languageAttributes.get(command);
}
}
|