J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun in the LICENSE file that accompanied this code. |
| 10 | * |
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | * version 2 for more details (a copy is included in the LICENSE file that |
| 15 | * accompanied this code). |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License version |
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 24 | */ |
| 25 | |
| 26 | |
| 27 | package java.awt.im.spi; |
| 28 | |
| 29 | import java.awt.AWTException; |
| 30 | import java.awt.Image; |
| 31 | import java.util.Locale; |
| 32 | |
| 33 | /** |
| 34 | * Defines methods that provide sufficient information about an input method |
| 35 | * to enable selection and loading of that input method. |
| 36 | * The input method itself is only loaded when it is actually used. |
| 37 | * |
| 38 | * @since 1.3 |
| 39 | */ |
| 40 | |
| 41 | public interface InputMethodDescriptor { |
| 42 | |
| 43 | /** |
| 44 | * Returns the locales supported by the corresponding input method. |
| 45 | * The locale may describe just the language, or may also include |
| 46 | * country and variant information if needed. |
| 47 | * The information is used to select input methods by locale |
| 48 | * ({@link java.awt.im.InputContext#selectInputMethod(Locale)}). It may also |
| 49 | * be used to sort input methods by locale in a user-visible |
| 50 | * list of input methods. |
| 51 | * <p> |
| 52 | * Only the input method's primary locales should be returned. |
| 53 | * For example, if a Japanese input method also has a pass-through |
| 54 | * mode for Roman characters, typically still only Japanese would |
| 55 | * be returned. Thus, the list of locales returned is typically |
| 56 | * a subset of the locales for which the corresponding input method's |
| 57 | * implementation of {@link java.awt.im.spi.InputMethod#setLocale} returns true. |
| 58 | * <p> |
| 59 | * If {@link #hasDynamicLocaleList} returns true, this method is |
| 60 | * called each time the information is needed. This |
| 61 | * gives input methods that depend on network resources the chance |
| 62 | * to add or remove locales as resources become available or |
| 63 | * unavailable. |
| 64 | * |
| 65 | * @return the locales supported by the input method |
| 66 | * @exception AWTException if it can be determined that the input method |
| 67 | * is inoperable, for example, because of incomplete installation. |
| 68 | */ |
| 69 | Locale[] getAvailableLocales() throws AWTException; |
| 70 | |
| 71 | /** |
| 72 | * Returns whether the list of available locales can change |
| 73 | * at runtime. This may be the case, for example, for adapters |
| 74 | * that access real input methods over the network. |
| 75 | */ |
| 76 | boolean hasDynamicLocaleList(); |
| 77 | |
| 78 | /** |
| 79 | * Returns the user-visible name of the corresponding |
| 80 | * input method for the given input locale in the language in which |
| 81 | * the name will be displayed. |
| 82 | * <p> |
| 83 | * The inputLocale parameter specifies the locale for which text |
| 84 | * is input. |
| 85 | * This parameter can only take values obtained from this descriptor's |
| 86 | * {@link #getAvailableLocales} method or null. If it is null, an |
| 87 | * input locale independent name for the input method should be |
| 88 | * returned. |
| 89 | * <p> |
| 90 | * If a name for the desired display language is not available, the |
| 91 | * method may fall back to some other language. |
| 92 | * |
| 93 | * @param inputLocale the locale for which text input is supported, or null |
| 94 | * @param displayLanguage the language in which the name will be displayed |
| 95 | */ |
| 96 | String getInputMethodDisplayName(Locale inputLocale, Locale displayLanguage); |
| 97 | |
| 98 | /** |
| 99 | * Returns an icon for the corresponding input method. |
| 100 | * The icon may be used by a user interface for selecting input methods. |
| 101 | * <p> |
| 102 | * The inputLocale parameter specifies the locale for which text |
| 103 | * is input. |
| 104 | * This parameter can only take values obtained from this descriptor's |
| 105 | * {@link #getAvailableLocales} method or null. If it is null, an |
| 106 | * input locale independent icon for the input method should be |
| 107 | * returned. |
| 108 | * <p> |
| 109 | * The icon's size should be 16×16 pixels. |
| 110 | * |
| 111 | * @param inputLocale the locale for which text input is supported, or null |
| 112 | * @return an icon for the corresponding input method, or null |
| 113 | */ |
| 114 | Image getInputMethodIcon(Locale inputLocale); |
| 115 | |
| 116 | /** |
| 117 | * Creates a new instance of the corresponding input method. |
| 118 | * |
| 119 | * @return a new instance of the corresponding input method |
| 120 | * @exception Exception any exception that may occur while creating the |
| 121 | * input method instance |
| 122 | */ |
| 123 | InputMethod createInputMethod() throws Exception; |
| 124 | } |