Index: lutincommandline/src/java/org/codelutin/option/def/DefinitionParserUtil.java diff -u lutincommandline/src/java/org/codelutin/option/def/DefinitionParserUtil.java:1.2 lutincommandline/src/java/org/codelutin/option/def/DefinitionParserUtil.java:1.3 --- lutincommandline/src/java/org/codelutin/option/def/DefinitionParserUtil.java:1.2 Sun Mar 16 03:49:49 2008 +++ lutincommandline/src/java/org/codelutin/option/def/DefinitionParserUtil.java Sun Mar 23 00:21:15 2008 @@ -42,47 +42,12 @@ public static final Character[] OPENING_CHARS = {'(', '{', '[', '<'}; public static final Character[] CLOSING_CHARS = {')', '}', ']', '>'}; - + final static String ODEFINITION_KEY_SUFFIX = ".option.definition"; final static String CDEFINITION_KEY_FACTOR = ".config.definition."; final static String CMODIFIERS_KEY_FACTOR = ".config.modifiers."; /** - * permet de définir le type de source pour lire les définitions à analyser. - *
- * Pour le moment seul le type {@link #properties} est implanté. - * - * @author chemit - */ - public enum TypeSource { - /** pour lire à partir d'un fichier de propriétés (mode par défaut). */ - properties(DefinitionParserFromProperties.class), - /** pour lire à partir d'un fichier xml (pas implanter). */ - xml(null), - /** pour lire depuis un InputReader (pas implanter) */ - console(null); - - private Class extends DefinitionParser> impl; - - TypeSource(Class extends DefinitionParser> aClass) { - this.impl = aClass; - } - - public DefinitionParser newParserInstance() { - if (impl == null) { - throw new IllegalArgumentException(_("lutinutil.parserdef.notimplemented.sourceType")); - } - try { - return impl.newInstance(); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - } - } - - /** * Classe abstraite définissant un context de parser de définitions. * * @author tony @@ -129,7 +94,7 @@ private static final long serialVersionUID = -5430904379928407190L; String def; String mods; - //TODO use only one entry for a config property + //TODO use only one entry for a config property public ConfigDefEntry(String key, String value) { super(key, value); } @@ -138,7 +103,7 @@ static class OptionDefEntry extends AbstractMap.SimpleEntryP doParse(Class
type, Object src) throws IOException, IllegalAccessException, InstantiationException {
if (type == null) {
- throw new IllegalArgumentException(_("lutinutil.parserdef.null.sourceType", type, Arrays.toString(TypeSource.values())));
+ throw new IllegalArgumentException(_("lutinutil.parserdef.null.sourceType"));
}
if (src == null) {
throw new IllegalArgumentException(_("lutinutil.parserdef.null.source"));
}
// obtain instance of implementation of parser
- DefinitionParser parser = type.newParserInstance();
+ P parser = type.newInstance();
// init parser parser : reading from source
ParserContext context = parser.init(src);
Index: lutincommandline/src/java/org/codelutin/option/def/MandatoryConfigProperty.java
diff -u /dev/null lutincommandline/src/java/org/codelutin/option/def/MandatoryConfigProperty.java:1.1
--- /dev/null Sun Mar 23 00:21:21 2008
+++ lutincommandline/src/java/org/codelutin/option/def/MandatoryConfigProperty.java Sun Mar 23 00:21:15 2008
@@ -0,0 +1,72 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * 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.option.def;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * les propriétés de configuration obligatoires.
+ *
+ * @author chemit
+ */
+public enum MandatoryConfigProperty {
+
+ /** le nom du fichier de configuration de l'application */
+ configFileName("java.io.File"),
+
+ /** l'encoding a utiliser sur le systeme */
+ encoding("java.lang.String"),
+
+ /** la locale par default à utiliser */
+ locale("java.util.Locale"),
+
+ /** le nom du projet */
+ projectName("java.lang.String"),
+
+ /** la version du projet */
+ version("org.codelutin.util.VersionNumber");
+
+ private final String type;
+
+ private MandatoryConfigProperty(String type) {
+ this.type = type;
+ }
+
+ public String category() {
+ return "main";
+ }
+
+ public String type() {
+ return type;
+ }
+
+ public String getEntryKey() {
+ return category() + '.' + DefinitionParserUtil.CDEFINITION_KEY_FACTOR + name();
+ }
+
+ public static List