Source Code Cross Referenced for LanguageSetImpl.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » container » om » common » 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 » Portal » uPortal_rel 2 6 1 GA » org.jasig.portal.container.om.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2004 The JA-SIG Collaborative.  All rights reserved.
002:         *  See license distributed with this file and
003:         *  available online at http://www.uportal.org/license.html
004:         */
005:
006:        package org.jasig.portal.container.om.common;
007:
008:        import java.io.Serializable;
009:        import java.util.HashMap;
010:        import java.util.Iterator;
011:        import java.util.Locale;
012:        import java.util.Map;
013:        import java.util.MissingResourceException;
014:        import java.util.ResourceBundle;
015:
016:        import org.apache.commons.logging.Log;
017:        import org.apache.commons.logging.LogFactory;
018:        import org.apache.pluto.om.common.Language;
019:        import org.apache.pluto.om.common.LanguageSet;
020:
021:        /**
022:         * Implementation of Apache Pluto object model.
023:         * @author Ken Weiner, kweiner@unicon.net
024:         * @version $Revision: 35013 $
025:         */
026:        public class LanguageSetImpl implements  LanguageSet, Serializable {
027:
028:            private String title = null;
029:            private String shortTitle = null;
030:            private String keywords = null;
031:            private String resources = null;
032:            private ClassLoader classLoader = null;
033:            private Map languages = null; // Locale --> Language
034:            private boolean resourceBundleInitialized = false;
035:            private boolean hasResourceBundle = false;
036:            private static final Log log = LogFactory
037:                    .getLog(LanguageSetImpl.class);
038:
039:            public LanguageSetImpl(String title, String shortTitle,
040:                    String keywords, String resources) {
041:                languages = new HashMap();
042:                this .title = title;
043:                this .shortTitle = shortTitle;
044:                this .keywords = keywords;
045:                this .resources = resources;
046:
047:                hasResourceBundle = resources != null;
048:            }
049:
050:            // LanguageSet methods
051:
052:            public Iterator iterator() {
053:                if (!resourceBundleInitialized) {
054:                    initResourceBundle();
055:                    resourceBundleInitialized = true;
056:                }
057:                return languages.values().iterator();
058:            }
059:
060:            public Iterator getLocales() {
061:                return languages.keySet().iterator();
062:            }
063:
064:            public Language get(Locale locale) {
065:                if (!resourceBundleInitialized) {
066:                    initResourceBundle();
067:                    resourceBundleInitialized = true;
068:                }
069:                return (Language) languages.get(locale);
070:            }
071:
072:            public Locale getDefaultLocale() {
073:                Locale defaultLocale = Locale.getDefault();
074:                return defaultLocale;
075:            }
076:
077:            // Additional methods
078:
079:            public void setResources(String resourceBundleBase) {
080:                this .resources = resourceBundleBase;
081:            }
082:
083:            public void setClassLoader(ClassLoader classLoader) {
084:                this .classLoader = classLoader;
085:            }
086:
087:            public void addLocale(Locale locale) {
088:                // The null Language values will be replaced
089:                // during the initResourceBundle() method
090:                // since we don't have the right class loader at the
091:                // time this method is called
092:                languages.put(locale, null);
093:            }
094:
095:            private void addLanguage(Locale locale) {
096:                ResourceBundle resourceBundle = null;
097:                if (hasResourceBundle) {
098:                    resourceBundle = loadResourceBundle(locale);
099:                }
100:                Language language = createLanguage(locale, resourceBundle);
101:                languages.put(language.getLocale(), language);
102:            }
103:
104:            // Create Language object with data from this class (title, short-title, description, keywords)
105:            private Language createLanguage(Locale locale, ResourceBundle bundle) {
106:                LanguageImpl lang = new LanguageImpl(locale, bundle, title,
107:                        shortTitle, keywords);
108:                return (Language) lang;
109:            }
110:
111:            // Loads resource bundle files from WEB-INF/classes directory
112:            private ResourceBundle loadResourceBundle(Locale locale) {
113:                ResourceBundle resourceBundle = null;
114:                try {
115:                    if (classLoader != null) {
116:                        resourceBundle = ResourceBundle.getBundle(resources,
117:                                locale, classLoader);
118:                    } else {
119:                        resourceBundle = ResourceBundle.getBundle(resources,
120:                                locale, Thread.currentThread()
121:                                        .getContextClassLoader());
122:                    }
123:                } catch (MissingResourceException mre) {
124:                    if (log.isErrorEnabled()) {
125:                        log.error("Cannot obtain portlet resource bundle '"
126:                                + resources + "'", mre);
127:                    }
128:                }
129:                return resourceBundle;
130:            }
131:
132:            private void initResourceBundle() {
133:                // Assume that by now, we have a proper webapp class loader
134:                addLocale(Locale.getDefault());
135:                for (Iterator iter = languages.keySet().iterator(); iter
136:                        .hasNext();) {
137:                    Locale locale = (Locale) iter.next();
138:                    addLanguage(locale);
139:                }
140:            }
141:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.