From cc894a5f9c71b0d9a8ca15e85332252300c3ec75 Mon Sep 17 00:00:00 2001
From: Georg Seibt <seibt@fim.uni-passau.de>
Date: Wed, 13 Apr 2016 15:08:03 +0200
Subject: [PATCH] doc

---
 .../gitwrapper/process/ProcessExecutor.java   | 37 ++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/de/uni_passau/fim/seibt/gitwrapper/process/ProcessExecutor.java b/src/de/uni_passau/fim/seibt/gitwrapper/process/ProcessExecutor.java
index 90c6330..723ec96 100644
--- a/src/de/uni_passau/fim/seibt/gitwrapper/process/ProcessExecutor.java
+++ b/src/de/uni_passau/fim/seibt/gitwrapper/process/ProcessExecutor.java
@@ -8,18 +8,34 @@ import java.util.logging.Logger;
 
 import org.apache.commons.io.IOUtils;
 
+/**
+ * Contains static methods for executing commands and gathering their output and exit code.
+ */
 public class ProcessExecutor {
 
     private static final Logger LOG = Logger.getLogger(ProcessExecutor.class.getCanonicalName());
 
     /**
-     * The result of a command line execution.
+     * The result of a process execution.
      */
     public static class ExecRes {
         public int exitCode;
         public String output;
     }
 
+    /**
+     * Executes the given <code>cmd</code> with the supplied <code>parameters</code>.
+     *
+     * @param cmd
+     *         the command to execute
+     * @param workingDir
+     *         the working directory for the execution
+     * @param redirectError
+     *         whether to merge the standard output and error streams
+     * @param parameters
+     *         the parameters for the command (may be null or none)
+     * @return the result of the execution or an empty {@link Optional} if there is an exception executing the command
+     */
     public static Optional<ExecRes> exec(String cmd, File workingDir, boolean redirectError, String... parameters) {
 
         if (parameters == null) {
@@ -34,6 +50,18 @@ public class ProcessExecutor {
         return exec(workingDir, redirectError, cmdArray);
     }
 
+    /**
+     * Executes the given <code>command</code>. If <code>command</code> is <code>null</code> no var-args are given
+     * and empty {@link Optional} will be returned.
+     *
+     * @param workingDir
+     *         the working directory for the execution
+     * @param redirectError
+     *         whether to merge the standard output and error streams
+     * @param command
+     *         the command to be executed
+     * @return the result of the execution or an empty {@link Optional} if there is an exception executing the command
+     */
     public static Optional<ExecRes> exec(File workingDir, boolean redirectError, String... command) {
 
         if (command == null) {
@@ -49,6 +77,13 @@ public class ProcessExecutor {
         return exec(builder);
     }
 
+    /**
+     * Executes the command represented by the given <code>builder</code>.
+     *
+     * @param builder
+     *         the {@link ProcessBuilder} to be executed
+     * @return the result of the execution or an empty {@link Optional} if there is an exception executing the command
+     */
     public static Optional<ExecRes> exec(ProcessBuilder builder) {
         String cmd = String.join(" ", builder.command());
         LOG.fine(() -> String.format("Executing '%s'.", cmd));
-- 
GitLab