Changeset 9498 in josm for trunk/src


Ignore:
Timestamp:
2016-01-17T05:29:59+01:00 (4 years ago)
Author:
Don-vip
Message:

add unit tests, code cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java

    r9402 r9498  
    6464public final class CustomConfigurator {
    6565
     66    private static StringBuilder summary = new StringBuilder();
     67
    6668    private CustomConfigurator() {
    6769        // Hide default constructor for utils classes
    6870    }
    6971
    70     private static StringBuilder summary = new StringBuilder();
    71 
     72    /**
     73     * Log a formatted message.
     74     * @param fmt format
     75     * @param vars arguments
     76     * @see String#format
     77     */
    7278    public static void log(String fmt, Object... vars) {
    7379        summary.append(String.format(fmt, vars));
    7480    }
    7581
     82    /**
     83     * Log a message.
     84     * @param s message to log
     85     */
    7686    public static void log(String s) {
    7787        summary.append(s);
     
    7989    }
    8090
     91    /**
     92     * Returns the log.
     93     * @return the log
     94     */
    8195    public static String getLog() {
    8296        return summary.toString();
     
    122136
    123137    /**
    124      * Downloads file to one of JOSM standard folders nad unpack it as ZIP/JAR file
     138     * Downloads file to one of JOSM standard folders and unpack it as ZIP/JAR file
    125139     * @param address - URL to download
    126140     * @param path - file path relative to base where to put downloaded file
     
    223237        Map<String, Setting<?>> allSettings = Main.pref.getAllSettings();
    224238        for (String key: allSettings.keySet()) {
    225             if (key.matches(pattern)) keySet.add(key);
     239            if (key.matches(pattern))
     240                keySet.add(key);
    226241        }
    227242        exportPreferencesKeysToFile(fileName, append, keySet);
     
    253268            Main.warn("Error getting preferences to save:" +ex.getMessage());
    254269        }
    255         if (root == null) return;
     270        if (root == null)
     271            return;
    256272        try {
    257 
    258273            Element newRoot = exportDocument.createElement("config");
    259274            exportDocument.appendChild(newRoot);
     
    459474            try {
    460475                this.mainPrefs = mainPrefs;
    461                 CustomConfigurator.summary = new StringBuilder();
     476                summary = new StringBuilder();
    462477                engine = new ScriptEngineManager().getEngineByName("rhino");
    463478                engine.eval("API={}; API.pref={}; API.fragments={};");
     
    482497
    483498        private void processXML(Document document) {
    484             Element root = document.getDocumentElement();
    485             processXmlFragment(root);
     499            processXmlFragment(document.getDocumentElement());
    486500        }
    487501
     
    10271041
    10281042        for (Entry<String, List<Collection<String>>> e : listlistMap.entrySet()) {
    1029             @SuppressWarnings("unchecked")
     1043            @SuppressWarnings({ "unchecked", "rawtypes" })
    10301044            List<List<String>> value = (List) e.getValue();
    10311045            tmp.put(e.getKey(), new ListListSetting(value));
     
    11491163            "}\n";
    11501164
    1151         // Execute conversion script
    1152         engine.eval(init);
    1153     }
     1165            // Execute conversion script
     1166            engine.eval(init);
     1167        }
    11541168    }
    11551169}
Note: See TracChangeset for help on using the changeset viewer.