Skip to content

Commit aa9c2ab

Browse files
committed
- Added new getValue() method to the Console class
git-svn-id: svn://192.168.0.80/JavaXT/javaxt-core@1564 2c7b0aa6-e0b2-3c4e-bb4a-8b65b6c465ff
1 parent 4610335 commit aa9c2ab

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/javaxt/utils/Console.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.InputStreamReader;
55
import java.text.DecimalFormat;
66
import java.lang.reflect.Array;
7+
import java.util.HashMap;
78

89
//******************************************************************************
910
//** Console
@@ -252,8 +253,8 @@ public synchronized void halt() {
252253
* with a "-" character (e.g. "-version" or "--version") followed by a
253254
* value (or nothing at all).
254255
*/
255-
public static java.util.HashMap<String, String> parseArgs(String[] args){
256-
java.util.HashMap<String, String> map = new java.util.HashMap<String, String>();
256+
public static HashMap<String, String> parseArgs(String[] args){
257+
HashMap<String, String> map = new HashMap<>();
257258
for (int i=0; i<args.length; i++){
258259
String key = args[i];
259260
if (key.startsWith("-")){
@@ -276,6 +277,23 @@ public static java.util.HashMap<String, String> parseArgs(String[] args){
276277
}
277278

278279

280+
//**************************************************************************
281+
//** getValue
282+
//**************************************************************************
283+
/** Returns a value for a given set of command line arguments
284+
* @param args HashMap of command line inputs generated by parseArgs()
285+
* @param keys One or more keywords to search (e.g. "-threads", "-t")
286+
*/
287+
public static Value getValue(HashMap<String, String> args, String ...keys){
288+
for (String key : keys){
289+
if (args.containsKey(key)){
290+
return new Value(args.get(key));
291+
}
292+
}
293+
return new Value(null);
294+
}
295+
296+
279297
//**************************************************************************
280298
//** main
281299
//**************************************************************************

0 commit comments

Comments
 (0)