package innovimax.mixthem.operation;

import innovimax.mixthem.MixException;
import innovimax.mixthem.arguments.RuleParam;
import innovimax.mixthem.arguments.ParamValue;
import innovimax.mixthem.io.InputResource;

import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.Map;
import java.util.List;
import java.util.stream.IntStream;

/**
* <p>Abstract class for all character operation.</p>
* @see ICopyOperation
* @author Innovimax
* @version 1.0
*/
public abstract class AbstractCopyOperation extends AbstractOperation implements ICopyOperation {
	
	protected final static int BUFFER_SIZE = 1024;	

	/**
	* Constructor
 	* @param params The list of parameters (maybe empty)
	* @see innovimax.mixthem.arguments.RuleParam
	* @see innovimax.mixthem.arguments.ParamValue
	*/
	public AbstractCopyOperation(final Map<RuleParam, ParamValue> params) {
		super(params);
	}

	@Override
	public void processFiles(final List<InputResource> inputs, final OutputStream output) throws MixException, IOException {		
		final IntStream indexes; 
		if (params.containsKey(RuleParam.FILE_LIST)) {
			indexes = Arrays.stream(params.get(RuleParam.FILE_LIST).asIntArray());
		} else {
			indexes = IntStream.range(1, inputs.size()+1);
		}				
                indexes.mapToObj(i -> inputs.get(i-1)).forEach(input -> {
			try {
				process(input, output);
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		});
	}

}

@@ -657,16 +657,75 @@
 tructor%0A
+%09* @param selection The file index selection (maybe empty)%0A
  %09* @par
@@ -904,16 +904,46 @@
 n(final 
+Set%3CInteger%3E selection, final 
 Map%3CRule
@@ -979,16 +979,27 @@
 %09%09super(
+selection, 
 params);
@@ -1169,131 +1169,97 @@
 es; 
+%09%09
 %0A%09%09if (
-params.containsKey(RuleParam.FILE_LIST)) %7B%0A%09%09%09indexes = Arrays.stream(params.get(RuleParam.FILE_LIST).asIntArray());
+this.selection.isEmpty()) %7B%0A%09%09%09indexes = IntStream.range(1, inputs.size()+1);%09%09%09
 %0A%09%09%7D
@@ -1265,16 +1265,19 @@
 %7D else %7B
+%09%09%09
 %0A%09%09%09inde
@@ -1286,42 +1286,82 @@
 s = 
-IntStream.range(1, inputs.size()+1
+Arrays.stream(this.selection.stream().mapToInt(Number::intValue).toArray()
 );%0A%09

Update AbstractCopyOperation.java