src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java

changeset 1383
b980e8e6aabf
parent 1362
c46e0c9940d6
child 1413
bdcef2ef52d2
equal deleted inserted replaced
1382:27f7952eea3c 1383:b980e8e6aabf
159 * @param showversion true if we want to use @version tags. 159 * @param showversion true if we want to use @version tags.
160 * @param showauthor true if we want to use @author tags. 160 * @param showauthor true if we want to use @author tags.
161 * @param message the message retriever to print warnings. 161 * @param message the message retriever to print warnings.
162 */ 162 */
163 public TagletManager(boolean nosince, boolean showversion, 163 public TagletManager(boolean nosince, boolean showversion,
164 boolean showauthor, MessageRetriever message){ 164 boolean showauthor, MessageRetriever message) {
165 overridenStandardTags = new HashSet<String>(); 165 overridenStandardTags = new HashSet<String>();
166 potentiallyConflictingTags = new HashSet<String>(); 166 potentiallyConflictingTags = new HashSet<String>();
167 standardTags = new HashSet<String>(); 167 standardTags = new HashSet<String>();
168 standardTagsLowercase = new HashSet<String>(); 168 standardTagsLowercase = new HashSet<String>();
169 unseenCustomTags = new HashSet<String>(); 169 unseenCustomTags = new HashSet<String>();
251 * of directory and JAR file URLs. 251 * of directory and JAR file URLs.
252 * 252 *
253 * @param path the search path string 253 * @param path the search path string
254 * @return the resulting array of directory and JAR file URLs 254 * @return the resulting array of directory and JAR file URLs
255 */ 255 */
256 private static URL[] pathToURLs(String path) { 256 private URL[] pathToURLs(String path) {
257 StringTokenizer st = new StringTokenizer(path, File.pathSeparator); 257 Set<URL> urls = new LinkedHashSet<URL>();
258 URL[] urls = new URL[st.countTokens()]; 258 for (String s: path.split(File.pathSeparator)) {
259 int count = 0; 259 if (s.isEmpty()) continue;
260 while (st.hasMoreTokens()) { 260 try {
261 URL url = fileToURL(new File(st.nextToken())); 261 urls.add(new File(s).getAbsoluteFile().toURI().toURL());
262 if (url != null) { 262 } catch (MalformedURLException e) {
263 urls[count++] = url; 263 message.error("doclet.MalformedURL", s);
264 } 264 }
265 } 265 }
266 urls = Arrays.copyOf(urls, count); 266 return urls.toArray(new URL[urls.size()]);
267 return urls;
268 }
269
270 /**
271 * Returns the directory or JAR file URL corresponding to the specified
272 * local file name.
273 *
274 * @param file the File object
275 * @return the resulting directory or JAR file URL, or null if unknown
276 */
277 private static URL fileToURL(File file) {
278 String name;
279 try {
280 name = file.getCanonicalPath();
281 } catch (IOException e) {
282 name = file.getAbsolutePath();
283 }
284 name = name.replace(File.separatorChar, '/');
285 if (!name.startsWith("/")) {
286 name = "/" + name;
287 }
288 // If the file does not exist, then assume that it's a directory
289 if (!file.isFile()) {
290 name = name + "/";
291 }
292 try {
293 return new URL("file", "", name);
294 } catch (MalformedURLException e) {
295 throw new IllegalArgumentException("file");
296 }
297 } 267 }
298 268
299 269
300 /** 270 /**
301 * Add a new <code>SimpleTaglet</code>. If this tag already exists 271 * Add a new <code>SimpleTaglet</code>. If this tag already exists

mercurial