Index: lutinutil/src/java/org/codelutin/util/OptionArgumentType.java diff -u /dev/null lutinutil/src/java/org/codelutin/util/OptionArgumentType.java:1.1 --- /dev/null Mon Nov 19 19:05:22 2007 +++ lutinutil/src/java/org/codelutin/util/OptionArgumentType.java Mon Nov 19 19:05:12 2007 @@ -0,0 +1,163 @@ +package org.codelutin.util; + +import static org.codelutin.util.OptionArgumentValueType._string; + +/** + * le type d'un argument d'option. + *
+ * La classe offre une méthode publique statique : + * + * {@link #findType(String)} pour trouver un type à partir de la + * définition d'un argument. + * + * Chaque constante offre deux méthodes publiques : + * + * {@link #explodeDefinition(String)} pour obtenir le couple + * [clef d'argument, type d'argument] à partir de la définition + * d'un argument. + * + * {@link #extractArgumentValue(String)} pour obtenir la valeur d'un + * argument de la ligne de commande. + * + * @author chemit + */ +public enum OptionArgumentType { + /** + * Dans la définition d'un argument , ce type est représenté sous la forme + * + *constantKeyconstantKey.
+ *
+ * Son type est toujours {@link OptionArgumentValueType#_string}.
+ *
+ * Pour accepter cet argument de la ligne de commande, il faut entrer
+ * extactement constantKey.
+ *
+ * @see OptionArgumentValueType#matchType(String)
+ * @see OptionArgumentValueType#findTypeFromDefinition(String)
+ * @see OptionArgumentValueType#findTypeFromArgument(String)
+ */
+ constant() {
+ public String[] explodeDefinition(String argumentDefinition) {
+ return new String[]{argumentDefinition, _string.toString()};
+ }
+ public String extractArgumentValue(String argument) {
+ return argument;
+ }
+ },
+ /**
+ * Dans la définition d'un argument , ce type est représenté sous la forme
+ *
+ * valuedKey:typevaluedKey.
+ *
+ * Son type est celui mappe sur type.
+ *
+ * Pour accepter cet argument de la ligne de commande, il faut entrer
+ * extactement un argument vérifiant le type.
+ *
+ * @see OptionArgumentValueType#matchType(String)
+ * @see OptionArgumentValueType#findTypeFromDefinition(String)
+ * @see OptionArgumentValueType#findTypeFromArgument(String)
+ */
+ valued() {
+ public String[] explodeDefinition(String argumentDefinition) {
+ int index = argumentDefinition.indexOf(':');
+ return new String[]{argumentDefinition.substring(0, index),
+ argumentDefinition.substring(index + 1)};
+ }
+ public String extractArgumentValue(String argument) {
+ return argument;
+ }
+ },
+ /**
+ * Dans la définition d'un argument , ce type est représenté sous la forme
+ *
+ * namedAndValuedKey=typenamedAndValuedKey.
+ *
+ * Son type est celui mappe sur type.
+ *
+ * Pour accepter cet argument de la ligne de commande, il faut entrer
+ * extactement un argument de la forme
+ * namedAndValuedKey=valeur, où
+ * type doit vérifier le type mappé sur type
+ *