Skip to content

Commit

Permalink
javadoc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
delchev committed Nov 13, 2017
1 parent dd215c2 commit 18f6bf8
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class FilesFacade {
* Check if file with the provided path exists
* @param path the path to the file
* @return true if a file exists
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final boolean exists(String path) throws IOException {
// return Files.exists(Paths.get(path));
Expand All @@ -54,7 +54,7 @@ public static final boolean exists(String path) throws IOException {
* Check if file with the provided path is executable
* @param path the path to the file
* @return true if the file is executable
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final boolean isExecutable(String path) throws IOException {
return Files.isExecutable(Paths.get(path));
Expand All @@ -64,7 +64,7 @@ public static final boolean isExecutable(String path) throws IOException {
* Check if file with the provided path is readable
* @param path the path to the file
* @return true if the file is readable
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final boolean isReadable(String path) throws IOException {
return Files.isReadable(Paths.get(path));
Expand All @@ -74,7 +74,7 @@ public static final boolean isReadable(String path) throws IOException {
* Check if file with the provided path is writable
* @param path the path to the file
* @return true if the file is writable
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final boolean isWritable(String path) throws IOException {
return Files.isReadable(Paths.get(path));
Expand All @@ -84,7 +84,7 @@ public static final boolean isWritable(String path) throws IOException {
* Check if file with the provided path is hidden
* @param path the path to the file
* @return true if the file is hidden
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final boolean isHidden(String path) throws IOException {
return Files.isHidden(Paths.get(path));
Expand All @@ -94,7 +94,7 @@ public static final boolean isHidden(String path) throws IOException {
* Check if file with the provided path is a directory
* @param path the path to the file
* @return true if the file is directory
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final boolean isDirectory(String path) throws IOException {
return Files.isDirectory(Paths.get(path));
Expand All @@ -104,7 +104,7 @@ public static final boolean isDirectory(String path) throws IOException {
* Check if file with the provided path is a regular file
* @param path the path to the file
* @return true if the file is a regular file
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final boolean isFile(String path) throws IOException {
return Files.isRegularFile(Paths.get(path));
Expand All @@ -115,7 +115,7 @@ public static final boolean isFile(String path) throws IOException {
* @param path1 path to the first file
* @param path2 path to the second file
* @return true if both paths point to the same file
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final boolean isSameFile(String path1, String path2) throws IOException {
return Files.isSameFile(Paths.get(path1), Paths.get(path2));
Expand All @@ -125,7 +125,7 @@ public static final boolean isSameFile(String path1, String path2) throws IOExce
* Get canonical representation of the provided path
* @param path the path
* @return the canonical representation of the path
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final String getCanonicalPath(String path) throws IOException {
return new File(path).getCanonicalPath();
Expand All @@ -135,17 +135,17 @@ public static final String getCanonicalPath(String path) throws IOException {
* Get the name of the file or directory represented by the provided path
* @param path the path
* @return the name of the file or the directory
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final String getName(String path) throws IOException {
return new File(path).getName();
}

/**
* Get the path of the parentdirectory
* Get the path of the parent directory
* @param path the path
* @return the path of the parent
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final String getParentPath(String path) throws IOException {
return new File(path).getParentFile().getPath(); //FIXME may throw NPE
Expand All @@ -155,7 +155,7 @@ public static final String getParentPath(String path) throws IOException {
* Read the content of the file into a byte array
* @param path the path of the file
* @return the file content as byte array
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final byte[] readBytes(String path) throws IOException {
return Files.readAllBytes(Paths.get(path));
Expand All @@ -165,7 +165,7 @@ public static final byte[] readBytes(String path) throws IOException {
* Read the text file represented by the provided path using UTF-8 charset
* @param path path to the file
* @return the text file content
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final String readText(String path) throws IOException {
return new String(Files.readAllBytes(Paths.get(path)), StandardCharsets.UTF_8);
Expand All @@ -176,7 +176,7 @@ public static final String readText(String path) throws IOException {
* If the file exists the old content is discarded.
* @param path path to the file to write to
* @param input the data to write
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final void writeBytes(String path, String input) throws IOException {
byte[] bytes = BytesHelper.jsonToBytes(input);
Expand All @@ -188,7 +188,7 @@ public static final void writeBytes(String path, String input) throws IOExceptio
* If the file exists the old content is discarded.
* @param path path to the file to write to
* @param text the data to write
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/ public static final void writeText(String path, String text) throws IOException {
Files.write(Paths.get(path), text.getBytes(StandardCharsets.UTF_8));
}
Expand All @@ -197,7 +197,7 @@ public static final void writeBytes(String path, String input) throws IOExceptio
* Get the timestamp of last modification
* @param path path to the file
* @return the timestamp of last modification
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final long getLastModified(String path) throws IOException {
return Files.getLastModifiedTime(Paths.get(path)).toMillis();
Expand All @@ -207,7 +207,7 @@ public static final long getLastModified(String path) throws IOException {
* Set the last modification timestamp
* @param path path to a file
* @param time the last modification timestamp to set
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final void setLastModified(String path, long time) throws IOException {
Files.setLastModifiedTime(Paths.get(path), FileTime.fromMillis(time));
Expand All @@ -217,7 +217,7 @@ public static final void setLastModified(String path, long time) throws IOExcept
* Set the last modification timestamp
* @param path path to a file
* @param time the last modification timestamp to set
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final void setLastModified(String path, Double time) throws IOException {
setLastModified(path, time.longValue());
Expand All @@ -227,7 +227,7 @@ public static final void setLastModified(String path, Double time) throws IOExce
* Get the name of teh principal representing the file owner
* @param path path to a file
* @return the name of the principal representing the file owner
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final String getOwner(String path) throws IOException {
return Files.getOwner(Paths.get(path)).getName();
Expand All @@ -236,8 +236,7 @@ public static final String getOwner(String path) throws IOException {
/**
* Set the file owner
* @param path path to file
* @return the name of the principal representing the file owner
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final void setOwner(String path, String owner) throws IOException {
UserPrincipal userPrincipal = Paths.get(path).getFileSystem().getUserPrincipalLookupService().lookupPrincipalByName(owner);
Expand All @@ -248,7 +247,7 @@ public static final void setOwner(String path, String owner) throws IOException
* Get the string representation of the file permissions
* @param path path to the file
* @return the string representation of the file permissions
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final String getPermissions(String path) throws IOException {
return PosixFilePermissions.toString(Files.getPosixFilePermissions(Paths.get(path)));
Expand All @@ -257,8 +256,7 @@ public static final String getPermissions(String path) throws IOException {
/**
* Set the file permissions
* @param path path to the file
* @return the string representation of the file permissions
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final void setPermissions(String path, String permissions) throws IOException {
Set<PosixFilePermission> perms = PosixFilePermissions.fromString(permissions);
Expand All @@ -269,7 +267,7 @@ public static final void setPermissions(String path, String permissions) throws
* Get the file size
* @param path path to the file
* @return the file size
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final long size(String path) throws IOException {
return Files.size(Paths.get(path));
Expand All @@ -278,16 +276,16 @@ public static final long size(String path) throws IOException {
/**
* Create a new file if it does not exist
* @param path path to the file
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final void createFile(String path) throws IOException {
Files.createFile(Paths.get(path));
}

/**
* Create all directories on the given path if they do not exist
* @param path
* @throws IOException
* @param path the path parameter
* @throws IOException in case of failure in underlying layer
*/
public static final void createDirectory(String path) throws IOException {
Files.createDirectories(Paths.get(path));
Expand All @@ -297,7 +295,7 @@ public static final void createDirectory(String path) throws IOException {
* Copy the directory structure
* @param source source location
* @param target target location
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final void copy(String source, String target) throws IOException {
Path sourcePath = Paths.get(source);
Expand All @@ -319,9 +317,9 @@ public FileVisitResult visitFile(final Path file, final BasicFileAttributes attr

/**
* Move the file to the specified location
* @param source
* @param target
* @throws IOException
* @param source source location
* @param target target location
* @throws IOException in case of failure in underlying layer
*/
public static final void move(String source, String target) throws IOException {
Files.move(Paths.get(source), Paths.get(target));
Expand All @@ -330,7 +328,7 @@ public static final void move(String source, String target) throws IOException {
/**
* Delete the file if it exists
* @param path path to file
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final void deleteFile(String path) throws IOException {
Files.deleteIfExists(Paths.get(path));
Expand All @@ -339,7 +337,7 @@ public static final void deleteFile(String path) throws IOException {
/**
* Delete empty directory
* @param path path to the directory
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final void deleteDirectory(String path) throws IOException {
Files.deleteIfExists(Paths.get(path));
Expand All @@ -349,7 +347,7 @@ public static final void deleteDirectory(String path) throws IOException {
* Delete directory. Set foce to true in order to delete non empty directory
* @param path path to the directory
* @param forced should non-empty directories be deleted
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final void deleteDirectory(String path, boolean forced) throws IOException {
if (forced) {
Expand Down Expand Up @@ -402,20 +400,20 @@ public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOExce

/**
* Create temporary file
* @param prefix
* @param suffix
* @param prefix the prefix parameter
* @param suffix the suffix parameter
* @return path to the temp file
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final String createTempFile(String prefix, String suffix) throws IOException {
return Files.createTempFile(prefix, suffix).toString();
}

/**
* Create temporary directory
* @param prefix
* @param prefix the prefix parameter
* @return path to the created directory
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final String createTempDirectory(String prefix) throws IOException {
return Files.createTempDirectory(prefix).toString();
Expand All @@ -426,7 +424,7 @@ public static final String createTempDirectory(String prefix) throws IOException
* Open input stream from the file represented by the given path
* @param path path to file
* @return the created input stream
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final InputStream createInputStream(String path) throws IOException {
return Files.newInputStream(Paths.get(path));
Expand All @@ -436,7 +434,7 @@ public static final InputStream createInputStream(String path) throws IOExceptio
* Open output stream to the file represented by the given path
* @param path path to file
* @return the created output stream
* @throws IOException
* @throws IOException in case of failure in underlying layer
*/
public static final OutputStream createOutputStream(String path) throws IOException {
return Files.newOutputStream(Paths.get(path));
Expand Down
Loading

0 comments on commit 18f6bf8

Please sign in to comment.