Index: lutinutil/src/java/org/codelutin/util/OptionGroupArgumentDefinition.java
diff -u /dev/null lutinutil/src/java/org/codelutin/util/OptionGroupArgumentDefinition.java:1.1
--- /dev/null Sun Dec 2 05:11:42 2007
+++ lutinutil/src/java/org/codelutin/util/OptionGroupArgumentDefinition.java Sun Dec 2 05:11:36 2007
@@ -0,0 +1,102 @@
+/**
+ * ##% 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 org.codelutin.util.OptionParserAnnotationHelper.OptionArgumentA;
+import org.codelutin.util.OptionParserAnnotationHelper.OptionGroupArgumentA;
+
+/**
+ * Cette classe représente la définition d'un groupe d'arguments d'une option.
+ *
+ * Elle comprend :
+ *
+ * - sa cardinalité {@link #min} {@link #max}
+ * - sa position {@link #pos} (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.
+ *
+ * Pour l'instant les cardinalités sur groupe se limite à {0,1} : facultatif,
+ * et {1,1} obligatoire exacement une fois.
+ *
+ * Il suffira de modifier les algorithmes des parseurs pour intégrer la gestion
+ * des cardinalités sur les groupes d'arguments d'option. A faire.
+ *
+ * @author chemit
+ */
+public class OptionGroupArgumentDefinition {
+
+ public static final int OPTIONAL_POSITION = -1;
+
+ /** nombre minimum d'occurrences requis */
+ protected int min;
+
+ /** nombre maximum d'occurrences requis, ou -1 si pas de limite */
+ protected int max;
+
+ /** la position du groupe d'argument dans l'option si obligatoire, -1 sinon */
+ protected int pos;
+
+ /** la liste de tous les argument du groupe */
+ protected OptionArgumentDefinition[] arguments;
+
+ protected OptionGroupArgumentDefinition(int min, int max, int pos,
+ OptionArgumentDefinition[] arguments) {
+ this.min = min;
+ this.max = max;
+ this.pos = pos;
+ this.arguments = arguments;
+ }
+
+ public OptionGroupArgumentDefinition(OptionGroupArgumentA definition) {
+ this.min = definition.min();
+ this.max = definition.max();
+ this.pos = definition.pos();
+ OptionArgumentA[] argumentDefinitions = definition.arguments();
+ this.arguments = new OptionArgumentDefinition[argumentDefinitions.length];
+ for (int i = 0; i < argumentDefinitions.length; i++) {
+ this.arguments[i] = new OptionArgumentDefinition(argumentDefinitions[i]);
+ }
+ }
+
+ public int getMax() {
+ return max;
+ }
+
+ public int getMin() {
+ return min;
+ }
+
+ public int getPos() {
+ return pos;
+ }
+
+ public boolean isMandatory() {
+ return pos != OPTIONAL_POSITION;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ StringBuffer s = new StringBuffer();
+ for (OptionArgumentDefinition argument : arguments) {
+ s.append('|').append(argument);
+ }
+ String s1 = s.toString();
+ StringUtil.printCardinalite(sb, s1.length() > 0 ? s1.substring(1) : s1, min, max, isMandatory(),"<",">","[","]");
+ return sb.toString();
+ }
+
+}
\ No newline at end of file