xref: /AOO41X/main/odk/examples/DevelopersGuide/OfficeDev/Linguistic/XSpellAlternatives_impl.java (revision 34dd1e2512dbacb6a9a7e4c7f17b9296daa8eff3)
1*34dd1e25SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*34dd1e25SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*34dd1e25SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*34dd1e25SAndrew Rist  * distributed with this work for additional information
6*34dd1e25SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*34dd1e25SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*34dd1e25SAndrew Rist  * "License"); you may not use this file except in compliance
9*34dd1e25SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*34dd1e25SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*34dd1e25SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*34dd1e25SAndrew Rist  * software distributed under the License is distributed on an
15*34dd1e25SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*34dd1e25SAndrew Rist  * KIND, either express or implied.  See the License for the
17*34dd1e25SAndrew Rist  * specific language governing permissions and limitations
18*34dd1e25SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*34dd1e25SAndrew Rist  *************************************************************/
21*34dd1e25SAndrew Rist 
22*34dd1e25SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir import com.sun.star.lang.Locale;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir 
27cdf0e10cSrcweir public class XSpellAlternatives_impl implements
28cdf0e10cSrcweir     com.sun.star.linguistic2.XSpellAlternatives
29cdf0e10cSrcweir {
30cdf0e10cSrcweir     String      aWord;
31cdf0e10cSrcweir     Locale      aLanguage;
32cdf0e10cSrcweir     String[]    aAlt;           // list of alternatives, may be empty.
33cdf0e10cSrcweir     short       nType;          // type of failure
34cdf0e10cSrcweir 
XSpellAlternatives_impl( String aWord, Locale aLanguage, short nFailureType, String[] aAlt )35cdf0e10cSrcweir     public XSpellAlternatives_impl(
36cdf0e10cSrcweir             String      aWord,
37cdf0e10cSrcweir             Locale      aLanguage,
38cdf0e10cSrcweir             short       nFailureType,
39cdf0e10cSrcweir             String[]    aAlt )
40cdf0e10cSrcweir     {
41cdf0e10cSrcweir         this.aWord      = aWord;
42cdf0e10cSrcweir         this.aLanguage  = aLanguage;
43cdf0e10cSrcweir         this.aAlt       = aAlt;
44cdf0e10cSrcweir         this.nType      = nFailureType;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir         //!! none of these cases should ever occur!
47cdf0e10cSrcweir         //!! values provided only for safety
48cdf0e10cSrcweir         if (this.aWord == null)
49cdf0e10cSrcweir             this.aWord = new String();
50cdf0e10cSrcweir         if (this.aLanguage == null)
51cdf0e10cSrcweir             this.aLanguage = new Locale();
52cdf0e10cSrcweir 
53cdf0e10cSrcweir         // having no alternatives is OK though.
54cdf0e10cSrcweir         // still for safety an empty existing array has to be provided.
55cdf0e10cSrcweir         if (this.aAlt == null)
56cdf0e10cSrcweir             this.aAlt = new String[]{};
57cdf0e10cSrcweir     }
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 	// XSpellAlternatives
getWord()60cdf0e10cSrcweir     public String getWord() throws com.sun.star.uno.RuntimeException
61cdf0e10cSrcweir     {
62cdf0e10cSrcweir         return aWord;
63cdf0e10cSrcweir     }
getLocale()64cdf0e10cSrcweir     public Locale getLocale() throws com.sun.star.uno.RuntimeException
65cdf0e10cSrcweir     {
66cdf0e10cSrcweir         return aLanguage;
67cdf0e10cSrcweir     }
getFailureType()68cdf0e10cSrcweir     public short getFailureType() throws com.sun.star.uno.RuntimeException
69cdf0e10cSrcweir     {
70cdf0e10cSrcweir         return nType;
71cdf0e10cSrcweir     }
getAlternativesCount()72cdf0e10cSrcweir     public short getAlternativesCount() throws com.sun.star.uno.RuntimeException
73cdf0e10cSrcweir     {
74cdf0e10cSrcweir         return (short) aAlt.length;
75cdf0e10cSrcweir     }
getAlternatives()76cdf0e10cSrcweir     public String[] getAlternatives() throws com.sun.star.uno.RuntimeException
77cdf0e10cSrcweir     {
78cdf0e10cSrcweir         return aAlt;
79cdf0e10cSrcweir     }
80cdf0e10cSrcweir };
81cdf0e10cSrcweir 
82