Skip to main content
summaryrefslogtreecommitdiffstats
blob: 84722707c8de3f8949cec071422dcd656a45ffc3 (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
/*******************************************************************************
 * Copyright (c) 2004, 2008 Tasktop Technologies 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>";

	public static final String COMMAND_ERROR_LOGIN = "error_login";

	public static final String COMMAND_ERROR_COLLISION = "error_collision";

	public static final String COMMAND_ERROR_COMMENT_REQUIRED = "error_comment_required";

	public static final String COMMAND_ERROR_LOGGED_OUT = "error_logged_out";

	public static final String COMMAND_BAD_LOGIN = "bad_login";

	public static final String COMMAND_PROCESSED = "processed";

	public static final String COMMAND_CHANGES_SUBMITTED = "changes_submitted";

	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);
	}
}

Back to the top