[jacli commit] r15 - in trunk: samples/src/main/java/com/google/jacli/samples/opt src/main/java/com/google/jacli

1 view
Skip to first unread message

codesite...@google.com

unread,
May 30, 2008, 3:33:45 AM5/30/08
to fant...@googlegroups.com
Author: maomaode
Date: Fri May 30 00:33:31 2008
New Revision: 15

Modified:
trunk/samples/src/main/java/com/google/jacli/samples/opt/SampleBean.java
trunk/src/main/java/com/google/jacli/CommandLineParser.java
trunk/src/main/java/com/google/jacli/DefaultUsage.java

Log:
* Support the L10N bundle of the super classes

Modified: trunk/samples/src/main/java/com/google/jacli/samples/opt/SampleBean.java
==============================================================================
---
trunk/samples/src/main/java/com/google/jacli/samples/opt/SampleBean.java (original)
+++
trunk/samples/src/main/java/com/google/jacli/samples/opt/SampleBean.java
Fri May 30 00:33:31 2008
@@ -12,6 +12,17 @@
@Argument(option = "p", documentation = "PACKAGE_MAP")
private Map<String, String> packageMap;

+ @Argument(shortName = "c", option = "compile")
+ private boolean compile;
+
+ public boolean getCompile() {
+ return this.compile;
+ }
+
+ public void setCompile(boolean c) {
+ this.compile = c;
+ }
+
public final File getOutputDir() {
return outputDir;
}

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:33:31 2008
@@ -3,9 +3,7 @@
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() {

Modified: trunk/src/main/java/com/google/jacli/DefaultUsage.java
==============================================================================
--- trunk/src/main/java/com/google/jacli/DefaultUsage.java (original)
+++ trunk/src/main/java/com/google/jacli/DefaultUsage.java Fri May 30
00:33:31 2008
@@ -1,26 +1,34 @@
package com.google.jacli;

import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

import com.google.jacli.l10n.BundleUtil;

public class DefaultUsage implements Usage {
+
+ private Map<Class, ResourceBundle> bundleMaps = new HashMap<Class, ResourceBundle>();

public void print(CommandLine commandLine) {
StringBuffer buffer = new StringBuffer();
ResourceBundle bundle = null;

- try {
- bundle = BundleUtil.getBundle(commandLine.getBean().getClass());
- } catch (MissingResourceException e) {
- // ignore the exception
- }
-
if (commandLine.getPattern() == Pattern.OPT) {
for (Field field : commandLine.getFields()) {
Argument argument = CommandLineParser.getArgument(field);
+
+ bundle = bundleMaps.get(field.getDeclaringClass());
+ if (bundle == null) {
+ try {
+ bundle = BundleUtil.getBundle(field.getDeclaringClass());
+ } catch (MissingResourceException e) {
+ // ignore the exception
+ }
+ bundleMaps.put(field.getDeclaringClass(), bundle);
+ }

if (!argument.required()) {
buffer.append("[");

Reply all
Reply to author
Forward
0 new messages