01: /*
02: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
03: * http://www.jaspersoft.com.
04: *
05: * Unless you have purchased a commercial license agreement from JasperSoft,
06: * the following license terms apply:
07: *
08: * This program is free software; you can redistribute it and/or modify
09: * it under the terms of the GNU General Public License version 2 as published by
10: * the Free Software Foundation.
11: *
12: * This program is distributed WITHOUT ANY WARRANTY; and without the
13: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14: * See the GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
18: * or write to:
19: *
20: * Free Software Foundation, Inc.,
21: * 59 Temple Place - Suite 330,
22: * Boston, MA USA 02111-1307
23: *
24: *
25: *
26: *
27: * LocaleAdapter.java
28: *
29: * Created on March 27, 2006, 8:19 PM
30: *
31: */
32:
33: package it.businesslogic.ireport.util;
34:
35: import java.util.Locale;
36:
37: /**
38: *
39: * @author gtoffoli
40: */
41: /**
42: * A simple class to enable locales to be placed in a combo box.
43: *
44: */
45: public class LocaleAdapter {
46: Locale l;
47:
48: public LocaleAdapter(Locale locale) {
49: l = locale;
50: }
51:
52: public Locale getLocale() {
53: return l;
54: }
55:
56: // ==> Modified by RL, June 3, 2005, introducing getVariant and Language Papiamentu
57: // Getdisplayname is now used to display the name according to the Locale.
58: // Possibly in Chinese language parts are combined differently.
59: public String toString() {
60: if (l.getLanguage().equals("")) {
61: return " - iReport - ";
62: } else if (l.getLanguage().equals("pap")) {
63: // Work aournd, as long as LocaleWrapper not active yet.
64: // TODO: Get LocaleWrapper active
65: String s;
66: s = "Papiamentu, " + "(" + l.getCountry();
67:
68: if (l.getVariant().length() > 0) {
69: s = s + ", " + l.getVariant() + ")";
70: } else {
71: s = s + ")";
72: }
73:
74: return s;
75: } else {
76: return l.getDisplayName(I18n.getCurrentLocale());
77: }
78: }
79: // <= End Modification RL, June 3, 2005
80:
81: /*
82: public String toString()
83: {
84: if( l.getCountry()==null || l.getCountry().length()==0 )
85: {
86: return l.getDisplayLanguage();
87: }
88: else
89: {
90: return l.getDisplayLanguage() + " - " + l.getDisplayCountry();
91: }
92: }
93: */
94:
95: }
|