src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SimpleDocFileFactory.java

changeset 1413
bdcef2ef52d2
parent 1412
400a4e8accd3
child 1985
0e6577980181
equal deleted inserted replaced
1412:400a4e8accd3 1413:bdcef2ef52d2
41 import java.util.ArrayList; 41 import java.util.ArrayList;
42 import java.util.LinkedHashSet; 42 import java.util.LinkedHashSet;
43 import java.util.List; 43 import java.util.List;
44 import java.util.Set; 44 import java.util.Set;
45 45
46 import javax.tools.DocumentationTool;
46 import javax.tools.JavaFileManager.Location; 47 import javax.tools.JavaFileManager.Location;
47 import javax.tools.StandardLocation; 48 import javax.tools.StandardLocation;
48 49
49 import com.sun.tools.doclets.internal.toolkit.Configuration; 50 import com.sun.tools.doclets.internal.toolkit.Configuration;
50 51
72 public DocFile createFileForInput(String file) { 73 public DocFile createFileForInput(String file) {
73 return new SimpleDocFile(new File(file)); 74 return new SimpleDocFile(new File(file));
74 } 75 }
75 76
76 public DocFile createFileForOutput(DocPath path) { 77 public DocFile createFileForOutput(DocPath path) {
77 return new SimpleDocFile(StandardLocation.CLASS_OUTPUT, path); 78 return new SimpleDocFile(DocumentationTool.Location.DOCUMENTATION_OUTPUT, path);
78 } 79 }
79 80
80 @Override 81 @Override
81 Iterable<DocFile> list(Location location, DocPath path) { 82 Iterable<DocFile> list(Location location, DocPath path) {
82 if (location != StandardLocation.SOURCE_PATH) 83 if (location != StandardLocation.SOURCE_PATH)
119 } 120 }
120 121
121 /** 122 /**
122 * Open an output stream for the file. 123 * Open an output stream for the file.
123 * The file must have been created with a location of 124 * The file must have been created with a location of
124 * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. 125 * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
125 */ 126 */
126 public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException { 127 public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException {
127 if (location != StandardLocation.CLASS_OUTPUT) 128 if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
128 throw new IllegalStateException(); 129 throw new IllegalStateException();
129 130
130 createDirectoryForFile(file); 131 createDirectoryForFile(file);
131 return new BufferedOutputStream(new FileOutputStream(file)); 132 return new BufferedOutputStream(new FileOutputStream(file));
132 } 133 }
133 134
134 /** 135 /**
135 * Open an writer for the file, using the encoding (if any) given in the 136 * Open an writer for the file, using the encoding (if any) given in the
136 * doclet configuration. 137 * doclet configuration.
137 * The file must have been created with a location of 138 * The file must have been created with a location of
138 * {@link StandardLocation#CLASS_OUTPUT} and a corresponding relative path. 139 * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
139 */ 140 */
140 public Writer openWriter() throws IOException, UnsupportedEncodingException { 141 public Writer openWriter() throws IOException, UnsupportedEncodingException {
141 if (location != StandardLocation.CLASS_OUTPUT) 142 if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
142 throw new IllegalStateException(); 143 throw new IllegalStateException();
143 144
144 createDirectoryForFile(file); 145 createDirectoryForFile(file);
145 FileOutputStream fos = new FileOutputStream(file); 146 FileOutputStream fos = new FileOutputStream(file);
146 if (configuration.docencoding == null) { 147 if (configuration.docencoding == null) {
241 } 242 }
242 } 243 }
243 244
244 /** 245 /**
245 * Resolve a relative file against the given output location. 246 * Resolve a relative file against the given output location.
246 * @param locn Currently, only SOURCE_OUTPUT is supported. 247 * @param locn Currently, only
247 */ 248 * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} is supported.
248 public DocFile resolveAgainst(StandardLocation locn) { 249 */
249 if (locn != StandardLocation.CLASS_OUTPUT) 250 public DocFile resolveAgainst(Location locn) {
251 if (locn != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
250 throw new IllegalArgumentException(); 252 throw new IllegalArgumentException();
251 return new SimpleDocFile( 253 return new SimpleDocFile(
252 new File(configuration.destDirName, file.getPath())); 254 new File(configuration.destDirName, file.getPath()));
253 } 255 }
254 256

mercurial