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
Modifizierer und TypFeldBeschreibungprotected final JavaFileManager.Location
The location for this file.protected final DocPath
The path relative to the (output) location.static final String
The line separator for the current platform. -
Konstruktorübersicht
ModifiziererKonstruktorBeschreibungprotected
DocFile()
Create a DocFile without a location or pathprotected
DocFile
(JavaFileManager.Location location, DocPath path) Create a DocFile for a given location and relative path. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungabstract boolean
canRead()
Return true if the file can be read.abstract boolean
canWrite()
Return true if the file can be written.void
Copy the contents of another file directly to this file.void
copyResource
(DocPath resource, boolean overwrite, boolean replaceNewLine) Copy the contents of a resource file to this file.void
copyResource
(DocPath resource, Resources resources) Copy the contents of a resource file to this file.static DocFile
createFileForDirectory
(BaseConfiguration configuration, String file) Create a DocFile for a directory.static DocFile
createFileForInput
(BaseConfiguration configuration, String file) Create a DocFile for a file that will be opened for reading.static DocFile
createFileForInput
(BaseConfiguration configuration, Path file) Create a DocFile for a file that will be opened for reading.static DocFile
createFileForOutput
(BaseConfiguration configuration, DocPath path) Create a DocFile for a file that will be opened for writing.abstract boolean
exists()
Return true if the file exists.abstract FileObject
Returns a file object for the file.abstract String
getName()
Return the base name (last component) of the file name.abstract String
getPath()
Return the file system path for this file.abstract boolean
Return true if file has an absolute path name.abstract boolean
Return true if file identifies a directory.abstract boolean
isFile()
Return true if file identifies a file.abstract boolean
isSameFile
(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 boolean
mkdirs()
Create the file as a directory, including any parent directories.abstract InputStream
Open an input stream for the file.abstract OutputStream
Open an output stream for the file.abstract Writer
Open an writer for the file, using the encoding (if any) given in the doclet configuration.abstract DocFile
Derive a new file by resolving a relative path against this file.abstract DocFile
Derive a new file by resolving a relative path against this file.abstract DocFile
Resolve 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_PATH
is 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_OUTPUT
and 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_OUTPUT
and 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_OUTPUT
is supported.
-