Source Code Cross Referenced for CopletData.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » portal » coplet » 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.coplet 
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.coplet;
018:
019:        import java.util.ArrayList;
020:        import java.util.HashMap;
021:        import java.util.Iterator;
022:        import java.util.List;
023:        import java.util.Map;
024:        import java.util.StringTokenizer;
025:
026:        import org.apache.cocoon.portal.factory.impl.AbstractProducible;
027:        import org.apache.cocoon.portal.util.DeltaApplicable;
028:        import org.apache.commons.lang.StringUtils;
029:
030:        /**
031:         *
032:         * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
033:         * @author <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
034:         * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj&ouml;rn L&uuml;tkemeier</a>
035:         * 
036:         * @version CVS $Id: CopletData.java 603311 2007-12-11 17:24:31Z cziegeler $
037:         */
038:        public class CopletData extends AbstractProducible implements 
039:                DeltaApplicable {
040:
041:            protected String title;
042:
043:            protected CopletBaseData copletBaseData;
044:
045:            protected Map attributes = new HashMap(3);
046:
047:            protected String allowedRoles;
048:
049:            protected transient List allowedRolesList;
050:
051:            /**
052:             * Signals whether a delta has been applied.
053:             */
054:            private boolean deltaApplied = false;
055:
056:            /**
057:             * Constructor
058:             */
059:            public CopletData() {
060:                // Nothing to do
061:            }
062:
063:            /**
064:             * Returns the title.
065:             * @return String
066:             */
067:            public String getTitle() {
068:                return title;
069:            }
070:
071:            /**
072:             * Sets the title.
073:             * @param title The title to set
074:             */
075:            public void setTitle(String title) {
076:                this .title = title;
077:            }
078:
079:            /**
080:             * Returns the copletBaseData.
081:             * @return CopletBaseData
082:             */
083:            public CopletBaseData getCopletBaseData() {
084:                return copletBaseData;
085:            }
086:
087:            /**
088:             * Sets the copletBaseData.
089:             * @param copletBaseData The copletBaseData to set
090:             */
091:            public void setCopletBaseData(CopletBaseData copletBaseData) {
092:                this .copletBaseData = copletBaseData;
093:            }
094:
095:            public Object removeAttribute(String key) {
096:                return this .attributes.remove(key);
097:            }
098:
099:            public Object getAttribute(String key) {
100:                return this .attributes.get(key);
101:            }
102:
103:            public void setAttribute(String key, Object value) {
104:                this .attributes.put(key, value);
105:            }
106:
107:            public Map getAttributes() {
108:                return this .attributes;
109:            }
110:
111:            /**
112:             * Applies the specified delta.
113:             * @throws ClassCastException If the object is not of the expected type.
114:             */
115:            public boolean applyDelta(Object object) {
116:                CopletData data = (CopletData) object;
117:
118:                this .deltaApplied = true;
119:
120:                String title = data.getTitle();
121:                if (title != null) {
122:                    this .setTitle(title);
123:                }
124:
125:                CopletBaseData copletBaseData = data.getCopletBaseData();
126:                if (copletBaseData != null) {
127:                    this .setCopletBaseData(copletBaseData);
128:                }
129:
130:                Iterator iterator = data.getAttributes().entrySet().iterator();
131:                Object attribute, delta;
132:                String key;
133:                Map.Entry entry;
134:                while (iterator.hasNext()) {
135:                    entry = (Map.Entry) iterator.next();
136:                    key = (String) entry.getKey();
137:                    delta = entry.getValue();
138:
139:                    attribute = this .getAttribute(key);
140:                    if (attribute == null) {
141:                        // add new attribute
142:                        this .setAttribute(key, delta);
143:                    } else if (attribute instanceof  DeltaApplicable) {
144:                        // apply delta
145:                        boolean success = ((DeltaApplicable) attribute)
146:                                .applyDelta(delta);
147:                        if (!success) {
148:                            // replace attribute
149:                            this .setAttribute(key, delta);
150:                        }
151:                    } else {
152:                        // replace attribute
153:                        this .setAttribute(key, delta);
154:                    }
155:                }
156:
157:                return true;
158:            }
159:
160:            /**
161:             * Checks if a delta has been applied.
162:             */
163:            public boolean deltaApplied() {
164:                return this .deltaApplied;
165:            }
166:
167:            /**
168:             * @return Returns the allowed roles.
169:             */
170:            public String getAllowedRoles() {
171:                return this .allowedRoles;
172:            }
173:
174:            /**
175:             * @param roles The allowed roles to set.
176:             */
177:            public void setAllowedRoles(String roles) {
178:                this .allowedRoles = roles;
179:                this .allowedRolesList = null;
180:            }
181:
182:            /**
183:             * Return the list of roles that are allowed to access this coplet
184:             * @return A list of roles or null if everyone is allowed.
185:             */
186:            public List getAllowedRolesList() {
187:                if (StringUtils.isBlank(this .allowedRoles)) {
188:                    return null;
189:                }
190:                if (this .allowedRolesList == null) {
191:                    this .allowedRolesList = new ArrayList();
192:                    final StringTokenizer tokenizer = new StringTokenizer(
193:                            this .allowedRoles, ",");
194:                    while (tokenizer.hasMoreElements()) {
195:                        String token = (String) tokenizer.nextElement();
196:                        this .allowedRolesList.add(token);
197:                    }
198:                    if (this .allowedRolesList.size() == 0) {
199:                        this .allowedRoles = null;
200:                        this .allowedRolesList = null;
201:                    }
202:                }
203:                return this .allowedRolesList;
204:            }
205:
206:            public void addToAllowedRoles(String role) {
207:                List l = this .getAllowedRolesList();
208:                if (l == null) {
209:                    l = new ArrayList();
210:                    l.add(role);
211:                } else {
212:                    if (!l.contains(role)) {
213:                        l.add(role);
214:                    }
215:                }
216:                this .buildRolesString(l);
217:            }
218:
219:            public void removeFromAllowedRoles(String role) {
220:                List l = this .getAllowedRolesList();
221:                if (l != null && l.contains(role)) {
222:                    l.remove(role);
223:                    if (l.size() == 0) {
224:                        this .allowedRoles = null;
225:                        this .allowedRolesList = null;
226:                    } else {
227:                        this .buildRolesString(l);
228:                    }
229:                }
230:            }
231:
232:            protected void buildRolesString(List fromList) {
233:                this .allowedRolesList = fromList;
234:                StringBuffer buffer = new StringBuffer();
235:                boolean first = true;
236:                Iterator i = fromList.iterator();
237:                while (i.hasNext()) {
238:                    String role = (String) i.next();
239:                    if (!first) {
240:                        buffer.append(',');
241:                    }
242:                    first = false;
243:                    buffer.append(role);
244:                }
245:                this.allowedRoles = buffer.toString();
246:            }
247:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.