Author: sebb Date: Mon Feb 23 16:03:17 2009 New Revision: 747056 URL: http://svn.apache.org/viewvc?rev=747056&view=rev Log: Make private variables final where possible
Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ExecuteException.java commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/LogOutputStream.java commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/PumpStreamHandler.java commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/StreamPumper.java commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Watchdog.java Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java?rev=747056&r1=747055&r2=747056&view=diff ============================================================================== --- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java (original) +++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java Mon Feb 23 16:03:17 2009 @@ -34,12 +34,12 @@ /** * The arguments of the command. */ - private Vector arguments = new Vector(); + private final Vector arguments = new Vector(); /** * The program to execute. */ - private String executable; + private final String executable; /** * A map of name value pairs used to expand command line arguments @@ -96,7 +96,7 @@ */ public CommandLine(String executable) { this.isFile=false; - setExecutable(executable); + this.executable=getExecutable(executable); } /** @@ -106,7 +106,7 @@ */ public CommandLine(File executable) { this.isFile=true; - setExecutable(executable.getAbsolutePath()); + this.executable=getExecutable(executable.getAbsolutePath()); } /** @@ -391,18 +391,18 @@ } /** - * Set the executable - the argument is trimmed and '/' and '\\' are + * Get the executable - the argument is trimmed and '/' and '\\' are * replaced with the platform specific file seperator char * * @param executable the executable */ - private void setExecutable(final String executable) { + private String getExecutable(final String executable) { if (executable == null) { throw new IllegalArgumentException("Executable can not be null"); } else if(executable.trim().length() == 0) { throw new IllegalArgumentException("Executable can not be empty"); } else { - this.executable = StringUtils.fixFileSeparatorChar(executable); + return StringUtils.fixFileSeparatorChar(executable); } } } Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java?rev=747056&r1=747055&r2=747056&view=diff ============================================================================== --- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java (original) +++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java Mon Feb 23 16:03:17 2009 @@ -58,7 +58,7 @@ private int[] exitValues; /** launches the command in a new process */ - private CommandLauncher launcher; + private final CommandLauncher launcher; /** optional cleanup of started processes */ private ProcessDestroyer processDestroyer; Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ExecuteException.java URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ExecuteException.java?rev=747056&r1=747055&r2=747056&view=diff ============================================================================== --- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ExecuteException.java (original) +++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ExecuteException.java Mon Feb 23 16:03:17 2009 @@ -33,12 +33,12 @@ /** * The underlying cause of this exception. */ - private Throwable cause; + private final Throwable cause; /** * The exit value returned by the failed process */ - private int exitValue; + private final int exitValue; /** * Construct a new exception with the specified detail message. @@ -49,6 +49,7 @@ */ public ExecuteException(final String message, int exitValue) { super(message + "(Exit value: " + exitValue + ")"); + this.cause = null; this.exitValue = exitValue; } Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/LogOutputStream.java URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/LogOutputStream.java?rev=747056&r1=747055&r2=747056&view=diff ============================================================================== --- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/LogOutputStream.java (original) +++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/LogOutputStream.java Mon Feb 23 16:03:17 2009 @@ -41,12 +41,20 @@ private static final int LF = 0x0a; /** the internal buffer */ - private ByteArrayOutputStream buffer = new ByteArrayOutputStream( + private final ByteArrayOutputStream buffer = new ByteArrayOutputStream( INTIAL_SIZE); private boolean skip = false; - private int level = 999; + private final int level; + + /** + * Creates a new instance of this class. + * Uses the default level of 999. + */ + public LogOutputStream() { + this(999); + } /** * Creates a new instance of this class. Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/PumpStreamHandler.java URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/PumpStreamHandler.java?rev=747056&r1=747055&r2=747056&view=diff ============================================================================== --- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/PumpStreamHandler.java (original) +++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/PumpStreamHandler.java Mon Feb 23 16:03:17 2009 @@ -37,11 +37,11 @@ private Thread inputThread; - private OutputStream out; + private final OutputStream out; - private OutputStream err; + private final OutputStream err; - private InputStream input; + private final InputStream input; /** * Construct a new <CODE>PumpStreamHandler</CODE>. Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/StreamPumper.java URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/StreamPumper.java?rev=747056&r1=747055&r2=747056&view=diff ============================================================================== --- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/StreamPumper.java (original) +++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/StreamPumper.java Mon Feb 23 16:03:17 2009 @@ -33,19 +33,19 @@ private static final int DEFAULT_SIZE = 1024; /** the input stream to pump from */ - private InputStream is; + private final InputStream is; /** the output stream to pmp into */ - private OutputStream os; + private final OutputStream os; /** the size of the internal buffer for copying the streams */ - private int size; + private final int size; /** was the end of the stream reached */ private boolean finished; /** close the output stream when exhausted */ - private boolean closeWhenExhausted; + private final boolean closeWhenExhausted; /** * Create a new stream pumper. Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Watchdog.java URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Watchdog.java?rev=747056&r1=747055&r2=747056&view=diff ============================================================================== --- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Watchdog.java (original) +++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Watchdog.java Mon Feb 23 16:03:17 2009 @@ -30,13 +30,13 @@ private Vector observers = new Vector(1); - private long timeout = -1; + private final long timeout; private boolean stopped = false; public Watchdog(final long timeout) { if (timeout < 1) { - throw new IllegalArgumentException("timeout lesser than 1."); + throw new IllegalArgumentException("timeout must not be less than 1."); } this.timeout = timeout; }