1. /*
  2. * @(#)InputMethodDescriptor.java 1.8 00/02/02
  3. *
  4. * Copyright 1998-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package java.awt.im.spi;
  11. import java.awt.AWTException;
  12. import java.awt.Image;
  13. import java.util.Locale;
  14. /**
  15. * Defines methods that provide sufficient information about an input method
  16. * to enable selection and loading of that input method.
  17. * The input method itself is only loaded when it is actually used.
  18. *
  19. * @since 1.3
  20. */
  21. public interface InputMethodDescriptor {
  22. /**
  23. * Returns the locales supported by the corresponding input method.
  24. * The locale may describe just the language, or may also include
  25. * country and variant information if needed.
  26. * The information is used to select input methods by locale
  27. * ({@link java.awt.im.InputContext#selectInputMethod(Locale)}). It may also
  28. * be used to sort input methods by locale in a user-visible
  29. * list of input methods.
  30. * <p>
  31. * Only the input method's primary locales should be returned.
  32. * For example, if a Japanese input method also has a pass-through
  33. * mode for Roman characters, typically still only Japanese would
  34. * be returned. Thus, the list of locales returned is typically
  35. * a subset of the locales for which the corresponding input method's
  36. * implementation of {@link java.awt.im.spi.InputMethod#setLocale} returns true.
  37. * <p>
  38. * If {@link #hasDynamicLocaleList} returns true, this method is
  39. * called each time the information is needed. This
  40. * gives input methods that depend on network resources the chance
  41. * to add or remove locales as resources become available or
  42. * unavailable.
  43. *
  44. * @return the locales supported by the input method
  45. * @exception AWTException if it can be determined that the input method
  46. * is inoperable, for example, because of incomplete installation.
  47. */
  48. Locale[] getAvailableLocales() throws AWTException;
  49. /**
  50. * Returns whether the list of available locales can change
  51. * at runtime. This may be the case, for example, for adapters
  52. * that access real input methods over the network.
  53. */
  54. boolean hasDynamicLocaleList();
  55. /**
  56. * Returns the user-visible name of the corresponding
  57. * input method for the given input locale in the language in which
  58. * the name will be displayed.
  59. * <p>
  60. * The inputLocale parameter specifies the locale for which text
  61. * is input.
  62. * This parameter can only take values obtained from this descriptor's
  63. * {@link #getAvailableLocales} method or null. If it is null, an
  64. * input locale independent name for the input method should be
  65. * returned.
  66. * <p>
  67. * If a name for the desired display language is not available, the
  68. * method may fall back to some other language.
  69. *
  70. * @param inputLocale the locale for which text input is supported, or null
  71. * @param displayLanguage the language in which the name will be displayed
  72. */
  73. String getInputMethodDisplayName(Locale inputLocale, Locale displayLanguage);
  74. /**
  75. * Returns an icon for the corresponding input method.
  76. * The icon may be used by a user interface for selecting input methods.
  77. * <p>
  78. * The inputLocale parameter specifies the locale for which text
  79. * is input.
  80. * This parameter can only take values obtained from this descriptor's
  81. * {@link #getAvailableLocales} method or null. If it is null, an
  82. * input locale independent icon for the input method should be
  83. * returned.
  84. * <p>
  85. * The icon's size should be 16×16 pixels.
  86. *
  87. * @param inputLocale the locale for which text input is supported, or null
  88. * @return an icon for the corresponding input method, or null
  89. */
  90. Image getInputMethodIcon(Locale inputLocale);
  91. /**
  92. * Creates a new instance of the corresponding input method.
  93. *
  94. * @return a new instance of the corresponding input method
  95. * @exception Exception any exception that may occur while creating the
  96. * input method instance
  97. */
  98. InputMethod createInputMethod() throws Exception;
  99. }