Klasse DocFile
java.lang.Object
org.jdrupes.mdoclet.internal.doclets.toolkit.util.DocFile
Abstraction for handling files, which may be specified directly
(e.g. via a path on the command line) or relative to a Location.
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungprotected final JavaFileManager.LocationThe location for this file.protected final DocPathThe path relative to the (output) location.static final StringThe line separator for the current platform. -
Konstruktorübersicht
KonstruktorenModifiziererKonstruktorBeschreibungprotectedDocFile()Create a DocFile without a location or pathprotectedDocFile(JavaFileManager.Location location, DocPath path) Create a DocFile for a given location and relative path. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungabstract booleancanRead()Return true if the file can be read.abstract booleancanWrite()Return true if the file can be written.voidCopy the contents of another file directly to this file.voidcopyResource(DocPath resource, boolean overwrite, boolean replaceNewLine) Copy the contents of a resource file to this file.voidcopyResource(DocPath resource, Resources resources) Copy the contents of a resource file to this file.static DocFilecreateFileForDirectory(BaseConfiguration configuration, String file) Create a DocFile for a directory.static DocFilecreateFileForInput(BaseConfiguration configuration, String file) Create a DocFile for a file that will be opened for reading.static DocFilecreateFileForInput(BaseConfiguration configuration, Path file) Create a DocFile for a file that will be opened for reading.static DocFilecreateFileForOutput(BaseConfiguration configuration, DocPath path) Create a DocFile for a file that will be opened for writing.abstract booleanexists()Return true if the file exists.abstract FileObjectReturns a file object for the file.abstract StringgetName()Return the base name (last component) of the file name.abstract StringgetPath()Return the file system path for this file.abstract booleanReturn true if file has an absolute path name.abstract booleanReturn true if file identifies a directory.abstract booleanisFile()Return true if file identifies a file.abstract booleanisSameFile(DocFile other) Return true if this file is the same as another.list()If the file is a directory, list its contents.list(BaseConfiguration configuration, JavaFileManager.Location location, DocPath path) List the directories and files found in subdirectories along the elements of the given location.abstract booleanmkdirs()Create the file as a directory, including any parent directories.abstract InputStreamOpen an input stream for the file.abstract OutputStreamOpen an output stream for the file.abstract WriterOpen an writer for the file, using the encoding (if any) given in the doclet configuration.abstract DocFileDerive a new file by resolving a relative path against this file.abstract DocFileDerive a new file by resolving a relative path against this file.abstract DocFileResolve a relative file against the given output location.
-
Felddetails
-
PLATFORM_LINE_SEPARATOR
The line separator for the current platform.Use this when writing to external files.
-
location
The location for this file.Maybe null if the file was created without a location or path.
-
path
The path relative to the (output) location.Maybe null if the file was created without a location or path.
-
-
Konstruktordetails
-
DocFile
protected DocFile()Create a DocFile without a location or path -
DocFile
Create a DocFile for a given location and relative path.
-
-
Methodendetails
-
createFileForDirectory
Create a DocFile for a directory. -
createFileForInput
Create a DocFile for a file that will be opened for reading. -
createFileForInput
Create a DocFile for a file that will be opened for reading. -
createFileForOutput
Create a DocFile for a file that will be opened for writing. -
list
public static Iterable<DocFile> list(BaseConfiguration configuration, JavaFileManager.Location location, DocPath path) List the directories and files found in subdirectories along the elements of the given location.- Parameter:
configuration- the doclet configurationlocation- currently, onlyStandardLocation.SOURCE_PATHis supported.path- the subdirectory of the directories of the location for which to list files
-
getFileObject
Returns a file object for the file.- Gibt zurück:
- a file object
-
openInputStream
Open an input stream for the file.- Gibt zurück:
- an open input stream for the file
- Löst aus:
DocFileIOException- if there is a problem opening the stream
-
openOutputStream
public abstract OutputStream openOutputStream() throws DocFileIOException, UnsupportedEncodingExceptionOpen an output stream for the file.The file must have been created with a location of
DocumentationTool.Location.DOCUMENTATION_OUTPUTand a corresponding relative path.- Gibt zurück:
- an open output stream for the file
- Löst aus:
DocFileIOException- if there is a problem opening the streamUnsupportedEncodingException- if the configured encoding is not supported
-
openWriter
Open an writer for the file, using the encoding (if any) given in the doclet configuration.The file must have been created with a location of
DocumentationTool.Location.DOCUMENTATION_OUTPUTand a corresponding relative path.- Gibt zurück:
- an open output stream for the file
- Löst aus:
DocFileIOException- if there is a problem opening the streamUnsupportedEncodingException- if the configured encoding is not supported
-
copyFile
Copy the contents of another file directly to this file.- Parameter:
fromFile- the file to be copied- Löst aus:
DocFileIOException- if there is a problem file copying the file
-
copyResource
public void copyResource(DocPath resource, boolean overwrite, boolean replaceNewLine) throws DocFileIOException, ResourceIOException Copy the contents of a resource file to this file.- Parameter:
resource- the path of the resource, relative to the package of this classoverwrite- whether or not to overwrite the file if it already existsreplaceNewLine- if false, the file is copied as a binary file; if true, the file is written line by line, using the platform line separator- Löst aus:
DocFileIOException- if there is a problem while writing the copyResourceIOException- if there is a problem while reading the resource
-
copyResource
public void copyResource(DocPath resource, Resources resources) throws DocFileIOException, ResourceIOException Copy the contents of a resource file to this file.- Parameter:
resource- the path of the resource, relative to the package of this classresources- if not null, substitute occurrences of ##REPLACE:key##- Löst aus:
DocFileIOException- if there is a problem while writing the copyResourceIOException- if there is a problem while reading the resource
-
canRead
Return true if the file can be read. -
canWrite
Return true if the file can be written. -
exists
Return true if the file exists. -
getName
Return the base name (last component) of the file name. -
getPath
Return the file system path for this file. -
isAbsolute
Return true if file has an absolute path name. -
isDirectory
Return true if file identifies a directory. -
isFile
Return true if file identifies a file. -
isSameFile
Return true if this file is the same as another. -
list
If the file is a directory, list its contents.- Gibt zurück:
- the contents of the directory
- Löst aus:
DocFileIOException- if there is a problem while listing the directory
-
mkdirs
Create the file as a directory, including any parent directories. -
resolve
Derive a new file by resolving a relative path against this file.The new file will inherit the configuration and location of this file If this file has a path set, the new file will have a corresponding new path.
-
resolve
Derive a new file by resolving a relative path against this file.The new file will inherit the configuration and location of this file If this file has a path set, the new file will have a corresponding new path.
-
resolveAgainst
Resolve a relative file against the given output location.- Parameter:
locn- Currently, onlyDocumentationTool.Location.DOCUMENTATION_OUTPUTis supported.
-