瀏覽代碼

- reduced visibility

Sebastian Stenzel 10 年之前
父節點
當前提交
6b45d62aa1

+ 16 - 4
main/ui/src/main/java/org/cryptomator/ui/util/command/CommandResult.java

@@ -20,16 +20,22 @@ import org.cryptomator.ui.util.mount.CommandFailedException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class CommandResult {
+public final class CommandResult {
 
 	private static final Logger LOG = LoggerFactory.getLogger(CommandResult.class);
 
 	private final Process process;
 
-	public CommandResult(Process process) {
+	/**
+	 * @param process An <strong>already finished</strong> process.
+	 */
+	CommandResult(Process process) {
 		this.process = process;		
 	}
-
+	
+	/**
+	 * @return Data written to STDOUT
+	 */
 	public String getOutput() throws CommandFailedException {
 		try (InputStream in = process.getInputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream()) {
 			copy(in, out);
@@ -39,6 +45,9 @@ public class CommandResult {
 		}
 	}
 
+	/**
+	 * @return Data written to STDERR
+	 */
 	public String getError() throws CommandFailedException {
 		try (InputStream in = process.getErrorStream(); ByteArrayOutputStream out = new ByteArrayOutputStream()) {
 			copy(in, out);
@@ -48,11 +57,14 @@ public class CommandResult {
 		}
 	}
 
+	/**
+	 * @return Exit value of the process
+	 */
 	public int getExitValue() throws CommandFailedException {
 		return process.exitValue();
 	}
 
-	public void logDebugInfo() {
+	void logDebugInfo() {
 		if (LOG.isDebugEnabled()) {
 			try {
 				LOG.debug("Command execution finished. Exit code: {}\n" + "Output:\n" + "{}\n" + "Error:\n" + "{}\n", process.exitValue(), getOutput(), getError());

+ 1 - 0
main/ui/src/main/java/org/cryptomator/ui/util/command/CommandRunner.java

@@ -5,6 +5,7 @@
  * 
  * Contributors:
  *     Markus Kreusch
+ *     Sebastian Stenzel - Refactoring
  ******************************************************************************/
 package org.cryptomator.ui.util.command;
 

+ 2 - 2
main/ui/src/main/java/org/cryptomator/ui/util/command/FutureCommandResult.java

@@ -19,7 +19,7 @@ import java.util.concurrent.locks.ReentrantLock;
 
 import org.cryptomator.ui.util.mount.CommandFailedException;
 
-class FutureCommandResult implements Future<CommandResult>, Runnable {
+final class FutureCommandResult implements Future<CommandResult>, Runnable {
 	
 	private final Process process;
 	private final AtomicBoolean canceled = new AtomicBoolean();
@@ -29,7 +29,7 @@ class FutureCommandResult implements Future<CommandResult>, Runnable {
 	
 	private CommandFailedException exception;
 	
-	public FutureCommandResult(Process process) {
+	FutureCommandResult(Process process) {
 		this.process = process;
 	}