Source Code Cross Referenced for RepoItem.java in  » Portal » Open-Portal » com » sun » portal » app » filesharing » repo » 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 » Open Portal » com.sun.portal.app.filesharing.repo 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.sun.portal.app.filesharing.repo;
002:
003:        import com.sun.portal.app.filesharing.util.ParameterCheck;
004:
005:        import java.text.MessageFormat;
006:        import java.io.Serializable;
007:
008:        /**
009:         * @author Alejandro Abdelnur
010:         */
011:        public class RepoItem implements  Cloneable, Serializable {
012:            private static final String SEPARATOR = "/";
013:
014:            public static final RepoItem ROOT = new RepoItem();
015:
016:            private String _name;
017:            private RepoItem _parent;
018:            private boolean _isDirectory;
019:            private String _creator;
020:
021:            private long _created;
022:            private long _lastModified;
023:            private long _length;
024:            private boolean _fromRepo;
025:
026:            private RepoItem() {
027:                _name = SEPARATOR;
028:                _parent = null;
029:                _isDirectory = true;
030:                _creator = "ROOT";
031:                _fromRepo = true;
032:            }
033:
034:            public RepoItem(String filePath, String creator)
035:                    throws RepoException {
036:                ParameterCheck.checkNotEmpty("filepath", filePath, true);
037:                ParameterCheck.checkNotEmpty("creator", creator, true);
038:                if (filePath.indexOf(SEPARATOR) == -1) {
039:                    throw new RepoException("RI00", "Parameter '" + filePath
040:                            + "' must contain '" + SEPARATOR + "' characters");
041:                }
042:                if (filePath.indexOf(SEPARATOR) != 0) {
043:                    throw new RepoException("RI01", "Parameter '" + filePath
044:                            + "' must begin wiht a '" + SEPARATOR
045:                            + "' character");
046:                }
047:                if (filePath.indexOf(SEPARATOR + SEPARATOR) > -1) {
048:                    throw new RepoException("RI02", "Parameter '" + filePath
049:                            + "' must not contain consecutive '" + SEPARATOR
050:                            + "' characters");
051:                }
052:                if (filePath.equals(SEPARATOR)) {
053:                    _parent = null;
054:                    _name = SEPARATOR;
055:                    _isDirectory = true;
056:                    _creator = "ROOT";
057:                    _fromRepo = true;
058:                } else {
059:                    filePath = (filePath.endsWith(SEPARATOR)) ? filePath
060:                            .substring(0, filePath.length() - 1) : filePath;
061:                    _parent = getParent(filePath);
062:                    _name = getName(filePath, filePath.lastIndexOf(SEPARATOR));
063:                    _creator = creator;
064:                }
065:            }
066:
067:            private RepoItem getParent(String filePath) throws RepoException {
068:                if (filePath.equals(SEPARATOR)) {
069:                    return RepoItem.ROOT;
070:                } else {
071:                    int i = filePath.lastIndexOf(SEPARATOR);
072:                    return new RepoItem(getPath(filePath, i), "dummy");
073:                }
074:            }
075:
076:            private String getPath(String filePath, int separatorPos) {
077:                return filePath.substring(0, separatorPos + 1);
078:            }
079:
080:            private String getName(String filePath, int separatorPos) {
081:                return filePath.substring(separatorPos + 1);
082:            }
083:
084:            public RepoItem(RepoItem parent, String name, String creator)
085:                    throws RepoException {
086:                this (parent, name, false, creator, 0, 0, 0, false);
087:            }
088:
089:            public RepoItem(RepoItem parent, String name, String creator,
090:                    long length) throws RepoException {
091:                this (parent, name, false, creator, 0, 0, length, false);
092:            }
093:
094:            RepoItem(RepoItem parent, String name, boolean isDir,
095:                    String creator, long created, long lastMod, long length,
096:                    boolean fromRepo) throws RepoException {
097:                ParameterCheck.checkNotNull("parent", parent);
098:                ParameterCheck.checkNotEmpty("name", name, true);
099:                if (name.indexOf(SEPARATOR) > -1) {
100:                    throw new RepoException("RI03", "Parameter '" + name
101:                            + "' cannot contain '" + SEPARATOR + "' characters");
102:                }
103:                ParameterCheck.checkNotEmpty("creator", creator, true);
104:                _parent = parent;
105:                _name = name;
106:                _isDirectory = isDir;
107:                _creator = creator;
108:                _created = created;
109:                _lastModified = lastMod;
110:                _length = length;
111:                _fromRepo = fromRepo;
112:            }
113:
114:            private static final String TO_STRING = "RepoItem: name[{0}] parent[{1}]";
115:
116:            public String toString() {
117:                return MessageFormat.format(TO_STRING, new Object[] { _name,
118:                        _parent });
119:            }
120:
121:            public int hashCode() {
122:                return getPath().hashCode();
123:            }
124:
125:            public boolean equals(Object other) {
126:                if (other != null && other instanceof  RepoItem) {
127:                    return ((RepoItem) other).getPath().equals(getPath());
128:                }
129:                return false;
130:            }
131:
132:            public Object clone() {
133:                try {
134:                    return new RepoItem(_parent, _name, _isDirectory, _creator,
135:                            _created, _lastModified, _length, _fromRepo);
136:                } catch (RepoException ex) {
137:                    throw new RuntimeException("It cannot happen");
138:                }
139:            }
140:
141:            public String getName() {
142:                return _name;
143:            }
144:
145:            public RepoItem getParent() {
146:                return _parent;
147:            }
148:
149:            public String getPath() {
150:                String path;
151:                if (_parent == null) {
152:                    path = SEPARATOR;
153:                } else {
154:                    if (_parent.equals(ROOT)) {
155:                        path = SEPARATOR + _name;
156:                    } else {
157:                        path = _parent.getPath() + SEPARATOR + _name;
158:                    }
159:                }
160:                return path;
161:            }
162:
163:            public long getLength() {
164:                return _length;
165:            }
166:
167:            public boolean isDirectory() {
168:                return _isDirectory;
169:            }
170:
171:            public long getCreated() {
172:                return _created;
173:            }
174:
175:            public long getLastModified() {
176:                return _lastModified;
177:            }
178:
179:            public String getCreator() {
180:                return _creator;
181:            }
182:
183:            public boolean isFromRepo() {
184:                return _fromRepo;
185:            }
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.