Added
Link Here
|
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2007 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
7 |
* |
8 |
* Contributors: |
9 |
* IBM Corporation - Initial API and implementation |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.cdt.core.language; |
12 |
|
13 |
import java.util.Collections; |
14 |
import java.util.Map; |
15 |
import java.util.TreeMap; |
16 |
|
17 |
/** |
18 |
* Provides programmatic access to language mappings for a project. |
19 |
*/ |
20 |
public class LanguageMappingConfiguration { |
21 |
|
22 |
/** |
23 |
* Project-wide mappings. |
24 |
*/ |
25 |
private Map fProjectMappings; |
26 |
|
27 |
/** |
28 |
* Creates a new <code>LanguageMappingConfiguration</code> with no |
29 |
* mappings defined. |
30 |
*/ |
31 |
public LanguageMappingConfiguration() { |
32 |
fProjectMappings = new TreeMap(); |
33 |
} |
34 |
|
35 |
/** |
36 |
* Returns a read-only copy of the project-wide language mappings. |
37 |
* @return a read-only copy of the project-wide language mappings. |
38 |
*/ |
39 |
public Map getProjectMappings() { |
40 |
return Collections.unmodifiableMap(fProjectMappings); |
41 |
} |
42 |
|
43 |
/** |
44 |
* Replaces the existing language mappings with the given |
45 |
* mappings. The given mappings should be between content type ids |
46 |
* (<code>String</code>) and language ids (<code>String</code>) |
47 |
* @param projectMappings |
48 |
*/ |
49 |
public void setProjectMappings(Map/*<String, String>*/ projectMappings) { |
50 |
fProjectMappings = new TreeMap(projectMappings); |
51 |
} |
52 |
|
53 |
/** |
54 |
* Maps a content type id to a language id. |
55 |
* @param contentType |
56 |
* @param language |
57 |
*/ |
58 |
public void addProjectMapping(String contentType, String language) { |
59 |
fProjectMappings.put(contentType, language); |
60 |
} |
61 |
|
62 |
/** |
63 |
* Removes the given content type mapping (if it exists). |
64 |
* @param contentType |
65 |
*/ |
66 |
public void removeProjectMapping(String contentType) { |
67 |
fProjectMappings.remove(contentType); |
68 |
} |
69 |
} |