Source Code Cross Referenced for Page.java in  » Content-Management-System » riotfamily » org » riotfamily » pages » model » 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 » riotfamily » org.riotfamily.pages.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ***** BEGIN LICENSE BLOCK *****
002:         * Version: MPL 1.1
003:         * The contents of this file are subject to the Mozilla Public License Version
004:         * 1.1 (the "License"); you may not use this file except in compliance with
005:         * the License. You may obtain a copy of the License at
006:         * http://www.mozilla.org/MPL/
007:         *
008:         * Software distributed under the License is distributed on an "AS IS" basis,
009:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
010:         * for the specific language governing rights and limitations under the
011:         * License.
012:         *
013:         * The Original Code is Riot.
014:         *
015:         * The Initial Developer of the Original Code is
016:         * Neteye GmbH.
017:         * Portions created by the Initial Developer are Copyright (C) 2007
018:         * the Initial Developer. All Rights Reserved.
019:         *
020:         * Contributor(s):
021:         *   Felix Gnass [fgnass at neteye dot de]
022:         *
023:         * ***** END LICENSE BLOCK ***** */
024:        package org.riotfamily.pages.model;
025:
026:        import java.util.Collection;
027:        import java.util.Date;
028:        import java.util.LinkedList;
029:        import java.util.List;
030:        import java.util.Locale;
031:        import java.util.Map;
032:
033:        import org.riotfamily.common.util.FormatUtils;
034:        import org.riotfamily.components.model.ComponentVersion;
035:        import org.riotfamily.components.model.VersionContainer;
036:
037:        /**
038:         * @author Felix Gnass [fgnass at neteye dot de]
039:         * @author Jan-Frederic Linde [jfl at neteye dot de]
040:         * @since 6.5
041:         */
042:        public class Page {
043:
044:            public static final String TITLE_PROPERTY = "title";
045:
046:            private Long id;
047:
048:            private PageNode node;
049:
050:            private Site site;
051:
052:            private String pathComponent;
053:
054:            private boolean hidden;
055:
056:            private boolean folder;
057:
058:            private String path;
059:
060:            private boolean wildcardInPath;
061:
062:            private boolean published;
063:
064:            private Date creationDate;
065:
066:            private VersionContainer versionContainer;
067:
068:            public Page() {
069:            }
070:
071:            public Page(String pathComponent, Site site) {
072:                this .pathComponent = pathComponent;
073:                this .site = site;
074:            }
075:
076:            public Long getId() {
077:                return this .id;
078:            }
079:
080:            public void setId(Long id) {
081:                this .id = id;
082:            }
083:
084:            public PageNode getNode() {
085:                return this .node;
086:            }
087:
088:            public void setNode(PageNode node) {
089:                this .node = node;
090:            }
091:
092:            public Site getSite() {
093:                return this .site;
094:            }
095:
096:            public void setSite(Site site) {
097:                this .site = site;
098:            }
099:
100:            public Locale getLocale() {
101:                return site.getLocale();
102:            }
103:
104:            public Date getCreationDate() {
105:                return creationDate;
106:            }
107:
108:            public void setCreationDate(Date creationDate) {
109:                this .creationDate = creationDate;
110:            }
111:
112:            public String getPathComponent() {
113:                return pathComponent;
114:            }
115:
116:            public void setPathComponent(String pathComponent) {
117:                this .pathComponent = pathComponent;
118:            }
119:
120:            public boolean isHidden() {
121:                return this .hidden;
122:            }
123:
124:            public void setHidden(boolean hidden) {
125:                this .hidden = hidden;
126:            }
127:
128:            /**
129:             * Returns whether the page only acts as container for other pages and
130:             * has no own content.
131:             */
132:            public boolean isFolder() {
133:                return this .folder;
134:            }
135:
136:            public void setFolder(boolean folder) {
137:                this .folder = folder;
138:            }
139:
140:            public String getPath() {
141:                if (path == null) {
142:                    path = buildPath();
143:                }
144:                return path;
145:            }
146:
147:            public void setPath(String path) {
148:                this .path = path;
149:            }
150:
151:            public String getFullPath() {
152:                if (site.getPathPrefix() != null) {
153:                    return site.getPathPrefix() + getPath();
154:                }
155:                return getPath();
156:            }
157:
158:            public boolean isWildcard() {
159:                return pathComponent.indexOf("@{") != -1;
160:            }
161:
162:            public boolean isWildcardInPath() {
163:                return this .wildcardInPath;
164:            }
165:
166:            public void setWildcardInPath(boolean wildcardInPath) {
167:                this .wildcardInPath = wildcardInPath;
168:            }
169:
170:            public String buildPath() {
171:                StringBuffer path = new StringBuffer();
172:                wildcardInPath = false;
173:                Page page = this ;
174:                while (page != null) {
175:                    path.insert(0, page.getPathComponent());
176:                    path.insert(0, '/');
177:                    wildcardInPath |= page.isWildcard();
178:                    page = page.getParentPage();
179:                }
180:                return path.toString();
181:            }
182:
183:            public Page getParentPage() {
184:                PageNode parentNode = node.getParent();
185:                if (parentNode == null) {
186:                    return null;
187:                }
188:                return parentNode.getPage(site);
189:            }
190:
191:            public List getChildPages() {
192:                return node.getChildPages(site);
193:            }
194:
195:            public Collection getChildPagesWithFallback() {
196:                return node.getChildPagesWithFallback(site);
197:            }
198:
199:            public Collection getAncestors() {
200:                LinkedList pages = new LinkedList();
201:                Page page = this ;
202:                while (page != null) {
203:                    pages.addFirst(page);
204:                    page = page.getParentPage();
205:                }
206:                return pages;
207:            }
208:
209:            public void addChildPage(Page child) {
210:                child.setSite(site);
211:                node.addChildNode(new PageNode(child));
212:            }
213:
214:            public String getHandlerName() {
215:                return node.getHandlerName();
216:            }
217:
218:            public VersionContainer getVersionContainer() {
219:                if (versionContainer == null) {
220:                    versionContainer = new VersionContainer();
221:                    ComponentVersion version = new ComponentVersion(Page.class
222:                            .getName());
223:                    versionContainer.setLiveVersion(version);
224:                }
225:                return versionContainer;
226:            }
227:
228:            public void setVersionContainer(VersionContainer versionContainer) {
229:                this .versionContainer = versionContainer;
230:            }
231:
232:            public ComponentVersion getComponentVersion(boolean preview) {
233:                return preview ? getVersionContainer().getLatestVersion()
234:                        : getVersionContainer().getLiveVersion();
235:            }
236:
237:            public Map getProperties(boolean preview) {
238:                ComponentVersion version = getComponentVersion(preview);
239:                return version != null ? version.getProperties() : null;
240:            }
241:
242:            public String getProperty(String key, boolean preview) {
243:                ComponentVersion version = getComponentVersion(preview);
244:                return version != null ? version.getProperty(key) : null;
245:            }
246:
247:            public String getTitle(boolean preview) {
248:                String title = getProperty(TITLE_PROPERTY, preview);
249:                if (title == null) {
250:                    title = FormatUtils.xmlToTitleCase(pathComponent);
251:                }
252:                return title;
253:            }
254:
255:            public boolean isDirty() {
256:                return getVersionContainer().isDirty();
257:            }
258:
259:            public boolean isPublished() {
260:                return this .published;
261:            }
262:
263:            public void setPublished(boolean published) {
264:                this .published = published;
265:            }
266:
267:            public boolean isEnabled() {
268:                return published && site.isEnabled();
269:            }
270:
271:            public boolean isVisible(boolean preview) {
272:                return !isHidden() && !node.isHidden() && !isWildcard()
273:                        && (isEnabled() || preview);
274:            }
275:
276:            public String toString() {
277:                return site + ":" + path;
278:            }
279:
280:            public boolean equals(Object o) {
281:                if (o instanceof  Page) {
282:                    Page page = (Page) o;
283:                    if (id == null) {
284:                        return this  == o;
285:                    }
286:                    return id.equals(page.getId());
287:                }
288:                return false;
289:            }
290:
291:            public int hashCode() {
292:                return id != null ? id.hashCode() : 0;
293:            }
294:
295:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.