jdk/src/share/classes/com/sun/inputmethods/internal/indicim/DevanagariInputMethodDescriptor.java
changeset 5656 4868963e05e0
parent 5655 8dacdb7bb25b
parent 5645 c98f230a6078
child 5657 7e406ebed9a5
equal deleted inserted replaced
5655:8dacdb7bb25b 5656:4868963e05e0
     1 /*
       
     2  * Copyright (c) 2002, Oracle and/or its affiliates. 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.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 
       
    26 /*
       
    27  * (C) Copyright IBM Corp. 2000 - All Rights Reserved
       
    28  *
       
    29  * The original version of this source code and documentation is
       
    30  * copyrighted and owned by IBM. These materials are provided
       
    31  * under terms of a License Agreement between IBM and Sun.
       
    32  * This technology is protected by multiple US and International
       
    33  * patents. This notice and attribution to IBM may not be removed.
       
    34  *
       
    35  */
       
    36 
       
    37 package com.sun.inputmethods.internal.indicim;
       
    38 
       
    39 import java.awt.Image;
       
    40 import java.awt.im.spi.InputMethod;
       
    41 import java.awt.im.spi.InputMethodDescriptor;
       
    42 import java.util.Locale;
       
    43 import java.util.MissingResourceException;
       
    44 import java.util.ResourceBundle;
       
    45 
       
    46 public class DevanagariInputMethodDescriptor implements InputMethodDescriptor {
       
    47 
       
    48     static final Locale HINDI = new Locale("hi", "IN");
       
    49 
       
    50     public DevanagariInputMethodDescriptor() {
       
    51     }
       
    52 
       
    53     /**
       
    54      * @see java.awt.im.spi.InputMethodDescriptor#getAvailableLocales
       
    55      */
       
    56     public Locale[] getAvailableLocales() {
       
    57         return new Locale[] { HINDI };
       
    58     }
       
    59 
       
    60     /**
       
    61      * @see java.awt.im.spi.InputMethodDescriptor#hasDynamicLocaleList
       
    62      */
       
    63     public boolean hasDynamicLocaleList() {
       
    64         return false;
       
    65     }
       
    66 
       
    67     /**
       
    68      * @see java.awt.im.spi.InputMethodDescriptor#getInputMethodDisplayName
       
    69      */
       
    70     public synchronized String getInputMethodDisplayName(Locale inputLocale, Locale displayLanguage) {
       
    71         try {
       
    72             ResourceBundle resources = ResourceBundle.getBundle("com.sun.inputmethods.internal.indicim.resources.DisplayNames", displayLanguage);
       
    73             return resources.getString("DisplayName.Devanagari");
       
    74         } catch (MissingResourceException mre) {
       
    75             return "Devanagari Input Method";
       
    76         }
       
    77     }
       
    78 
       
    79     /**
       
    80      * @see java.awt.im.spi.InputMethodDescriptor#getInputMethodIcon
       
    81      */
       
    82     public Image getInputMethodIcon(Locale inputLocale) {
       
    83         return null;
       
    84     }
       
    85 
       
    86     /**
       
    87      * @see java.awt.im.spi.InputMethodDescriptor#createInputMethod
       
    88      */
       
    89     public InputMethod createInputMethod() throws Exception {
       
    90         IndicInputMethodImpl impl = new IndicInputMethodImpl(
       
    91             DevanagariTables.keyboardMap,
       
    92             DevanagariTables.joinWithNukta,
       
    93             DevanagariTables.nuktaForm,
       
    94             DevanagariTables.substitutionTable);
       
    95 
       
    96         return new IndicInputMethod(HINDI, impl);
       
    97     }
       
    98 
       
    99     public String toString() {
       
   100         return getClass().getName();
       
   101     }
       
   102 }