4444
4545import processing .app .contrib .*;
4646import processing .core .*;
47+ import processing .data .StringDict ;
4748import processing .data .StringList ;
4849
4950
@@ -2398,7 +2399,7 @@ static public byte[] loadBytesRaw(File file) throws IOException {
23982399 * Changed in 3.0a6 to return null (rather than empty hash) if no file,
23992400 * and changed return type to Map instead of HashMap.
24002401 */
2401- static public Map < String , String > readSettings (File inputFile ) {
2402+ static public StringDict readSettings (File inputFile ) {
24022403 if (!inputFile .exists ()) {
24032404 if (DEBUG ) System .err .println (inputFile + " does not exist." );
24042405 return null ;
@@ -2416,13 +2417,13 @@ static public Map<String, String> readSettings(File inputFile) {
24162417 * Parse a String array that contains attribute/value pairs separated
24172418 * by = (the equals sign). The # (hash) symbol is used to denote comments.
24182419 * Comments can be anywhere on a line. Blank lines are ignored.
2419- * In 3.0a6, no longer taking a blank HahMap as param; no cases in the main
2420+ * In 3.0a6, no longer taking a blank HashMap as param; no cases in the main
24202421 * PDE code of adding to a (Hash)Map. Also returning the Map instead of void.
24212422 * Both changes modify the method signature, but this was only used by the
24222423 * contrib classes.
24232424 */
2424- static public Map < String , String > readSettings (String filename , String [] lines ) {
2425- Map < String , String > settings = new HashMap <> ();
2425+ static public StringDict readSettings (String filename , String [] lines ) {
2426+ StringDict settings = new StringDict ();
24262427 for (String line : lines ) {
24272428 // Remove comments
24282429 int commentMarker = line .indexOf ('#' );
@@ -2442,7 +2443,7 @@ static public Map<String, String> readSettings(String filename, String[] lines)
24422443 } else {
24432444 String attr = line .substring (0 , equals ).trim ();
24442445 String valu = line .substring (equals + 1 ).trim ();
2445- settings .put (attr , valu );
2446+ settings .set (attr , valu );
24462447 }
24472448 }
24482449 }
@@ -2797,8 +2798,9 @@ static public String contentsToClassPath(File folder) {
27972798 * @param path the input classpath
27982799 * @return array of possible package names
27992800 */
2800- static public String [] packageListFromClassPath (String path ) {
2801- Map <String , Object > map = new HashMap <String , Object >();
2801+ static public StringList packageListFromClassPath (String path ) {
2802+ // Map<String, Object> map = new HashMap<String, Object>();
2803+ StringList list = new StringList ();
28022804 String pieces [] =
28032805 PApplet .split (path , File .pathSeparatorChar );
28042806
@@ -2809,32 +2811,35 @@ static public String[] packageListFromClassPath(String path) {
28092811 if (pieces [i ].toLowerCase ().endsWith (".jar" ) ||
28102812 pieces [i ].toLowerCase ().endsWith (".zip" )) {
28112813 //System.out.println("checking " + pieces[i]);
2812- packageListFromZip (pieces [i ], map );
2814+ packageListFromZip (pieces [i ], list );
28132815
28142816 } else { // it's another type of file or directory
28152817 File dir = new File (pieces [i ]);
28162818 if (dir .exists () && dir .isDirectory ()) {
2817- packageListFromFolder (dir , null , map );
2819+ packageListFromFolder (dir , null , list );
28182820 //importCount = magicImportsRecursive(dir, null,
28192821 // map);
28202822 //imports, importCount);
28212823 }
28222824 }
28232825 }
2824- int mapCount = map .size ();
2825- String output [] = new String [mapCount ];
2826- int index = 0 ;
2827- Set <String > set = map .keySet ();
2828- for (String s : set ) {
2829- output [index ++] = s .replace ('/' , '.' );
2826+ // int mapCount = map.size();
2827+ // String output[] = new String[mapCount];
2828+ // int index = 0;
2829+ // Set<String> set = map.keySet();
2830+ // for (String s : set) {
2831+ // output[index++] = s.replace('/', '.');
2832+ // }
2833+ // return output;
2834+ StringList outgoing = new StringList (list .size ());
2835+ for (String item : list ) {
2836+ outgoing .append (item .replace ('/' , '.' ));
28302837 }
2831- //System.arraycopy(imports, 0, output, 0, importCount);
2832- //PApplet.printarr(output);
2833- return output ;
2838+ return outgoing ;
28342839 }
28352840
28362841
2837- static private void packageListFromZip (String filename , Map < String , Object > map ) {
2842+ static private void packageListFromZip (String filename , StringList list ) {
28382843 try {
28392844 ZipFile file = new ZipFile (filename );
28402845 Enumeration entries = file .entries ();
@@ -2849,9 +2854,10 @@ static private void packageListFromZip(String filename, Map<String, Object> map)
28492854 if (slash == -1 ) continue ;
28502855
28512856 String pname = name .substring (0 , slash );
2852- if (map .get (pname ) == null ) {
2853- map .put (pname , new Object ());
2854- }
2857+ // if (map.get(pname) == null) {
2858+ // map.put(pname, new Object());
2859+ // }
2860+ list .appendUnique (pname );
28552861 }
28562862 }
28572863 }
@@ -2870,10 +2876,8 @@ static private void packageListFromZip(String filename, Map<String, Object> map)
28702876 * walk down into that folder and continue.
28712877 */
28722878 static private void packageListFromFolder (File dir , String sofar ,
2873- Map <String , Object > map ) {
2874- //String imports[],
2875- //int importCount) {
2876- //System.err.println("checking dir '" + dir + "'");
2879+ StringList list ) {
2880+ // Map<String, Object> map) {
28772881 boolean foundClass = false ;
28782882 String files [] = dir .list ();
28792883
@@ -2884,15 +2888,16 @@ static private void packageListFromFolder(File dir, String sofar,
28842888 if (sub .isDirectory ()) {
28852889 String nowfar =
28862890 (sofar == null ) ? files [i ] : (sofar + "." + files [i ]);
2887- packageListFromFolder (sub , nowfar , map );
2891+ packageListFromFolder (sub , nowfar , list );
28882892 //System.out.println(nowfar);
28892893 //imports[importCount++] = nowfar;
28902894 //importCount = magicImportsRecursive(sub, nowfar,
28912895 // imports, importCount);
28922896 } else if (!foundClass ) { // if no classes found in this folder yet
28932897 if (files [i ].endsWith (".class" )) {
28942898 //System.out.println("unique class: " + files[i] + " for " + sofar);
2895- map .put (sofar , new Object ());
2899+ // map.put(sofar, new Object());
2900+ list .appendUnique (sofar );
28962901 foundClass = true ;
28972902 }
28982903 }
0 commit comments