updating documentation and fixing minor bugs
This commit is contained in:
17
README.md
17
README.md
@@ -17,7 +17,7 @@ Have a nice coding :)
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ie.corballis</groupId>
|
<groupId>ie.corballis</groupId>
|
||||||
<artifactId>sox-java</artifactId>
|
<artifactId>sox-java</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -40,10 +40,13 @@ Sox sox = new Sox("/usr/bin/sox");
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Pass unimplemented arguments to the sox
|
### Don't find your favorite sox argument implemented yet?
|
||||||
|
|
||||||
|
If an argument, you are looking for is not implemented yet, feel free to open an issue, but don't worry.
|
||||||
|
You do not need to wait for a new version. you can always use the following "universal" method for such a cases:
|
||||||
|
`SoX argument(String ...args)`
|
||||||
|
The above mentioned method accepts any kind of custom arguments and passes it straight to the sox.
|
||||||
|
|
||||||
If an argument, you are looking for is not implemented yet, feel free to open an issue, or simply use the
|
|
||||||
`SoX argument(String ...args)` method to pass custom arguments to the sox.
|
|
||||||
```
|
```
|
||||||
Sox sox = new Sox("/usr/bin/sox");
|
Sox sox = new Sox("/usr/bin/sox");
|
||||||
sox.argument("--myargumentKey", "myArgumentValue")
|
sox.argument("--myargumentKey", "myArgumentValue")
|
||||||
@@ -73,3 +76,9 @@ public class SoXConfiguration {
|
|||||||
With the above described Spring configuration class you can inject the sox wrapper anywhere in you Spring project like this:
|
With the above described Spring configuration class you can inject the sox wrapper anywhere in you Spring project like this:
|
||||||
|
|
||||||
```@Autowired private SoX sox;``` and the framework will initialize a new wrapper for you.
|
```@Autowired private SoX sox;``` and the framework will initialize a new wrapper for you.
|
||||||
|
|
||||||
|
## Does the order of the arguments matter?
|
||||||
|
Yes, it does. However, this java wrapper allows you any kind of order of the sox parameters, it does not check sox'
|
||||||
|
syntax, the wrapper will pass the arguments to sox in the same order as you provided them in the java code.
|
||||||
|
The wrapper checks only one syntax: You have to provide your output parameter later than your input parameter.
|
||||||
|
If you break this rule, then you will get a `WrongParameterException` checked exception.
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package ie.corballis.sox;
|
package ie.corballis.sox;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -81,9 +81,7 @@ public class Sox {
|
|||||||
|
|
||||||
public Sox effect(SoXEffect effect, String ... effectArguments) {
|
public Sox effect(SoXEffect effect, String ... effectArguments) {
|
||||||
arguments.add(effect.toString());
|
arguments.add(effect.toString());
|
||||||
for (String effectArgument : effectArguments) {
|
Collections.addAll(arguments, effectArguments);
|
||||||
arguments.add(effectArgument);
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,11 +92,12 @@ public class Sox {
|
|||||||
|
|
||||||
public Sox inputFile(String inputFile) {
|
public Sox inputFile(String inputFile) {
|
||||||
arguments.add(inputFile);
|
arguments.add(inputFile);
|
||||||
|
inputFileSet = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sox outputFile(String outputFile) throws WrongParametersException {
|
public Sox outputFile(String outputFile) throws WrongParametersException {
|
||||||
if (inputFileSet) {
|
if (!inputFileSet) {
|
||||||
throw new WrongParametersException("The output file has to be later then an input file");
|
throw new WrongParametersException("The output file has to be later then an input file");
|
||||||
}
|
}
|
||||||
arguments.add(outputFile);
|
arguments.add(outputFile);
|
||||||
@@ -106,10 +105,7 @@ public class Sox {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute() throws IOException, WrongParametersException, AlreadyExecutedException {
|
public void execute() throws IOException, WrongParametersException {
|
||||||
if (hasBeenExecuted) {
|
|
||||||
throw new AlreadyExecutedException("The execute() method cannot be called twice");
|
|
||||||
}
|
|
||||||
File soxBinary = new File(soXBinaryPath);
|
File soxBinary = new File(soXBinaryPath);
|
||||||
if (!soxBinary.exists()) {
|
if (!soxBinary.exists()) {
|
||||||
throw new FileNotFoundException("Sox binary is not available under the following path: " + soXBinaryPath);
|
throw new FileNotFoundException("Sox binary is not available under the following path: " + soXBinaryPath);
|
||||||
@@ -135,6 +131,7 @@ public class Sox {
|
|||||||
errorDuringExecution = e;
|
errorDuringExecution = e;
|
||||||
logger.error("Error while running Sox. {}", e.getMessage());
|
logger.error("Error while running Sox. {}", e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
|
arguments.clear();
|
||||||
if (process != null) {
|
if (process != null) {
|
||||||
process.destroy();
|
process.destroy();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,4 +31,10 @@ public class ArgumentTester {
|
|||||||
"1");
|
"1");
|
||||||
assertEquals(expectedArguments, arguments);
|
assertEquals(expectedArguments, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected = WrongParametersException.class)
|
||||||
|
public void testOutputParamHasToFollowInputParam() throws WrongParametersException {
|
||||||
|
Sox sox = new Sox("/usr/local/bin/sox");
|
||||||
|
sox.outputFile("").inputFile("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user