Package com.yahoo.config.application.api
Class ApplicationFile
java.lang.Object
com.yahoo.config.application.api.ApplicationFile
- All Implemented Interfaces:
Comparable<ApplicationFile>
An application file represents a file within an application package. This class can be used to traverse the entire
application package file structure, as well as read and write files to it, and create directories.
- Author:
- Ulf Lilleengen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interface -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract ApplicationFileappendFile(String value) Appends the given string to this text file.abstract ApplicationFileCreates a directory at the path represented by this file.abstract InputStreamCreates anInputStreamfor the contents of this file.abstract ReaderCreates aReaderfor the contents of this file.abstract ApplicationFiledelete()Deletes the file pointed to by this.booleanabstract booleanexists()Tests whether this file exists.abstract ApplicationFile.MetaDataprotected com.yahoo.path.Pathcom.yahoo.path.PathgetPath()Gets the path that this file represents.abstract longgetSize()abstract booleanChecks whether this file is a directory.Lists the files under this directory.listFiles(boolean recurse) Lists the files in this directory, optionally lists files for subdirectories recursively as well.abstract List<ApplicationFile>listFiles(ApplicationFile.PathFilter filter) Lists the files under this directory.toString()abstract ApplicationFilewriteFile(InputStream input) Writes the contents of the supplied input stream to this file.abstract ApplicationFileWrites the contents from supplied reader to this file.Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareTo
-
Field Details
-
ContentStatusNew
- See Also:
-
ContentStatusChanged
- See Also:
-
ContentStatusDeleted
- See Also:
-
path
protected final com.yahoo.path.Path path
-
-
Constructor Details
-
ApplicationFile
protected ApplicationFile(com.yahoo.path.Path path)
-
-
Method Details
-
isDirectory
public abstract boolean isDirectory()Checks whether this file is a directory.- Returns:
- true if it is, false if not.
-
exists
public abstract boolean exists()Tests whether this file exists.- Returns:
- true if it exists, false if not.
-
createReader
Creates aReaderfor the contents of this file.- Returns:
- A
Readerthat should be closed after use. - Throws:
FileNotFoundException- if the file is not found.
-
createInputStream
Creates anInputStreamfor the contents of this file.- Returns:
- An
InputStreamthat should be closed after use. - Throws:
FileNotFoundException- if the file is not found.
-
createDirectory
Creates a directory at the path represented by this file. Parent directories will be automatically created.- Returns:
- this
- Throws:
IllegalArgumentException- if the directory already exists.
-
writeFile
Writes the contents from supplied reader to this file. Any existing content will be overwritten!- Parameters:
input- A reader pointing to the content that should be written.- Returns:
- this
-
writeFile
Writes the contents of the supplied input stream to this file. Any existing content will be overwritten!- Parameters:
input- An input stream with the content that should be written.- Returns:
- this
-
appendFile
Appends the given string to this text file.- Returns:
- this
-
listFiles
Lists the files under this directory. If this is file, an empty list is returned. Only immediate files/subdirectories are returned.- Returns:
- a list of files in this directory.
-
listFiles
Lists the files under this directory. If this is a file, an empty list is returned. Only immediate files/subdirectories are returned.- Parameters:
filter- A filter functor for filtering path names- Returns:
- a list of files in this directory.
-
listFiles
Lists the files in this directory, optionally lists files for subdirectories recursively as well.- Parameters:
recurse- Set to true if all files in the directory tree should be returned.- Returns:
- a list of files in this directory.
-
delete
Deletes the file pointed to by this. If this is a non-empty directory, the operation will throw.- Returns:
- this.
- Throws:
RuntimeException- if the file is a directory and not empty.
-
getPath
public com.yahoo.path.Path getPath()Gets the path that this file represents.- Returns:
- a Path
-
toString
-
equals
-
getMetaPath
protected com.yahoo.path.Path getMetaPath() -
getMetaData
-
getSize
public abstract long getSize()
-