Source Code Cross Referenced for Internationalization.java in  » Web-Mail » Jwma » dtw » webmail » util » config » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Mail » Jwma » dtw.webmail.util.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package dtw.webmail.util.config;
002:
003:        import dtw.webmail.util.StringUtil;
004:
005:        import java.util.*;
006:        import java.io.Serializable;
007:
008:        /** 
009:         * Class representing a model for i18n configuration
010:         * data.
011:         * <p>
012:         * @author Dieter Wimberger (wimpi)
013:         * @version (created Feb 24, 2003)
014:         */
015:        public class Internationalization implements  Serializable {
016:
017:            private Locale m_SystemLocale;
018:            private Locale m_DefaultViewLocale;
019:            private Set m_ViewLocales;
020:
021:            //private Set m_ViewLanguages;
022:
023:            public Internationalization() {
024:                //m_ViewLanguages = Collections.synchronizedSet(new TreeSet());
025:                m_ViewLocales = Collections.synchronizedSet(new HashSet(10));
026:            }//constructor
027:
028:            /**
029:             * Returns the system language in ISO two-letter
030:             * format.
031:             *
032:             * @return the language code as <tt>String</tt>.
033:             */
034:            public String getSystemLanguage() {
035:                return m_SystemLocale.getLanguage();
036:            }//getSystemLanguage
037:
038:            /**
039:             * Sets the system language. The parameter should be
040:             * an ISO two-letter format string.
041:             *
042:             * @param language the language as <tt>String</tt>.
043:             */
044:            public void setSystemLanguage(String language) {
045:                m_SystemLocale = new Locale(language, "");
046:            }//setSystemLanguage
047:
048:            /**
049:             * Returns the system locale.
050:             *
051:             * @return a <tt>Lcoale</tt> instance.
052:             */
053:            public Locale getSystemLocale() {
054:                return m_SystemLocale;
055:            }//getSystemLocale
056:
057:            /**
058:             * Sets the system locale.
059:             *
060:             * @param locale a <tt>Locale</tt> instance.
061:             */
062:            public void setSystemLocale(Locale locale) {
063:                m_SystemLocale = locale;
064:            }//setSystemLocale
065:
066:            /**
067:             * Returns the default view language in ISO two-letter
068:             * format.
069:             *
070:             * @return the language code as <tt>String</tt>.
071:             */
072:            public String getDefaultViewLanguage() {
073:                return m_DefaultViewLocale.getLanguage();
074:            }//getDefaultViewLanguage
075:
076:            /**
077:             * Sets the default view language. The parameter should be
078:             * an ISO two-letter format string.
079:             *
080:             * @param language the language as <tt>String</tt>.
081:             */
082:            public void setDefaultViewLanguage(String language) {
083:                m_DefaultViewLocale = new Locale(language, "");
084:            }//setDefaultViewLanguage
085:
086:            /**
087:             * Returns the default view locale.
088:             *
089:             * @return a <tt>Lcoale</tt> instance.
090:             */
091:            public Locale getDefaultViewLocale() {
092:                return m_DefaultViewLocale;
093:            }//getDefaultViewLocale
094:
095:            /**
096:             * Sets the default view locale.
097:             *
098:             * @param locale a <tt>Locale</tt> instance.
099:             */
100:            public void setDefaultViewLocale(Locale locale) {
101:                m_DefaultViewLocale = locale;
102:            }//setDefaultViewLocale
103:
104:            /**
105:             * Convenience method for obtaining the supported languages
106:             * (represented in ISO two letter code) as a simple
107:             * comma seperated list.
108:             * <p>
109:             * Note that this is supposed to be helpful for simplifying
110:             * the persistency mechanism.
111:             *
112:             * @return the list as <tt>String</tt>.
113:             */
114:            public String getViewLanguageList() {
115:                return StringUtil.join(listViewLanguages(), ",");
116:            }//getViewLanguageList
117:
118:            /**
119:             * Convenience method for setting the supported languages
120:             * (represented in ISO two letter code) as a simple
121:             * comma seperated list.
122:             * <p>
123:             * Note that this is supposed to be helpful for simplifying
124:             * the persistency mechanism.
125:             *
126:             * @return the list as <tt>String</tt>.
127:             */
128:            public void setViewLanguageList(String list) {
129:                String[] locales = StringUtil.split(list, ",");
130:                m_ViewLocales.clear();
131:                for (int i = 0; i < locales.length; i++) {
132:                    addViewLocale(new Locale(locales[i], ""));
133:                }
134:            }//setViewLanguageList
135:
136:            /**
137:             * Returns the list of languages (by their ISO two
138:             * letter code).
139:             *
140:             * @return the list as <tt>String[]</tt>.
141:             */
142:            public String[] listViewLanguages() {
143:                String[] strs = new String[m_ViewLocales.size()];
144:                int i = 0;
145:                for (Iterator iterator = m_ViewLocales.iterator(); iterator
146:                        .hasNext(); i++) {
147:                    strs[i] = ((Locale) iterator.next()).getLanguage();
148:                }
149:                return strs;
150:            }//listViewLanguages
151:
152:            /**
153:             * Returns a list of view languages as
154:             * locale instances.
155:             *
156:             * @return the view languages as <tt>Locale[]</tt>.
157:             */
158:            public Locale[] listViewLocales() {
159:                Locale[] strs = new Locale[m_ViewLocales.size()];
160:                return (Locale[]) m_ViewLocales.toArray(strs);
161:            }//listViewLocales
162:
163:            /**
164:             * Adds a language, specifying it's ISO two letter
165:             * code.
166:             *
167:             * @param lang the language as <tt>String</tt>.
168:             */
169:            public void addViewLanguage(String lang) {
170:                m_ViewLocales.add(new Locale(lang, ""));
171:            }//addViewLanguage
172:
173:            /**
174:             * Adds a view locale.
175:             *
176:             * @param locale a <tt>Locale</tt> instance.
177:             */
178:            public void addViewLocale(Locale locale) {
179:                m_ViewLocales.add(locale);
180:            }//addViewLocale
181:
182:            /**
183:             * Removes a view language.
184:             *
185:             * @param lang the language as <tt>String</tt>.
186:             */
187:            public void removeViewLanguage(String lang) {
188:                m_ViewLocales.remove(new Locale(lang, ""));
189:            }//removeViewLanguage
190:
191:            /**
192:             * Removes a view locale.
193:             *
194:             * @param locale a <tt>Locale</tt> instance.
195:             */
196:            public void removeViewLocale(Locale locale) {
197:                m_ViewLocales.remove(locale);
198:            }//removeViewLocale
199:
200:            /**
201:             * Tests if a given language (by ISO two letter code)
202:             * is supported.
203:             *
204:             * @param lang a <tt>String</tt> representing a language.
205:             * @return true if supported, false otherwise.
206:             */
207:            public boolean isSupportedViewLanguage(String lang) {
208:                return m_ViewLocales.contains(new Locale(lang, ""));
209:            }//isSupportedViewLanguage
210:
211:            /**
212:             * Tests if a given locale is supported.
213:             *
214:             * @param loc a <tt>Locale</tt> instance.
215:             * @return true if supported, false otherwise.
216:             */
217:            public boolean isSupportedViewLocale(Locale loc) {
218:                return m_ViewLocales.contains(loc);
219:            }//isSupportedViewLocale
220:
221:        }//class Internationalization
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.