author | jjg |
Mon, 22 Aug 2016 16:32:40 -0700 | |
changeset 40587 | 1c355ea550ed |
parent 35426 | 374342e56a56 |
child 45417 | f7479ee8de69 |
permissions | -rw-r--r-- |
14544 | 1 |
/* |
35420 | 2 |
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. |
14544 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
35420
diff
changeset
|
26 |
package jdk.javadoc.internal.doclets.toolkit.util; |
14544 | 27 |
|
28 |
import javax.tools.JavaFileManager; |
|
29 |
import javax.tools.JavaFileManager.Location; |
|
30 |
import javax.tools.StandardJavaFileManager; |
|
31 |
import javax.tools.StandardLocation; |
|
32 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
35420
diff
changeset
|
33 |
import jdk.javadoc.internal.doclets.toolkit.Configuration; |
40587 | 34 |
import jdk.javadoc.internal.doclets.toolkit.DocletException; |
14544 | 35 |
|
36 |
/** |
|
37 |
* Factory for DocFile objects. |
|
38 |
* |
|
39 |
* <p><b>This is NOT part of any supported API. |
|
40 |
* If you write code that depends on this, you do so at your own risk. |
|
41 |
* This code and its internal interfaces are subject to change or |
|
42 |
* deletion without notice.</b> |
|
43 |
* |
|
44 |
*/ |
|
35420 | 45 |
public abstract class DocFileFactory { |
14544 | 46 |
/** |
47 |
* Get the appropriate factory, based on the file manager given in the |
|
48 |
* configuration. |
|
40587 | 49 |
* |
50 |
* @param configuration the configuration for this doclet |
|
51 |
* @return the factory associated with this configuration |
|
14544 | 52 |
*/ |
40587 | 53 |
public static synchronized DocFileFactory getFactory(Configuration configuration) { |
35420 | 54 |
DocFileFactory f = configuration.docFileFactory; |
14544 | 55 |
if (f == null) { |
56 |
JavaFileManager fm = configuration.getFileManager(); |
|
29780
8f8e54a1fa20
8076420: Consolidate javac file handling in javac.file package
jjg
parents:
25874
diff
changeset
|
57 |
if (fm instanceof StandardJavaFileManager) { |
14544 | 58 |
f = new StandardDocFileFactory(configuration); |
29780
8f8e54a1fa20
8076420: Consolidate javac file handling in javac.file package
jjg
parents:
25874
diff
changeset
|
59 |
} else { |
8f8e54a1fa20
8076420: Consolidate javac file handling in javac.file package
jjg
parents:
25874
diff
changeset
|
60 |
throw new IllegalStateException(); |
14544 | 61 |
} |
35420 | 62 |
configuration.docFileFactory = f; |
14544 | 63 |
} |
64 |
return f; |
|
65 |
} |
|
66 |
||
67 |
protected Configuration configuration; |
|
68 |
||
69 |
protected DocFileFactory(Configuration configuration) { |
|
70 |
this.configuration = configuration; |
|
71 |
} |
|
72 |
||
40587 | 73 |
public abstract void setDestDir(String dir) throws DocletException; |
74 |
||
14544 | 75 |
/** Create a DocFile for a directory. */ |
76 |
abstract DocFile createFileForDirectory(String file); |
|
77 |
||
78 |
/** Create a DocFile for a file that will be opened for reading. */ |
|
79 |
abstract DocFile createFileForInput(String file); |
|
80 |
||
81 |
/** Create a DocFile for a file that will be opened for writing. */ |
|
82 |
abstract DocFile createFileForOutput(DocPath path); |
|
83 |
||
84 |
/** |
|
85 |
* List the directories and files found in subdirectories along the |
|
86 |
* elements of the given location. |
|
87 |
* @param location currently, only {@link StandardLocation#SOURCE_PATH} is supported. |
|
88 |
* @param path the subdirectory of the directories of the location for which to |
|
89 |
* list files |
|
90 |
*/ |
|
91 |
abstract Iterable<DocFile> list(Location location, DocPath path); |
|
92 |
} |