View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.tobago.example.demo;
21  
22  import org.apache.commons.lang3.StringUtils;
23  
24  import java.util.Locale;
25  
26  public class LocaleEntry {
27  
28    private Locale locale;
29    private Locale displayLocale;
30    private String country;
31    private String language;
32  
33    public LocaleEntry(final Locale locale, final Locale displayLocale) {
34      this.locale = locale;
35      this.displayLocale = displayLocale;
36      country = locale.getDisplayCountry(displayLocale);
37      language = locale.getDisplayLanguage(displayLocale);
38    }
39  
40    public boolean isDisabled() {
41      return StringUtils.isBlank(country);
42    }
43  
44    public Locale getLocale() {
45      return locale;
46    }
47  
48    public void setLocale(final Locale locale) {
49      this.locale = locale;
50    }
51  
52    public Locale getDisplayLocale() {
53      return displayLocale;
54    }
55  
56    public void setDisplayLocale(final Locale displayLocale) {
57      this.displayLocale = displayLocale;
58    }
59  
60    public String getCountry() {
61      return country;
62    }
63  
64    public void setCountry(final String country) {
65      this.country = country;
66    }
67  
68    public String getLanguage() {
69      return language;
70    }
71  
72    public void setLanguage(final String language) {
73      this.language = language;
74    }
75  }