Index: lutinutil/src/java/org/codelutin/util/OptionArgumentDefinition.java
diff -u /dev/null lutinutil/src/java/org/codelutin/util/OptionArgumentDefinition.java:1.1
--- /dev/null Mon Nov 19 19:36:49 2007
+++ lutinutil/src/java/org/codelutin/util/OptionArgumentDefinition.java Mon Nov 19 19:36:41 2007
@@ -0,0 +1,135 @@
+/**
+ * ##% Copyright (C) 2002, 2007 Code Lutin This program is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
+ * - Suite 330, Boston, MA 02111-1307, USA. ##%*
+ */
+package org.codelutin.util;
+
+import static org.codelutin.i18n.I18n._;
+
+/**
+ * Cette classe représente la définition d'un argument d'une option.
+ *
+ * Elle comprend :
+ *
+ * - son type {@link #type}, à savoir constant, valued ou namedAndValued.
+ * - le type de sa valeur {@link #valueType}.
+ * - la clef de l'argument {@link #key} (pour un argument constant, il s'agit
+ * de la constante elle même, pour un ValuedArgument de sa description et
+ * pour un NamedValuedArgument de sa clef).
+ * - sa cardinalité {@link #min} {@link #max}
+ * - sa position {@link #position} (si argument dans un groupe
+ * d'arguments obligatoires) , sinon -1
+ *
+ * De manière générale cette classe ne doit pas être instanciée directement,
+ * cela est fait automatiquement lors du parsing de la définition de l'option
+ * par le parseur ou dans les factory de définitions.
+ *
+ * @author chemit
+ * @see OptionArgumentType
+ * @see OptionArgumentValueType
+ * @see OptionDefinition
+ */
+public class OptionArgumentDefinition {
+
+ /** type de l'argument */
+ protected OptionArgumentType type;
+
+ /** type de la valeur de l'argument */
+ protected OptionArgumentValueType valueType;
+
+ /** clef unique qui définie l'argument */
+ protected String key;
+
+ /** nombre minimum d'occurrences requis */
+ protected int min;
+
+ /** nombre maximum d'occurrences requis, ou -1 si pas de limite */
+ protected int max;
+
+ /** la position de l'argument dans l'option si argument obligatoire, -1 sinon */
+ protected int position;
+
+ protected OptionArgumentDefinition(OptionArgumentType type,
+ OptionArgumentValueType valueType,
+ String key,
+ int min, int max, int position) {
+ this.type = type;
+ this.valueType = valueType;
+ this.key = key;
+ this.min = min;
+ this.max = max;
+ this.position = position;
+ }
+
+ public OptionArgumentType getType() {
+ return type;
+ }
+
+ public OptionArgumentValueType getValueType() {
+ return valueType;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public int getMax() {
+ return max;
+ }
+
+ public int getMin() {
+ return min;
+ }
+
+ public int getPosition() {
+ return position;
+ }
+
+ public boolean isMandatory() {
+ return position > -1;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ OptionArgumentDefinition that = (OptionArgumentDefinition) o;
+ return max == that.max &&
+ min == that.min &&
+ key.equals(that.key) &&
+ valueType.equals(that.valueType);
+ }
+
+ @Override
+ public int hashCode() {
+ int result;
+ result = key.hashCode();
+ result = 31 * result + valueType.hashCode();
+ result = 31 * result + min;
+ result = 31 * result + max;
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ StringBuffer s = new StringBuffer();
+ s.append(_("lutinutil.parserdef.printDetail.argument",key, type,
+ valueType));
+ StringUtil.printCardinalite(sb, s.toString(), min, max, isMandatory());
+ return sb.toString();
+ }
+
+}