Source Code Cross Referenced for WikiPagePath.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 fitnesse.util.StringUtil;
006:        import java.util.*;
007:        import java.io.Serializable;
008:
009:        public class WikiPagePath implements  Comparable, Cloneable,
010:                Serializable {
011:            private static final long serialVersionUID = 1L;
012:
013:            public static final String ROOT = "_root";
014:
015:            private LinkedList names = new LinkedList();
016:
017:            public WikiPagePath() {
018:            }
019:
020:            protected Object clone() throws CloneNotSupportedException {
021:                WikiPagePath clone = new WikiPagePath();
022:                clone.names = (LinkedList) names.clone();
023:                return clone;
024:            }
025:
026:            public WikiPagePath copy() {
027:                try {
028:                    return (WikiPagePath) clone();
029:                } catch (CloneNotSupportedException e) {
030:                    return null;
031:                }
032:            }
033:
034:            public WikiPagePath(WikiPage page) throws Exception {
035:                PageCrawler crawler = page.getPageCrawler();
036:                while (!crawler.isRoot(page)) {
037:                    names.addFirst(page.getName());
038:                    page = page.getParent();
039:                }
040:            }
041:
042:            public WikiPagePath(WikiPagePath path) {
043:                for (WikiPagePath p = path; !p.isEmpty(); p = p.getRest())
044:                    addName(p.getFirst());
045:            }
046:
047:            private WikiPagePath(List names) {
048:                this .names = new LinkedList(names);
049:            }
050:
051:            public String getFirst() {
052:                return isEmpty() ? null : (String) names.get(0);
053:            }
054:
055:            public WikiPagePath addName(String name) {
056:                names.add(name);
057:                return this ;
058:            }
059:
060:            public WikiPagePath addNameToFront(String name) {
061:                names.addFirst(name);
062:                return this ;
063:            }
064:
065:            public WikiPagePath getRest() {
066:                int size = names.size();
067:                return (size <= 1) ? new WikiPagePath() : new WikiPagePath(
068:                        names.subList(1, size));
069:            }
070:
071:            public boolean isEmpty() {
072:                return names.size() == 0;
073:            }
074:
075:            public String last() {
076:                return (String) (names.size() == 0 ? null : names.get(names
077:                        .size() - 1));
078:            }
079:
080:            public List getNames() {
081:                return names;
082:            }
083:
084:            public String toString() {
085:                return "(" + StringUtil.join(names, ".") + ")";
086:            }
087:
088:            public void pop() {
089:                if (names.size() > 0)
090:                    names.removeLast();
091:            }
092:
093:            public WikiPagePath append(WikiPagePath childPath) {
094:                WikiPagePath newPath = new WikiPagePath(this );
095:                for (WikiPagePath p = childPath; !p.isEmpty(); p = p.getRest())
096:                    newPath.addName(p.getFirst());
097:                return newPath;
098:            }
099:
100:            public boolean isAbsolute() {
101:                return (!isEmpty() && ROOT.equals(getFirst()));
102:            }
103:
104:            public void makeAbsolute() {
105:                if (!isAbsolute())
106:                    addNameToFront(ROOT);
107:            }
108:
109:            public int hashCode() {
110:                return StringUtil.join(names, "").hashCode();
111:            }
112:
113:            public WikiPagePath relativePath() {
114:                if (isAbsolute())
115:                    return getRest();
116:                else
117:                    return this ;
118:            }
119:
120:            public int compareTo(Object o) {
121:                if (o instanceof  WikiPagePath) {
122:                    WikiPagePath p = (WikiPagePath) o;
123:                    String compressedName = StringUtil.join(names, "");
124:                    String compressedArgumentName = StringUtil
125:                            .join(p.names, "");
126:                    return compressedName.compareTo(compressedArgumentName);
127:                }
128:                return 1; // we are greater because we are the right type.
129:            }
130:
131:            public boolean equals(Object o) {
132:                if (o instanceof  WikiPagePath) {
133:                    WikiPagePath that = (WikiPagePath) o;
134:                    return this .names.equals(that.names);
135:                }
136:                return false;
137:            }
138:
139:            public WikiPagePath parentPath() {
140:                WikiPagePath parentPath = new WikiPagePath(this );
141:                parentPath.pop();
142:                return parentPath;
143:            }
144:
145:            public boolean startsWith(WikiPagePath that) {
146:                if (that.names.size() > names.size())
147:                    return false;
148:
149:                Iterator this Iterator = names.iterator();
150:                Iterator thatIterator = that.names.iterator();
151:                while (thatIterator.hasNext()) {
152:                    Object this Next = this Iterator.next();
153:                    Object thatNext = thatIterator.next();
154:                    if (!this Next.equals(thatNext))
155:                        return false;
156:                }
157:                return true;
158:            }
159:
160:            public WikiPagePath withNameAdded(String name) {
161:                WikiPagePath path = new WikiPagePath(this);
162:                path.addName(name);
163:                return path;
164:            }
165:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.