Source Code Cross Referenced for PageCrawlerImpl.java in  » Testing » StoryTestIQ » fitnesse » wiki » 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 » Testing » StoryTestIQ » fitnesse.wiki 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
002:        // Released under the terms of the GNU General Public License version 2 or later.
003:        package fitnesse.wiki;
004:
005:        import java.util.Iterator;
006:        import java.util.List;
007:
008:        import fitnesse.components.FitNesseTraversalListener;
009:
010:        public class PageCrawlerImpl implements  PageCrawler {
011:            private PageCrawlerDeadEndStrategy deadEndStrategy;
012:
013:            protected PageCrawlerImpl() {
014:            }
015:
016:            public WikiPage getPage(WikiPage context, WikiPagePath path)
017:                    throws Exception {
018:                if (path == null)
019:                    return null;
020:
021:                if (path.isEmpty())
022:                    return context;
023:
024:                String firstPathElement = path.getFirst();
025:                WikiPagePath restOfPath = path.getRest();
026:                if (firstPathElement.equals(WikiPagePath.ROOT))
027:                    return getPage(getRoot(context), restOfPath);
028:
029:                WikiPage childPage = context.getChildPage(firstPathElement);
030:                if (childPage != null)
031:                    return getPage(childPage, restOfPath);
032:                else
033:                    return getPageAfterDeadEnd(context, firstPathElement,
034:                            restOfPath);
035:            }
036:
037:            protected WikiPage getPageAfterDeadEnd(WikiPage context,
038:                    String first, WikiPagePath rest) throws Exception {
039:                rest.addNameToFront(first);
040:                if (deadEndStrategy != null)
041:                    return deadEndStrategy.getPageAfterDeadEnd(context, rest,
042:                            this );
043:                else
044:                    return null;
045:            }
046:
047:            public void setDeadEndStrategy(PageCrawlerDeadEndStrategy strategy) {
048:                deadEndStrategy = strategy;
049:            }
050:
051:            public boolean pageExists(WikiPage context, WikiPagePath path)
052:                    throws Exception {
053:                return getPage(context, path) != null;
054:            }
055:
056:            public WikiPagePath getFullPathOfChild(WikiPage parent,
057:                    WikiPagePath childPath) throws Exception {
058:                WikiPagePath fullPathOfChild;
059:                if (childPath.isAbsolute())
060:                    fullPathOfChild = childPath.relativePath();
061:                else {
062:                    WikiPagePath absolutePathOfParent = new WikiPagePath(parent);
063:                    fullPathOfChild = absolutePathOfParent.append(childPath);
064:                }
065:                return fullPathOfChild;
066:            }
067:
068:            public WikiPagePath getFullPath(WikiPage page) throws Exception {
069:                return new WikiPagePath(page);
070:            }
071:
072:            public WikiPage addPage(WikiPage context, WikiPagePath path,
073:                    String content) throws Exception {
074:                WikiPage page = addPage(context, path);
075:                if (page != null) {
076:                    PageData data = new PageData(page);
077:                    data.setContent(content);
078:                    page.commit(data);
079:                }
080:                return page;
081:            }
082:
083:            public WikiPage addPage(WikiPage context, WikiPagePath path)
084:                    throws Exception {
085:                return getOrMakePage(context, path.getNames());
086:            }
087:
088:            private WikiPage getOrMakePage(WikiPage context, List namePieces)
089:                    throws Exception {
090:                String first = (String) namePieces.get(0);
091:                List rest = namePieces.subList(1, namePieces.size());
092:                WikiPage current;
093:                if (context.getChildPage(first) == null)
094:                    current = context.addChildPage(first);
095:                else
096:                    current = context.getChildPage(first);
097:                if (rest.size() == 0)
098:                    return current;
099:                return getOrMakePage(current, rest);
100:            }
101:
102:            public String getRelativeName(WikiPage base, WikiPage page)
103:                    throws Exception {
104:                StringBuffer qualName = new StringBuffer();
105:                for (WikiPage p = page; !isRoot(p) && p != base; p = p
106:                        .getParent()) {
107:                    if (p != page)
108:                        qualName.insert(0, ".");
109:                    qualName.insert(0, p.getName());
110:                }
111:                return qualName.toString();
112:            }
113:
114:            // TODO this doesn't belong here
115:            public static WikiPage getInheritedPage(String pageName,
116:                    WikiPage context) throws Exception {
117:                List ancestors = WikiPageUtil.getAncestorsStartingWith(context);
118:                for (Iterator iterator = ancestors.iterator(); iterator
119:                        .hasNext();) {
120:                    WikiPage ancestor = (WikiPage) iterator.next();
121:                    WikiPage namedPage = ancestor.getChildPage(pageName);
122:                    if (namedPage != null)
123:                        return namedPage;
124:                }
125:                return null;
126:            }
127:
128:            public boolean isRoot(WikiPage page) throws Exception {
129:                WikiPage parent = page.getParent();
130:                return parent == null || parent == page;
131:            }
132:
133:            public WikiPage getRoot(WikiPage page) throws Exception {
134:                if (isRoot(page))
135:                    return page;
136:                else
137:                    return getRoot(page.getParent());
138:            }
139:
140:            public void traverse(WikiPage context,
141:                    FitNesseTraversalListener listener) throws Exception {
142:                if (context.getClass() == SymbolicPage.class)
143:                    return;
144:                listener.processPage(context);
145:                List children = context.getChildren();
146:                for (Iterator iterator = children.iterator(); iterator
147:                        .hasNext();) {
148:                    WikiPage wikiPage = (WikiPage) iterator.next();
149:                    traverse(wikiPage, listener);
150:                }
151:            }
152:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.