a80ba1a6791f27a6baac2ed3b73000ac0e52e054
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / spelling / engine / LocaleSensitiveSpellDictionary.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11
12 package net.sourceforge.phpdt.internal.ui.text.spelling.engine;
13
14 import java.net.MalformedURLException;
15 import java.net.URL;
16 import java.util.Locale;
17
18 import net.sourceforge.phpdt.internal.ui.PHPUIMessages;
19
20 /**
21  * Platform wide read-only locale sensitive dictionary for spell-checking.
22  * 
23  * @since 3.0
24  */
25 public class LocaleSensitiveSpellDictionary extends AbstractSpellDictionary {
26
27         /** The locale of this dictionary */
28         private final Locale fLocale;
29
30         /** The location of the dictionaries */
31         private final URL fLocation;
32
33         /**
34          * Creates a new locale sensitive spell dictionary.
35          * 
36          * @param locale
37          *            The locale for this dictionary
38          * @param location
39          *            The location of the locale sensitive dictionaries
40          */
41         public LocaleSensitiveSpellDictionary(final Locale locale,
42                         final URL location) {
43                 fLocation = location;
44                 fLocale = locale;
45         }
46
47         /**
48          * Returns the locale of this dictionary.
49          * 
50          * @return The locale of this dictionary
51          */
52         public final Locale getLocale() {
53                 return fLocale;
54         }
55
56         /*
57          * @see net.sourceforge.phpdt.internal.ui.text.spelling.engine.AbstractSpellDictionary#getURL()
58          */
59         protected final URL getURL() throws MalformedURLException {
60                 return new URL(
61                                 fLocation,
62                                 fLocale.toString().toLowerCase()
63                                                 + "." + PHPUIMessages.getString("Spelling.dictionary.file.extension")); //$NON-NLS-1$ //$NON-NLS-2$
64         }
65 }