Added:
trunk/samples/src/main/java/com/google/jacli/samples/opt/Messages_zh_CN.properties
trunk/samples/src/main/java/com/google/jacli/samples/opt/Messages_zh_CN.properties.txt
trunk/src/main/java/com/google/jacli/Messages_zh_CN.properties
trunk/src/main/java/com/google/jacli/Messages_zh_CN.properties.txt
Modified:
trunk/samples/ (props changed)
trunk/samples/src/main/java/com/google/jacli/samples/opt/Sample.java
trunk/src/main/java/com/google/jacli/CommandLineParser.java
trunk/src/main/java/com/google/jacli/CommonBean.java
Log:
* Add the Chinese locale
* Get all of the fields, include the fields from the super classes
Added: trunk/samples/src/main/java/com/google/jacli/samples/opt/Messages_zh_CN.properties
==============================================================================
--- (empty file)
+++ trunk/samples/src/main/java/com/google/jacli/samples/opt/Messages_zh_CN.properties Fri May 30 00:14:51 2008
@@ -0,0 +1,2 @@
+PACKAGE_MAP = [wsdl namespace =]Package Name
+OUTPUT_DIR = \u6307\u5b9a\u6587\u4ef6\u8f93\u51fa\u76ee\u5f55
Added: trunk/samples/src/main/java/com/google/jacli/samples/opt/Messages_zh_CN.properties.txt
==============================================================================
--- (empty file)
+++ trunk/samples/src/main/java/com/google/jacli/samples/opt/Messages_zh_CN.properties.txt Fri May 30 00:14:51 2008
@@ -0,0 +1,2 @@
+PACKAGE_MAP = [wsdl namespace =]Package Name
+OUTPUT_DIR = ָ���ļ����Ŀ¼
Modified: trunk/samples/src/main/java/com/google/jacli/samples/opt/Sample.java
==============================================================================
--- trunk/samples/src/main/java/com/google/jacli/samples/opt/Sample.java (original)
+++ trunk/samples/src/main/java/com/google/jacli/samples/opt/Sample.java Fri May 30 00:14:51 2008
@@ -1,5 +1,7 @@
package com.google.jacli.samples.opt;
+import java.lang.reflect.Method;
+
import com.google.jacli.CommandLine;
import com.google.jacli.CommandLineParser;
@@ -12,5 +14,13 @@
CommandLine commandLine = CommandLineParser.parse(bean, args);
commandLine.printUsage();
+
+ Method[] fields = SampleBean.class.getDeclaredMethods();
+
+ //System.out.println(CommandLineParser.getAllDeclaredFields(SampleBean.class));
+
+// for (int i = 0; i < fields.length; i++) {
+// System.out.println(fields[i]);
+// }
}
}
Modified: trunk/src/main/java/com/google/jacli/CommandLineParser.java
==============================================================================
--- trunk/src/main/java/com/google/jacli/CommandLineParser.java (original)
+++ trunk/src/main/java/com/google/jacli/CommandLineParser.java Fri May 30 00:14:51 2008
@@ -1,7 +1,11 @@
package com.google.jacli;
import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
public final class CommandLineParser {
private CommandLineParser() {
@@ -15,7 +19,7 @@
Class clz = target.getClass();
- Field[] fields = clz.getDeclaredFields();
+ List<Field> fields = getAllDeclaredFields(target.getClass());
List<Field> fieldList = command.getFields();
@@ -60,5 +64,24 @@
public static Argument getArgument(final Field field) {
return (Argument) field.getAnnotation(Argument.class);
+ }
+
+ public static List<Field> getAllDeclaredFields(Class target) {
+ List<Field> fields = new ArrayList<Field>();
+ for (Class clz : getAllSuperClasses(target)) {
+ fields.addAll(Arrays.asList(clz.getDeclaredFields()));
+ }
+ return fields;
+ }
+
+ public static List<Class> getAllSuperClasses(Class target) {
+ List<Class> superClasses = new ArrayList<Class>();
+ Class<?> pClass = target;
+
+ while (pClass != Object.class) {
+ superClasses.add(pClass);
+ pClass = pClass.getSuperclass();
+ }
+ return superClasses;
}
}
Modified: trunk/src/main/java/com/google/jacli/CommonBean.java
==============================================================================
--- trunk/src/main/java/com/google/jacli/CommonBean.java (original)
+++ trunk/src/main/java/com/google/jacli/CommonBean.java Fri May 30 00:14:51 2008
@@ -2,12 +2,12 @@
public class CommonBean {
@Argument(shortName = "h", option = "help", documentation = "HELP")
- private boolean help;
+ protected boolean help;
@Argument(shortName = "v", option = "verbose", documentation = "VERBOSE")
- private boolean verbose;
+ protected boolean verbose;
- public final boolean isHelp() {
+ public final boolean getHelp() {
return help;
}
@@ -15,7 +15,7 @@
this.help = newHelp;
}
- public final boolean isVerbose() {
+ public final boolean getVerbose() {
return verbose;
}
Added: trunk/src/main/java/com/google/jacli/Messages_zh_CN.properties
==============================================================================
--- (empty file)
+++ trunk/src/main/java/com/google/jacli/Messages_zh_CN.properties Fri May 30 00:14:51 2008
@@ -0,0 +1,2 @@
+HELP = \u6253\u5370\u5e2e\u52a9\u4fe1\u606f
+VERBOSE = \u663e\u793a\u6700\u8be6\u7ec6\u4fe1\u606f
Added: trunk/src/main/java/com/google/jacli/Messages_zh_CN.properties.txt
==============================================================================
--- (empty file)
+++ trunk/src/main/java/com/google/jacli/Messages_zh_CN.properties.txt Fri May 30 00:14:51 2008
@@ -0,0 +1,2 @@
+HELP = ��ӡ������Ϣ
+VERBOSE = ��ʾ����ϸ��Ϣ
\ No newline at end of file