Permalink
Browse files

Miscellaneous source cleanup

Removed Java 1.1 idioms like java.util.Iterator and now unneccessary typecasts
  • Loading branch information...
1 parent e54537c commit 0986aecb1f452b76c8c6addcd2083f4c39335272 @penSecIT penSecIT committed Sep 23, 2012
View
@@ -114,6 +114,24 @@
</java>
</target>
+ <target name="run-examples" depends="compile-examples">
+ <java classname="com.sanityinc.jargs.examples.OptionTest"
+ classpath="${build.classes}:${examples.classes}:${java.class.path}">
+ </java>
+ <java classname="com.sanityinc.jargs.examples.AutoHelpParser"
+ classpath="${build.classes}:${examples.classes}:${java.class.path}">
+ <arg value="--help" />
+ </java>
+ <java classname="com.sanityinc.jargs.examples.CustomOptionTest"
+ classpath="${build.classes}:${examples.classes}:${java.class.path}">
+ <arg value="-d" />
+ <arg value="09/23/2012" />
+ </java>
+ <java classname="com.sanityinc.jargs.examples.OptionParserSubclassTest"
+ classpath="${build.classes}:${examples.classes}:${java.class.path}">
+ </java>
+ </target>
+
<target name="clean"
description="Remove all generated files.">
<delete dir="target" />
@@ -35,7 +35,6 @@
import com.sanityinc.jargs.CmdLineParser;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
/**
@@ -83,18 +82,18 @@ public static void main( String[] args ) {
System.exit(2);
}
- if ( Boolean.TRUE.equals(parser.getOptionValue(help))) {
+ if ( parser.getOptionValue(help) ) {
parser.printUsage();
System.exit(0);
}
// Extract the values entered for the various options -- if the
// options were not specified, the corresponding values will be
// null.
- Boolean verboseValue = (Boolean)parser.getOptionValue(verbose);
- Integer sizeValue = (Integer)parser.getOptionValue(size);
- String nameValue = (String)parser.getOptionValue(name);
- Double fractionValue = (Double)parser.getOptionValue(fraction);
+ Boolean verboseValue = parser.getOptionValue(verbose);
+ Integer sizeValue = parser.getOptionValue(size);
+ String nameValue = parser.getOptionValue(name);
+ Double fractionValue = parser.getOptionValue(fraction);
// For testing purposes, we just print out the option values
System.out.println("verbose: " + verboseValue);
@@ -88,9 +88,9 @@ public static void main( String[] args ) {
MyOptionsParser.FRACTION
};
- for ( int j = 0; j<allOptions.length; ++j ) {
- System.out.println(allOptions[j].longForm() + ": " +
- myOptions.getOptionValue(allOptions[j]));
+ for ( CmdLineParser.Option<?> option : allOptions ) {
+ System.out.println(option.longForm() + ": " +
+ myOptions.getOptionValue(option));
}
String[] otherArgs = myOptions.getRemainingArgs();
@@ -36,7 +36,6 @@
import com.sanityinc.jargs.CmdLineParser.Option;
import java.util.Collection;
-import java.util.Iterator;
public class OptionTest {
@@ -35,7 +35,6 @@
import com.sanityinc.jargs.CmdLineParser.Option;
import java.util.Collection;
-import java.util.Iterator;
import java.util.Locale;
import static org.junit.Assert.assertEquals;
@@ -203,9 +202,7 @@ public void testGetOptionValues() throws Exception {
int verbosity = 0;
Collection<Boolean> v = parser.getOptionValues(verbose);
- Iterator<Boolean> it = v.iterator();
- while (it.hasNext()) {
- Boolean b = it.next();
+ for (Boolean b : v) {
if (b == Boolean.TRUE) {
verbosity++;

0 comments on commit 0986aec

Please sign in to comment.