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