Permalink
Browse files

Moved Cut command to use new command structure.

  • Loading branch information...
benjwarner committed Sep 18, 2012
1 parent 8202166 commit 8121da7cfe8b1f3d3251281fd357a4b2227846df
@@ -0,0 +1,7 @@
<component name="ProjectDictionaryState">
<dictionary name="ben">
<words>
<w>parsable</w>
</words>
</dictionary>
</component>
@@ -12,7 +12,7 @@
* exception if {@code array} is not an array or null.
* <p>
* The method returns {@code "null"} if the given {@code array} is null.
*
*
* @param array
* the array to return as a string
* @return a (deep) string representation of the array
@@ -39,4 +39,14 @@ public static String toString(Object array) {
private ArrayUtil() {
super();
}
//TODO BJW Write unit tests
public static String join(final String[] array, final String delim){
final StringBuilder sb = new StringBuilder();
for(final String element: array){
if(sb.length() > 0) sb.append(delim);
sb.append(element);
}
return sb.toString();
}
}
@@ -6,6 +6,7 @@
import org.unix4j.redirect.From;
import org.unix4j.unix.*;
import org.unix4j.unix.cat.CatOptions;
import org.unix4j.unix.cut.CutOptions;
import org.unix4j.unix.echo.EchoOptions;
import org.unix4j.unix.grep.GrepOptions;
import org.unix4j.unix.head.HeadOptions;
@@ -14,6 +15,7 @@
import org.unix4j.unix.tail.TailOptions;
import org.unix4j.unix.uniq.UniqOptions;
import org.unix4j.unix.wc.WcOptions;
import org.unix4j.util.Range;
import java.io.File;
import java.io.InputStream;
@@ -100,37 +102,37 @@ public Unix4jCommandBuilder from(Input input) {
join(From.FACTORY.from(input));
return this;
}
@Override
public Unix4jCommandBuilder cat() {
join(Cat.FACTORY.cat());
return this;
}
@Override
public Unix4jCommandBuilder cat(File... files) {
join(Cat.FACTORY.cat(files));
return this;
}
@Override
public Unix4jCommandBuilder cat(String... paths) {
join(Cat.FACTORY.cat(paths));
return this;
}
@Override
public Unix4jCommandBuilder cat(CatOptions options) {
join(Cat.FACTORY.cat(options));
return this;
}
@Override
public Unix4jCommandBuilder cat(CatOptions options, File... files) {
join(Cat.FACTORY.cat(options, files));
return this;
}
@Override
public Unix4jCommandBuilder cat(CatOptions options, String... paths) {
join(Cat.FACTORY.cat(options, paths));
@@ -305,36 +307,6 @@ public Unix4jCommandBuilder sort(SortOptions options, Comparator<? super Line> c
return this;
}
@Override
public Unix4jCommandBuilder cut(int fieldIndex) {
join(Cut.FACTORY.cut(fieldIndex));
return this;
}
@Override
public Unix4jCommandBuilder cut(String delimiter, int... fieldIndices) {
join(Cut.FACTORY.cut(delimiter, fieldIndices));
return this;
}
@Override
public Unix4jCommandBuilder cut(String inputDelimiter, String outputDelimiter, int... fieldIndices) {
join(Cut.FACTORY.cut(inputDelimiter, outputDelimiter, fieldIndices));
return this;
}
@Override
public Unix4jCommandBuilder cut(int start, int length) {
join(Cut.FACTORY.cut(start, length));
return this;
}
@Override
public Unix4jCommandBuilder cut(int[] charIndices) {
join(Cut.FACTORY.cut(charIndices));
return this;
}
@Override
public Unix4jCommandBuilder sed(String script) {
join(Sed.FACTORY.sed(script));
@@ -389,30 +361,6 @@ public Unix4jCommandBuilder wc(WcOptions options, String... paths) {
return this;
}
// @Override
// public Unix4jCommandBuilder wcCountLinesWordsAndChars() {
// join(Wc.FACTORY.wcCountLinesWordsAndChars());
// return this;
// }
//
// @Override
// public Unix4jCommandBuilder wcCountLines() {
// join(Wc.FACTORY.wcCountLines());
// return this;
// }
//
// @Override
// public Unix4jCommandBuilder wcCountChars() {
// join(Wc.FACTORY.wcCountChars());
// return this;
// }
//
// @Override
// public Unix4jCommandBuilder wcCountWords() {
// join(Wc.FACTORY.wcCountWords());
// return this;
// }
@Override
public Unix4jCommandBuilder head() {
join(Head.FACTORY.head());
@@ -552,4 +500,40 @@ public Unix4jCommandBuilder uniq(UniqOptions options, String path) {
join(Uniq.FACTORY.uniq(options, path));
return this;
}
@Override
public Unix4jCommandBuilder cut(CutOptions options, Range range) {
join(Cut.FACTORY.cut(options, range));
return this;
}
@Override
public Unix4jCommandBuilder cut(CutOptions options, int... indexes) {
join(Cut.FACTORY.cut(options, indexes));
return this;
}
@Override
public Unix4jCommandBuilder cut(CutOptions options, String delimiter, Range range) {
join(Cut.FACTORY.cut(options, delimiter, range));
return this;
}
@Override
public Unix4jCommandBuilder cut(CutOptions options, String delimiter, int... indexes) {
join(Cut.FACTORY.cut(options, delimiter, indexes));
return this;
}
@Override
public Unix4jCommandBuilder cut(CutOptions options, String delimiter, char outputDelimiter, Range range) {
join(Cut.FACTORY.cut(options, delimiter, outputDelimiter, range));
return this;
}
@Override
public Unix4jCommandBuilder cut(CutOptions options, String delimiter, char outputDelimiter, int... indexes) {
join(Cut.FACTORY.cut(options, delimiter, outputDelimiter, indexes));
return this;
}
}
Oops, something went wrong.

0 comments on commit 8121da7

Please sign in to comment.