package innovimax.mixthem.arguments;

/**
* <p>This is a detailed enumeration of additional rule parameters.</p>
* @author Innovimax
* @version 1.0
*/
public enum RuleParam { 
	SEL_FILE("file", ParamType.INTEGER),
	ADD_FILES("files", ParamType.INTEGER_ARRAY),
	RANDOM_SEED("seed", ParamType.INTEGER),	
	JOIN_COLS("cols", ParamType.INTEGER_ARRAY),
	ZIP_SEP("sep", ParamType.STRING);

	private final String name;
	private final ParamType type;

	private RuleParam(final String name, final ParamType type) {
		this.name = name;
		this.type = type;
	}

	/**
	* Returns the alias name of this parameter.
	* @return The alias name of this parameter
	*/
	public String getName() {
		return this.name;
	}
	
	/**
	* Returns the comment for this parameter.
	* @return The comment for this parameter
	*/
	public String getComment() {
		switch(this.type) {
			case INTEGER:
            			return "is an integer value";
			case INTEGER_ARRAY:
				return "is a list of integer separated by a comma; starting by a comma or 2 consecutives commas mean a default value";
            		default:
            			return "is a string value";
		}		
	}

	/**
 	* Returns the {@link ParamValue} representation of the parameter value.
 	* @param value The value of the parameter on command line
 	* @return The {@link ParamValue} representation of the parameter value
 	*/
	public ParamValue createValue(final String value) throws NumberFormatException {
		ParamValue pv = null;
		switch (this.type) {
			case INTEGER:				
            			pv = ParamValue.createInt(Integer.parseInt(value));
            			break;
			case INTEGER_ARRAY:
				final String[] stringArray = value.split(",");
				final int len = value.endsWith(",") ? stringArray.length+1 : stringArray.length;
				final int[] intArray = new int[len];
				for (int i=0; i < stringArray.length; i++) {
					if (stringArray[i].equals("")) {
						intArray[i] = -1;
					} else {
						intArray[i] = Integer.parseInt(stringArray[i]);
					}
				}
				if (len > stringArray.length) {
					intArray[stringArray.length] = -1;
				}
            			pv = ParamValue.createIntArray(intArray);
            			break;
            		default:
            			pv = ParamValue.createString(value);
		}
		return pv;
	}

}

@@ -204,16 +204,22 @@
 .INTEGER
+, true
 ),%0A%09ADD_
@@ -252,24 +252,31 @@
 NTEGER_ARRAY
+, false
 ),%0A%09RANDOM_S
@@ -304,16 +304,23 @@
 .INTEGER
+, false
 ),%09%0A%09JOI
@@ -357,16 +357,23 @@
 ER_ARRAY
+, false
 ),%0A%09ZIP_
@@ -399,16 +399,23 @@
 e.STRING
+, false
 );%0A%0A%09pri
@@ -468,16 +468,50 @@
 pe type;
+%0A%09private final boolean mandatory;
 %0A%0A%09priva
@@ -558,24 +558,49 @@
 ramType type
+, final boolean mandatory
 ) %7B%0A%09%09this.n
@@ -631,16 +631,46 @@
 = type;%0A
+%09%09this.mandatory = mandatory;%0A
 %09%7D%0A%0A%09/**
@@ -1241,24 +1241,182 @@
 ;%0A%09%09%7D%09%09%0A%09%7D%0A%0A
+%09/**%0A%09* Indicates if the parameter is mandatory%0A%09* @return True if the parameter is mandatory%0A%09*/%0A%09public boolean isMandatory() %7B%0A%09%09return this.mandatory;%0A%09%7D%0A
 %09/**%0A %09* Ret

Update RuleParam.java