jkeyes 2004/03/06 14:21:24
Modified: cli/src/test/org/apache/commons/cli2/impl Tag:
RESEARCH_CLI_2_ROXSPRING ArgumentTest.java
cli/src/java/org/apache/commons/cli2/impl Tag:
RESEARCH_CLI_2_ROXSPRING ArgumentImpl.java
Added: cli/src/java/org/apache/commons/cli2/impl Tag:
RESEARCH_CLI_2_ROXSPRING messages.properties
Log:
- housekeeping
. use tertiary operator
. l12n
Revision Changes Path
No revision
No revision
1.1.2.10 +23 -19
jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/ArgumentTest.java
Index: ArgumentTest.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/ArgumentTest.java,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -r1.1.2.9 -r1.1.2.10
--- ArgumentTest.java 25 Feb 2004 00:49:21 -0000 1.1.2.9
+++ ArgumentTest.java 6 Mar 2004 22:21:24 -0000 1.1.2.10
@@ -30,6 +30,7 @@
import org.apache.commons.cli2.Option;
import org.apache.commons.cli2.OptionException;
import org.apache.commons.cli2.WriteableCommandLine;
+import org.apache.commons.cli2.resources.ResourceHelper;
import org.apache.commons.cli2.validation.DateValidator;
import org.apache.commons.cli2.validation.DateValidatorTest;
@@ -38,6 +39,8 @@
*/
public class ArgumentTest extends ArgumentTestCase {
+ private ResourceHelper resources =
ResourceHelper.getResourceHelper(ArgumentTest.class);
+
public static Argument buildUsernameArgument() {
return new ArgumentImpl(
"username",
@@ -108,25 +111,6 @@
0);
}
- public void testNew() {
- try {
- new ArgumentImpl(
- "limit",
- "the last acceptable date",
- 10,
- 5,
- '=',
- '\0',
- new DateValidator(DateValidatorTest.YYYY_MM_YY),
- null,
- null,
- 0);
- }
- catch (IllegalArgumentException e) {
- assertEquals("minimum must not exceed maximum", e.getMessage());
- }
- }
-
public static Argument buildSizeArgument() {
List defaults = new ArrayList();
defaults.add("10");
@@ -160,6 +144,26 @@
ArgumentImpl.DEFAULT_CONSUME_REMAINING,
defaults,
0);
+ }
+
+ public void testNew() {
+ try {
+ new ArgumentImpl(
+ "limit",
+ "the last acceptable date",
+ 10,
+ 5,
+ '=',
+ '\0',
+ new DateValidator(DateValidatorTest.YYYY_MM_YY),
+ null,
+ null,
+ 0);
+ } catch (IllegalArgumentException e) {
+ assertEquals(
+ resources.getMessage("cli.error.minimum.exceeds.maximum"),
+ e.getMessage());
+ }
}
/*
No revision
No revision
1.1.2.10 +11 -10
jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/ArgumentImpl.java
Index: ArgumentImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/ArgumentImpl.java,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -r1.1.2.9 -r1.1.2.10
--- ArgumentImpl.java 25 Feb 2004 00:49:21 -0000 1.1.2.9
+++ ArgumentImpl.java 6 Mar 2004 22:21:24 -0000 1.1.2.10
@@ -28,6 +28,7 @@
import org.apache.commons.cli2.Option;
import org.apache.commons.cli2.OptionException;
import org.apache.commons.cli2.WriteableCommandLine;
+import org.apache.commons.cli2.resources.ResourceHelper;
import org.apache.commons.cli2.validation.InvalidArgumentException;
import org.apache.commons.cli2.validation.Validator;
@@ -48,6 +49,8 @@
private final Validator validator;
private final String consumeRemaining;
private final List defaultValues;
+ private final ResourceHelper resources
+ = ResourceHelper.getResourceHelper(ArgumentImpl.class);
private static final char NUL = '\0';
public static final char DEFAULT_INITIAL_SEPARATOR = NUL;
@@ -91,15 +94,10 @@
final String consumeRemaining,
final List defaultValues,
final int id) {
+
super(id);
- if (name == null) {
- this.name = "arg";
- }
- else {
- this.name = name;
- }
-
+ this.name = (name == null) ? "arg" : name;
this.description = description;
this.minimum = minimum;
this.maximum = maximum;
@@ -111,16 +109,19 @@
this.defaultValues = defaultValues;
if (minimum > maximum) {
- throw new IllegalArgumentException("minimum must not exceed maximum");
+ throw new IllegalArgumentException(
+ resources.getMessage("cli.error.minimum.exceeds.maximum"));
}
if (defaultValues != null) {
if (defaultValues.size() < minimum) {
- throw new IllegalArgumentException("not enough default values");
+ throw new IllegalArgumentException(
+ resources.getMessage("cli.error.too.few.defaults"));
}
if (defaultValues.size() > maximum) {
- throw new IllegalArgumentException("too many default values");
+ throw new IllegalArgumentException(
+ resources.getMessage("cli.error.too.many.defaults"));
}
}
}
No revision
Index: ArgumentImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/ArgumentImpl.java,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -r1.1.2.9 -r1.1.2.10
--- ArgumentImpl.java 25 Feb 2004 00:49:21 -0000 1.1.2.9
+++ ArgumentImpl.java 6 Mar 2004 22:21:24 -0000 1.1.2.10
@@ -28,6 +28,7 @@
import org.apache.commons.cli2.Option;
import org.apache.commons.cli2.OptionException;
import org.apache.commons.cli2.WriteableCommandLine;
+import org.apache.commons.cli2.resources.ResourceHelper;
import org.apache.commons.cli2.validation.InvalidArgumentException;
import org.apache.commons.cli2.validation.Validator;
@@ -48,6 +49,8 @@
private final Validator validator;
private final String consumeRemaining;
private final List defaultValues;
+ private final ResourceHelper resources
+ = ResourceHelper.getResourceHelper(ArgumentImpl.class);
private static final char NUL = '\0';
public static final char DEFAULT_INITIAL_SEPARATOR = NUL;
@@ -91,15 +94,10 @@
final String consumeRemaining,
final List defaultValues,
final int id) {
+
super(id);
- if (name == null) {
- this.name = "arg";
- }
- else {
- this.name = name;
- }
-
+ this.name = (name == null) ? "arg" : name;
this.description = description;
this.minimum = minimum;
this.maximum = maximum;
@@ -111,16 +109,19 @@
this.defaultValues = defaultValues;
if (minimum > maximum) {
- throw new IllegalArgumentException("minimum must not exceed maximum");
+ throw new IllegalArgumentException(
+ resources.getMessage("cli.error.minimum.exceeds.maximum"));
}
if (defaultValues != null) {
if (defaultValues.size() < minimum) {
- throw new IllegalArgumentException("not enough default values");
+ throw new IllegalArgumentException(
+ resources.getMessage("cli.error.too.few.defaults"));
}
if (defaultValues.size() > maximum) {
- throw new IllegalArgumentException("too many default values");
+ throw new IllegalArgumentException(
+ resources.getMessage("cli.error.too.many.defaults"));
}
}
}
No revision
Index: ArgumentImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/ArgumentImpl.java,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -r1.1.2.9 -r1.1.2.10
--- ArgumentImpl.java 25 Feb 2004 00:49:21 -0000 1.1.2.9
+++ ArgumentImpl.java 6 Mar 2004 22:21:24 -0000 1.1.2.10
@@ -28,6 +28,7 @@
import org.apache.commons.cli2.Option;
import org.apache.commons.cli2.OptionException;
import org.apache.commons.cli2.WriteableCommandLine;
+import org.apache.commons.cli2.resources.ResourceHelper;
import org.apache.commons.cli2.validation.InvalidArgumentException;
import org.apache.commons.cli2.validation.Validator;
@@ -48,6 +49,8 @@
private final Validator validator;
private final String consumeRemaining;
private final List defaultValues;
+ private final ResourceHelper resources
+ = ResourceHelper.getResourceHelper(ArgumentImpl.class);
private static final char NUL = '\0';
public static final char DEFAULT_INITIAL_SEPARATOR = NUL;
@@ -91,15 +94,10 @@
final String consumeRemaining,
final List defaultValues,
final int id) {
+
super(id);
- if (name == null) {
- this.name = "arg";
- }
- else {
- this.name = name;
- }
-
+ this.name = (name == null) ? "arg" : name;
this.description = description;
this.minimum = minimum;
this.maximum = maximum;
@@ -111,16 +109,19 @@
this.defaultValues = defaultValues;
if (minimum > maximum) {
- throw new IllegalArgumentException("minimum must not exceed maximum");
+ throw new IllegalArgumentException(
+ resources.getMessage("cli.error.minimum.exceeds.maximum"));
}
if (defaultValues != null) {
if (defaultValues.size() < minimum) {
- throw new IllegalArgumentException("not enough default values");
+ throw new IllegalArgumentException(
+ resources.getMessage("cli.error.too.few.defaults"));
}
if (defaultValues.size() > maximum) {
- throw new IllegalArgumentException("too many default values");
+ throw new IllegalArgumentException(
+ resources.getMessage("cli.error.too.many.defaults"));
}
}
}
1.1.2.3 +3 -9
jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/messages.properties
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]