![JAR search and dependency download from the Maven repository](/logo.png)
eu.unicore.uas.json.ArgumentSweep Maven / Gradle / Ivy
The newest version!
package eu.unicore.uas.json;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/**
* Helper for dealing with JSDL argument sweep
*
* @author schuller
*/
public class ArgumentSweep {
protected final int argNo;
Listvalues = new ArrayList<>();
public ArgumentSweep(int argNo){
this.argNo=argNo;
}
public ArgumentSweep(int argNo, JSONObject json){
this.argNo=argNo;
sweep(json);
}
public void setValues(String[]values){
this.values.addAll(Arrays.asList(values));
}
public void sweep(JSONObject json){
JSONArray valueArray = json.optJSONArray("Values");
if(valueArray!=null){
for(int i=0; i0){
while(from.compareTo(to)<=0){
values.add(String.valueOf(from));
from=from.add(step);
}
}
else if(step.signum()<0){
while(from.compareTo(to)>=0){
values.add(String.valueOf(from));
from=from.add(step);
}
}
else throw new IllegalArgumentException("Step must be non-zero");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy