1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sourceforge.javadpkg.impl;
20
21 import net.sourceforge.javadpkg.DebianPackageConstants;
22 import net.sourceforge.javadpkg.DocumentPaths;
23 import net.sourceforge.javadpkg.control.PackageName;
24
25
26
27
28
29
30
31
32
33
34 public class DocumentPathsImpl implements DocumentPaths, DebianPackageConstants {
35
36
37
38 private String documentBasePath;
39
40 private String documentPath;
41
42 private String copyrightPath;
43
44 private String changeLogPath;
45
46 private String changeLogDebianPath;
47
48 private String changeLogGzipPath;
49
50 private String changeLogHtmlPath;
51
52 private String changeLogHtmlGzipPath;
53
54
55
56
57
58
59
60
61
62
63
64
65 public DocumentPathsImpl(PackageName name) {
66 super();
67
68 if (name == null)
69 throw new IllegalArgumentException("Argument name is null.");
70
71 this.initialize(DOC_BASE_PATH, name);
72 }
73
74
75
76
77
78
79
80
81
82
83
84
85 private void initialize(String docBasePath, PackageName name) {
86 this.documentBasePath = docBasePath;
87 this.documentPath = docBasePath + name.getName() + "/";
88 this.copyrightPath = this.documentPath + "copyright";
89 this.changeLogPath = this.documentPath + "changelog";
90 this.changeLogDebianPath = this.changeLogPath + ".Debian";
91 this.changeLogGzipPath = this.changeLogPath + ".gz";
92 this.changeLogHtmlPath = this.changeLogPath + ".html";
93 this.changeLogHtmlGzipPath = this.changeLogHtmlPath + ".gz";
94 }
95
96
97 @Override
98 public String getDocumentBasePath() {
99 return this.documentBasePath;
100 }
101
102
103 @Override
104 public String getDocumentPath() {
105 return this.documentPath;
106 }
107
108
109 @Override
110 public boolean isCopyrightPath(String path) {
111 if (path == null)
112 throw new IllegalArgumentException("Argument path is null.");
113
114 return this.copyrightPath.equals(path);
115 }
116
117
118 @Override
119 public String getCopyrightPath() {
120 return this.copyrightPath;
121 }
122
123
124 @Override
125 public boolean isChangeLogPath(String path) {
126 if (path == null)
127 throw new IllegalArgumentException("Argument path is null.");
128
129 return (path.equals(this.changeLogPath) || path.startsWith(this.changeLogPath + "."));
130 }
131
132
133 @Override
134 public boolean isChangeLogDebianPath(String path) {
135 if (path == null)
136 throw new IllegalArgumentException("Argument path is null.");
137
138 return (path.equals(this.changeLogDebianPath) || path.startsWith(this.changeLogDebianPath + "."));
139 }
140
141
142 @Override
143 public boolean isChangeLogGzipPath(String path) {
144 if (path == null)
145 throw new IllegalArgumentException("Argument path is null.");
146
147 if (!this.isChangeLogPath(path))
148 return false;
149 return path.endsWith(".gz");
150 }
151
152
153 @Override
154 public boolean isChangeLogHtmlPath(String path) {
155 int index;
156 String name, extension;
157
158
159 if (path == null)
160 throw new IllegalArgumentException("Argument path is null.");
161
162 if (!this.isChangeLogPath(path))
163 return false;
164 index = path.lastIndexOf('/');
165 name = path.substring(index + 1);
166 if (name.isEmpty())
167 return false;
168 index = name.indexOf('.');
169 if (index == -1)
170 return false;
171 extension = name.substring(index + 1);
172 if (extension.isEmpty())
173 return false;
174
175 return ("html".equals(extension) || extension.startsWith("html."));
176 }
177
178
179 @Override
180 public String getChangeLogPath() {
181 return this.changeLogPath;
182 }
183
184
185 @Override
186 public String getChangeLogGzipPath() {
187 return this.changeLogGzipPath;
188 }
189
190
191 @Override
192 public String getChangeLogHtmlPath() {
193 return this.changeLogHtmlPath;
194 }
195
196
197 @Override
198 public String getChangeLogHtmlGzipPath() {
199 return this.changeLogHtmlGzipPath;
200 }
201
202
203 }