Source Code Cross Referenced for LanguageImpl.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » portal » pluto » 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 » Content Management System » apache lenya 2.0 » org.apache.cocoon.portal.pluto.om.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.cocoon.portal.pluto.om.common;
018:
019:        import java.util.ArrayList;
020:        import java.util.Collection;
021:        import java.util.Enumeration;
022:        import java.util.HashMap;
023:        import java.util.Iterator;
024:        import java.util.ListResourceBundle;
025:        import java.util.Locale;
026:        import java.util.ResourceBundle;
027:        import java.util.StringTokenizer;
028:
029:        import org.apache.pluto.om.common.Language;
030:        import org.apache.pluto.util.Enumerator;
031:        import org.apache.pluto.util.StringUtils;
032:
033:        /**
034:         * 
035:         *
036:         * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
037:         * 
038:         * @version CVS $Id: LanguageImpl.java 433543 2006-08-22 06:22:54Z crossley $
039:         */
040:        public class LanguageImpl implements  Language, java.io.Serializable {
041:            // ResourceBundle creation part
042:
043:            /*private static class Resources extends ListResourceBundle {
044:                private Object [][] resources = null;
045:                private Language source = null;
046:
047:                public Resources(Language source)
048:                {                        
049:                    this.source = source;
050:                    Vector v  = new Vector();
051:                    Iterator it = source.getKeywords();
052:                    while(it != null && it.hasNext()) 
053:                        v.add(it.next());
054:
055:                    resources = new Object [][] {            
056:                            { "javax.portlet.title", source.getTitle()==null? "": source.getTitle()},
057:                            { "javax.portlet.short-title", source.getShortTitle()==null? "": source.getShortTitle()},
058:                            { "javax.portlet.keywords", v.size() > 0 ? v.toArray().toString() : ""}};
059:                }
060:
061:                public Object[][] getContents()
062:                {
063:                    return resources;
064:                }        
065:            }*/
066:
067:            private static class DefaultsResourceBundle extends
068:                    ListResourceBundle {
069:                private Object[][] resources;
070:
071:                public DefaultsResourceBundle(String defaultTitle,
072:                        String defaultShortTitle, String defaultKeyWords) {
073:                    resources = new Object[][] {
074:                            { "javax.portlet.title", defaultTitle },
075:                            { "javax.portlet.short-title", defaultShortTitle },
076:                            { "javax.portlet.keywords", defaultKeyWords } };
077:                }
078:
079:                protected Object[][] getContents() {
080:                    return resources;
081:                }
082:            }
083:
084:            private static class ResourceBundleImpl extends ResourceBundle {
085:                private HashMap data;
086:
087:                public ResourceBundleImpl(ResourceBundle bundle,
088:                        ResourceBundle defaults) {
089:                    data = new HashMap();
090:
091:                    importData(defaults);
092:                    importData(bundle);
093:                }
094:
095:                private void importData(ResourceBundle bundle) {
096:                    if (bundle != null) {
097:                        for (Enumeration enumeration = bundle.getKeys(); enumeration
098:                                .hasMoreElements();) {
099:                            String key = (String) enumeration.nextElement();
100:                            Object value = bundle.getObject(key);
101:
102:                            data.put(key, value);
103:                        }
104:                    }
105:                }
106:
107:                protected Object handleGetObject(String key) {
108:                    return data.get(key);
109:                }
110:
111:                public Enumeration getKeys() {
112:                    return new Enumerator(data.keySet());
113:                }
114:            }
115:
116:            private Locale locale;
117:            private String title;
118:            private String shortTitle;
119:            private ResourceBundle bundle;
120:            private ArrayList keywords;
121:
122:            public LanguageImpl(Locale locale, ResourceBundle bundle,
123:                    String defaultTitle, String defaultShortTitle,
124:                    String defaultKeyWords) {
125:                this .bundle = new ResourceBundleImpl(bundle,
126:                        new DefaultsResourceBundle(defaultTitle,
127:                                defaultShortTitle, defaultKeyWords));
128:
129:                this .locale = locale;
130:                title = this .bundle.getString("javax.portlet.title");
131:                shortTitle = this .bundle.getString("javax.portlet.short-title");
132:                keywords = toList(this .bundle
133:                        .getString("javax.portlet.keywords"));
134:            }
135:
136:            // Language implementation.
137:
138:            public Locale getLocale() {
139:                return locale;
140:            }
141:
142:            public String getTitle() {
143:                return title;
144:            }
145:
146:            public String getShortTitle() {
147:                return shortTitle;
148:            }
149:
150:            public Iterator getKeywords() {
151:                return keywords.iterator();
152:            }
153:
154:            public ResourceBundle getResourceBundle() {
155:                return bundle;
156:            }
157:
158:            // internal methods.
159:            private ArrayList toList(String value) {
160:                ArrayList keywords = new ArrayList();
161:
162:                for (StringTokenizer st = new StringTokenizer(value, ","); st
163:                        .hasMoreTokens();) {
164:                    keywords.add(st.nextToken().trim());
165:                }
166:
167:                return keywords;
168:            }
169:
170:            public String toString() {
171:                return toString(0);
172:            }
173:
174:            public String toString(final int indent) {
175:                StringBuffer buffer = new StringBuffer(50);
176:                StringUtils.newLine(buffer, indent);
177:                buffer.append(getClass().toString());
178:                buffer.append(":");
179:                StringUtils.newLine(buffer, indent);
180:                buffer.append("{");
181:                StringUtils.newLine(buffer, indent);
182:                buffer.append("locale='");
183:                buffer.append(locale);
184:                buffer.append("'");
185:                StringUtils.newLine(buffer, indent);
186:                buffer.append("title='");
187:                buffer.append(title);
188:                buffer.append("'");
189:                StringUtils.newLine(buffer, indent);
190:                buffer.append("shortTitle='");
191:                buffer.append(shortTitle);
192:                buffer.append("'");
193:                Iterator iterator = keywords.iterator();
194:                if (iterator.hasNext()) {
195:                    StringUtils.newLine(buffer, indent);
196:                    buffer.append("Keywords:");
197:                }
198:                while (iterator.hasNext()) {
199:                    buffer.append(iterator.next());
200:                    buffer.append(',');
201:                }
202:                StringUtils.newLine(buffer, indent);
203:                buffer.append("}");
204:                return buffer.toString();
205:            }
206:
207:            // additional methods.
208:
209:            /* (non-Javadoc)
210:             * @see java.lang.Object#equals(java.lang.Object)
211:             * used for element equality according collection implementations
212:             */
213:            public boolean equals(Object o) {
214:                return o == null ? false : ((LanguageImpl) o).getLocale()
215:                        .equals(this .locale);
216:            }
217:
218:            /* (non-Javadoc)
219:             * @see java.lang.Object#hashCode()
220:             */
221:            public int hashCode() {
222:                return locale.hashCode();
223:            }
224:
225:            public void setKeywords(Collection keywords) {
226:                this .keywords.clear();
227:                this .keywords.addAll(keywords);
228:            }
229:
230:            public void setLocale(Locale locale) {
231:                this .locale = locale;
232:            }
233:
234:            public void setShortTitle(String shortTitle) {
235:                this .shortTitle = shortTitle;
236:            }
237:
238:            public void setTitle(String title) {
239:                this.title = title;
240:            }
241:
242:        }
w__w___w__._j___a___va_2_s__.__c_o_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.