@@ -1285,67 +1285,6 @@ public static void printToFile(String filename, String message) {
1285
1285
printToFile (new File (filename ), message , false );
1286
1286
}
1287
1287
1288
- /**
1289
- * A simpler form of command line argument parsing.
1290
- * Dan thinks this is highly superior to the overly complexified code that
1291
- * comes before it.
1292
- * Parses command line arguments into a Map. Arguments of the form
1293
- * -flag1 arg1 -flag2 -flag3 arg3
1294
- * will be parsed so that the flag is a key in the Map (including the hyphen)
1295
- * and the
1296
- * optional argument will be its value (if present).
1297
- *
1298
- * @return A Map from keys to possible values (String or null)
1299
- */
1300
- @ SuppressWarnings ("unchecked" )
1301
- public static Map <String , String > parseCommandLineArguments (String [] args ) {
1302
- return (Map )parseCommandLineArguments (args , false );
1303
- }
1304
-
1305
- /**
1306
- * A simpler form of command line argument parsing.
1307
- * Dan thinks this is highly superior to the overly complexified code that
1308
- * comes before it.
1309
- * Parses command line arguments into a Map. Arguments of the form
1310
- * -flag1 arg1 -flag2 -flag3 arg3
1311
- * will be parsed so that the flag is a key in the Map (including the hyphen)
1312
- * and the
1313
- * optional argument will be its value (if present).
1314
- * In this version, if the argument is numeric, it will be a Double value
1315
- * in the map, not a String.
1316
- *
1317
- * @return A Map from keys to possible values (String or null)
1318
- */
1319
- public static Map <String , Object > parseCommandLineArguments (String [] args , boolean parseNumbers ) {
1320
- Map <String , Object > result = Generics .newHashMap ();
1321
- for (int i = 0 ; i < args .length ; i ++) {
1322
- String key = args [i ];
1323
- if (key .charAt (0 ) == '-' ) {
1324
- if (i + 1 < args .length ) {
1325
- String value = args [i + 1 ];
1326
- if (value .charAt (0 ) != '-' ) {
1327
- if (parseNumbers ) {
1328
- Object numericValue = value ;
1329
- try {
1330
- numericValue = Double .parseDouble (value );
1331
- } catch (NumberFormatException e2 ) {
1332
- // ignore
1333
- }
1334
- result .put (key , numericValue );
1335
- } else {
1336
- result .put (key , value );
1337
- }
1338
- i ++;
1339
- } else {
1340
- result .put (key , null );
1341
- }
1342
- } else {
1343
- result .put (key , null );
1344
- }
1345
- }
1346
- }
1347
- return result ;
1348
- }
1349
1288
1350
1289
public static String stripNonAlphaNumerics (String orig ) {
1351
1290
StringBuilder sb = new StringBuilder ();
@@ -1367,7 +1306,7 @@ public static String stripSGML(String orig) {
1367
1306
public static void printStringOneCharPerLine (String s ) {
1368
1307
for (int i = 0 ; i < s .length (); i ++) {
1369
1308
int c = s .charAt (i );
1370
- System .out .println (c + " \ ' " + (char ) c + "\ ' " );
1309
+ System .out .println (c + " '" + (char ) c + "' " );
1371
1310
}
1372
1311
}
1373
1312
@@ -1675,7 +1614,7 @@ public static <T> T columnStringToObject(Class objClass, String str, String deli
1675
1614
public static <T > T columnStringToObject (Class <?> objClass , String str , Pattern delimiterPattern , String [] fieldNames )
1676
1615
throws InstantiationException , IllegalAccessException , NoSuchMethodException , NoSuchFieldException , InvocationTargetException {
1677
1616
String [] fields = delimiterPattern .split (str );
1678
- T item = ErasureUtils .uncheckedCast (objClass .newInstance ());
1617
+ T item = ErasureUtils .uncheckedCast (objClass .getDeclaredConstructor (). newInstance ());
1679
1618
for (int i = 0 ; i < fields .length ; i ++) {
1680
1619
try {
1681
1620
Field field = objClass .getDeclaredField (fieldNames [i ]);
@@ -1955,7 +1894,7 @@ public static String toAscii(String s) {
1955
1894
} else if (c >= 0x00fd && c <= 0x00ff ) {
1956
1895
result = "y" ;
1957
1896
} else if (c >= 0x2018 && c <= 0x2019 ) {
1958
- result = "\ ' " ;
1897
+ result = "'" ;
1959
1898
} else if (c >= 0x201c && c <= 0x201e ) {
1960
1899
result = "\" " ;
1961
1900
} else if (c >= 0x0213 && c <= 0x2014 ) {
@@ -2316,7 +2255,8 @@ public static Collection<String> getCharacterNgrams(String s, int minSize, int m
2316
2255
return ngrams ;
2317
2256
}
2318
2257
2319
- private static Pattern diacriticalMarksPattern = Pattern .compile ("\\ p{InCombiningDiacriticalMarks}" );
2258
+ private static final Pattern diacriticalMarksPattern = Pattern .compile ("\\ p{InCombiningDiacriticalMarks}" );
2259
+
2320
2260
public static String normalize (String s ) {
2321
2261
// Normalizes string and strips diacritics (map to ascii) by
2322
2262
// 1. taking the NFKD (compatibility decomposition -
@@ -2711,12 +2651,12 @@ public static Map<String, String> decodeMap(String encoded){
2711
2651
i += 1 ;
2712
2652
}else {
2713
2653
//(case: normal)
2714
- if (chars [i ] == '"' ){
2654
+ if (chars [i ] == '"' ) {
2715
2655
quoteCloseChar = '"' ;
2716
- } else if (chars [i ] == '\'' ){
2656
+ } else if (chars [i ] == '\'' ) {
2717
2657
quoteCloseChar = '\'' ;
2718
2658
} else if (chars [i ] == '\n' && current .length () == 0 ) {
2719
- current .append ("" ); // do nothing
2659
+ // current.append(""); // do nothing
2720
2660
} else if (chars [i ] == ',' || chars [i ] == ';' || chars [i ] == '\t' || chars [i ] == '\n' ){
2721
2661
// case: end a value
2722
2662
if (onKey ) {
0 commit comments