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


001:        /* Copyright 2001 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;
007:
008:        import java.util.ArrayList;
009:        import java.util.Enumeration;
010:        import java.util.Hashtable;
011:        import java.util.List;
012:
013:        import org.apache.commons.logging.Log;
014:        import org.apache.commons.logging.LogFactory;
015:
016:        /**
017:         * User preferences for stylesheets performing theme transformation
018:         * @author Peter Kharchenko <a href="mailto:">pkharchenko@interactivebusiness.com</>a
019:         * @version $Revision: 35879 $
020:         */
021:
022:        public class ThemeStylesheetUserPreferences extends
023:                StylesheetUserPreferences {
024:
025:            private static final Log log = LogFactory
026:                    .getLog(ThemeStylesheetUserPreferences.class);
027:
028:            protected Hashtable channelAttributeNumbers;
029:            protected Hashtable channelAttributeValues;
030:            protected ArrayList defaultChannelAttributeValues;
031:
032:            public ThemeStylesheetUserPreferences() {
033:                super ();
034:                channelAttributeNumbers = new Hashtable();
035:                channelAttributeValues = new Hashtable();
036:                defaultChannelAttributeValues = new ArrayList();
037:            }
038:
039:            public ThemeStylesheetUserPreferences(
040:                    ThemeStylesheetUserPreferences ssup) {
041:                super (ssup);
042:                this .channelAttributeNumbers = new Hashtable(
043:                        ssup.channelAttributeNumbers);
044:                this .channelAttributeValues = new Hashtable(
045:                        ssup.channelAttributeValues);
046:                this .defaultChannelAttributeValues = new ArrayList(
047:                        ssup.defaultChannelAttributeValues);
048:            }
049:
050:            /**
051:             * Provides a copy of this object with all fields instantiated to reflect 
052:             * the values of this object. This allows subclasses to override to add
053:             * correct copying behavior for their added fields.
054:             * 
055:             * @return a copy of this object
056:             */
057:            public Object newInstance() {
058:                return new ThemeStylesheetUserPreferences(this );
059:            }
060:
061:            public String getChannelAttributeValue(String channelSubscribeId,
062:                    String attributeName) {
063:                Integer attributeNumber = (Integer) channelAttributeNumbers
064:                        .get(attributeName);
065:                if (attributeNumber == null) {
066:                    log
067:                            .error("ThemeStylesheetUserPreferences::getChannelAttributeValue() : Attempting to obtain a non-existing attribute \""
068:                                    + attributeName + "\".");
069:                    return null;
070:                }
071:                String value = null;
072:                List l = (List) channelAttributeValues.get(channelSubscribeId);
073:                if (l == null) {
074:                    //            log.debug("ThemeStylesheetUserPreferences::getChannelAttributeValue() : Attempting to obtain an attribute for a non-existing channel \""+channelSubscribeId+"\".");
075:                    // return null;
076:                    return (String) defaultChannelAttributeValues
077:                            .get(attributeNumber.intValue());
078:                } else {
079:                    if (attributeNumber.intValue() < l.size()) {
080:                        value = (String) l.get(attributeNumber.intValue());
081:                    }
082:                    if (value == null) {
083:                        try {
084:                            value = (String) defaultChannelAttributeValues
085:                                    .get(attributeNumber.intValue());
086:                        } catch (IndexOutOfBoundsException e) {
087:                            log
088:                                    .error("ThemeStylesheetUserPreferences::getChannelAttributeValue() : internal error - attribute name is registered, but no default value is provided.");
089:                            return null;
090:                        }
091:                    }
092:                }
093:                return value;
094:            }
095:
096:            /**
097:             * Returns channel attribute value only if it has been assigned specifically.
098:             * @param channelSubscribeId channel id
099:             * @param attributeName name of the attribute
100:             * @return attribute value or null if the value is determined by the attribute default
101:             */
102:            public String getDefinedChannelAttributeValue(
103:                    String channelSubscribeId, String attributeName) {
104:                Integer attributeNumber = (Integer) channelAttributeNumbers
105:                        .get(attributeName);
106:                if (attributeNumber == null) {
107:                    log
108:                            .error("ThemeStylesheetUserPreferences::hasDefinedChannelAttributeValue() : Attempting to obtain a non-existing attribute \""
109:                                    + attributeName + "\".");
110:                    return null;
111:                }
112:                List l = (List) channelAttributeValues.get(channelSubscribeId);
113:                if (l == null) {
114:                    return null;
115:                } else {
116:                    if (attributeNumber.intValue() < l.size())
117:                        return (String) l.get(attributeNumber.intValue());
118:                    else
119:                        return null;
120:                }
121:            }
122:
123:            // this should be modified to throw exceptions
124:            public void setChannelAttributeValue(String channelSubscribeId,
125:                    String attributeName, String attributeValue) {
126:                Integer attributeNumber = (Integer) channelAttributeNumbers
127:                        .get(attributeName);
128:                if (attributeNumber == null) {
129:                    log
130:                            .error("ThemeStylesheetUserPreferences::setChannelAttribute() : Attempting to set a non-existing channel attribute \""
131:                                    + attributeName + "\".");
132:                    return;
133:                }
134:                List l = (List) channelAttributeValues.get(channelSubscribeId);
135:                if (l == null)
136:                    l = this .createChannel(channelSubscribeId);
137:                try {
138:                    l.set(attributeNumber.intValue(), attributeValue);
139:                } catch (IndexOutOfBoundsException e) {
140:                    // bring up the array to the right size
141:                    for (int i = l.size(); i < attributeNumber.intValue(); i++) {
142:                        l.add((String) null);
143:                    }
144:                    l.add(attributeValue);
145:                }
146:            }
147:
148:            public void addChannelAttribute(String attributeName,
149:                    String defaultValue) {
150:                if (channelAttributeNumbers.get(attributeName) != null) {
151:                    log
152:                            .error("ThemeStylesheetUserPreferences::addChannelAttribute() : Attempting to re-add an existing channel attribute \""
153:                                    + attributeName + "\".");
154:                } else {
155:                    channelAttributeNumbers.put(attributeName, new Integer(
156:                            defaultChannelAttributeValues.size()));
157:                    // append to the end of the default value array
158:                    defaultChannelAttributeValues.add(defaultValue);
159:                }
160:            }
161:
162:            public void setChannelAttributeDefaultValue(String attributeName,
163:                    String defaultValue) {
164:                Integer attributeNumber = (Integer) channelAttributeNumbers
165:                        .get(attributeName);
166:                defaultChannelAttributeValues.set(attributeNumber.intValue(),
167:                        defaultValue);
168:            }
169:
170:            public void removeChannelAttribute(String attributeName) {
171:                Integer attributeNumber;
172:                if ((attributeNumber = (Integer) channelAttributeNumbers
173:                        .get(attributeName)) == null) {
174:                    log
175:                            .error("ThemeStylesheetUserPreferences::removeChannelAttribute() : Attempting to remove a non-existing channel attribute \""
176:                                    + attributeName + "\".");
177:                } else {
178:                    channelAttributeNumbers.remove(attributeName);
179:                    // do not touch the arraylists
180:                }
181:            }
182:
183:            public Enumeration getChannelAttributeNames() {
184:                return channelAttributeNumbers.keys();
185:            }
186:
187:            public void addChannel(String channelSubscribeId) {
188:                // check if the channel is there. In general it might be ok to use this functon to default
189:                // all of the channel's parameters
190:
191:                ArrayList l = new ArrayList(defaultChannelAttributeValues
192:                        .size());
193:
194:                if (channelAttributeValues.put(channelSubscribeId, l) != null
195:                        && log.isDebugEnabled())
196:                    log
197:                            .debug("ThemeStylesheetUserPreferences::addChannel() : Readding an existing channel (channelSubscribeId=\""
198:                                    + channelSubscribeId
199:                                    + "\"). All values will be set to default.");
200:            }
201:
202:            public void removeChannel(String channelSubscribeId) {
203:                if (channelAttributeValues.remove(channelSubscribeId) == null
204:                        && log.isDebugEnabled())
205:                    log
206:                            .error("ThemeStylesheetUserPreferences::removeChannel() : Attempting to remove an non-existing channel (channelSubscribeId=\""
207:                                    + channelSubscribeId + "\").");
208:            }
209:
210:            public Enumeration getChannels() {
211:                return channelAttributeValues.keys();
212:            }
213:
214:            public boolean hasChannel(String channelSubscribeId) {
215:                return channelAttributeValues.containsKey(channelSubscribeId);
216:            }
217:
218:            private ArrayList createChannel(String channelSubscribeId) {
219:                ArrayList l = new ArrayList(defaultChannelAttributeValues
220:                        .size());
221:                channelAttributeValues.put(channelSubscribeId, l);
222:                return l;
223:            }
224:
225:            public String getCacheKey() {
226:                StringBuffer sbKey = new StringBuffer();
227:                for (Enumeration e = channelAttributeValues.keys(); e
228:                        .hasMoreElements();) {
229:                    String channelId = (String) e.nextElement();
230:                    sbKey.append("(channel:").append(channelId).append(':');
231:                    List l = (List) channelAttributeValues.get(channelId);
232:                    for (int i = 0; i < l.size(); i++) {
233:                        String value = (String) l.get(i);
234:                        if (value == null)
235:                            value = (String) defaultChannelAttributeValues
236:                                    .get(i);
237:                        sbKey.append(value).append(",");
238:                    }
239:                    sbKey.append(")");
240:                }
241:                return super.getCacheKey().concat(sbKey.toString());
242:            }
243:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.