Changeset 9717 in josm for trunk/src/org
- Timestamp:
- 2016-02-02T23:13:51+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r9715 r9717 662 662 * Get the directory where cached content of any kind should be stored. 663 663 * 664 * If the directory doesn't exist on the file system, it will be created 665 * by this method. 664 * If the directory doesn't exist on the file system, it will be created by this method. 666 665 * 667 666 * @return the cache directory … … 737 736 * Get settings value for a certain key. 738 737 * @param key the identifier for the setting 739 * @return "" if there is nothing set for the preference key, 740 * the corresponding value otherwise. The result is not null. 738 * @return "" if there is nothing set for the preference key, the corresponding value otherwise. The result is not null. 741 739 */ 742 740 public synchronized String get(final String key) { … … 748 746 * Get settings value for a certain key and provide default a value. 749 747 * @param key the identifier for the setting 750 * @param def the default value. For each call of get() with a given key, the 751 * default value must be the same. 752 * @return the corresponding value if the property has been set before, 753 * def otherwise 748 * @param def the default value. For each call of get() with a given key, the default value must be the same. 749 * @return the corresponding value if the property has been set before, {@code def} otherwise 754 750 */ 755 751 public synchronized String get(final String key, final String def) { … … 817 813 * Set a value for a certain setting. 818 814 * @param key the unique identifier for the setting 819 * @param value the value of the setting. Can be null or "" which both removes 820 * the key-value entry. 815 * @param value the value of the setting. Can be null or "" which both removes the key-value entry. 821 816 * @return {@code true}, if something has changed (i.e. value is different than before) 822 817 */ … … 1146 1141 * @param key the identifier for the setting 1147 1142 * @param def the default value. 1148 * @return the corresponding value if the property has been set before, 1149 * def otherwise 1143 * @return the corresponding value if the property has been set before, {@code def} otherwise 1150 1144 */ 1151 1145 public Collection<String> getCollection(String key, Collection<String> def) { … … 1156 1150 * Get a list of values for a certain key 1157 1151 * @param key the identifier for the setting 1158 * @return the corresponding value if the property has been set before, 1159 * an empty Collection otherwise. 1152 * @return the corresponding value if the property has been set before, an empty collection otherwise. 1160 1153 */ 1161 1154 public Collection<String> getCollection(String key) { … … 1171 1164 1172 1165 /** 1173 * Set a value for a certain setting. The changed setting is saved 1174 * to the preference file immediately. Due to caching mechanisms on modern 1175 * operating systems and hardware, this shouldn't be a performance problem. 1166 * Set a value for a certain setting. The changed setting is saved to the preference file immediately. 1167 * Due to caching mechanisms on modern operating systems and hardware, this shouldn't be a performance problem. 1176 1168 * @param key the unique identifier for the setting 1177 * @param setting the value of the setting. In case it is null, the key-value 1178 * entry will be removed. 1169 * @param setting the value of the setting. In case it is null, the key-value entry will be removed. 1179 1170 * @return {@code true}, if something has changed (i.e. value is different than before) 1180 1171 */ … … 1220 1211 * @param <T> the setting type 1221 1212 * @param key the identifier for the setting 1222 * @param def the default value. For each call of getSetting() with a given 1223 * key, the default value must be the same. <code>def</code> must not be 1224 * null, but the value of <code>def</code> can be null. 1213 * @param def the default value. For each call of getSetting() with a given key, the default value must be the same. 1214 * <code>def</code> must not be null, but the value of <code>def</code> can be null. 1225 1215 * @param klass the setting type (same as T) 1226 * @return the corresponding value if the property has been set before, 1227 * def otherwise 1216 * @return the corresponding value if the property has been set before, {@code def} otherwise 1228 1217 */ 1229 1218 @SuppressWarnings("unchecked") … … 1312 1301 /** 1313 1302 * Annotation used for converting objects to String Maps and vice versa. 1314 * Indicates that a certain field should be considered in the conversion 1315 * process. Otherwise it is ignored. 1303 * Indicates that a certain field should be considered in the conversion process. Otherwise it is ignored. 1316 1304 * 1317 1305 * @see #serializeStruct(java.lang.Object, java.lang.Class) … … 1323 1311 /** 1324 1312 * Annotation used for converting objects to String Maps. 1325 * Indicates that a certain field should be written to the map, even if 1326 * the value is the same as the default value. 1313 * Indicates that a certain field should be written to the map, even if the value is the same as the default value. 1327 1314 * 1328 1315 * @see #serializeStruct(java.lang.Object, java.lang.Class) … … 1333 1320 /** 1334 1321 * Get a list of hashes which are represented by a struct-like class. 1335 * Possible properties are given by fields of the class klass that have 1336 * the @pref annotation. 1337 * Default constructor is used to initialize the struct objects, properties 1338 * then override some of these default values. 1322 * Possible properties are given by fields of the class klass that have the @pref annotation. 1323 * Default constructor is used to initialize the struct objects, properties then override some of these default values. 1339 1324 * @param <T> klass type 1340 1325 * @param key main preference key … … 1372 1357 1373 1358 /** 1374 * Convenience method that saves a MapListSetting which is provided as a 1375 * Collection of objects. 1359 * Convenience method that saves a MapListSetting which is provided as a collection of objects. 1376 1360 * 1377 * Each object is converted to a <code>Map<String, String></code> using 1378 * the fields with {@link pref} annotation. The field name is the key and 1379 * the value will be converted to a string. 1361 * Each object is converted to a <code>Map<String, String></code> using the fields with {@link pref} annotation. 1362 * The field name is the key and the value will be converted to a string. 1380 1363 * 1381 1364 * Considers only fields that have the @pref annotation. 1382 1365 * In addition it does not write fields with null values. (Thus they are cleared) 1383 * Default values are given by the field values after default constructor has 1384 * been called. 1385 * Fields equal to the default value are not written unless the field has 1386 * the @writeExplicitly annotation. 1366 * Default values are given by the field values after default constructor has been called. 1367 * Fields equal to the default value are not written unless the field has the @writeExplicitly annotation. 1387 1368 * @param <T> the class, 1388 1369 * @param key main preference key … … 1457 1438 1458 1439 /** 1459 * Convert an object to a String Map, by using field names and values as map 1460 * key and value. 1440 * Convert an object to a String Map, by using field names and values as map key and value. 1461 1441 * 1462 1442 * The field value is converted to a String. … … 1466 1446 * Fields will not be written to the map if the value is null or unchanged 1467 1447 * (compared to an object created with the no-arg-constructor). 1468 * The {@link writeExplicitly} annotation overrides this behavior, i.e. the 1469 * default value will also be written. 1448 * The {@link writeExplicitly} annotation overrides this behavior, i.e. the default value will also be written. 1470 1449 * 1471 1450 * @param <T> the class of the object <code>struct</code> … … 1509 1488 1510 1489 /** 1511 * Converts a String-Map to an object of a certain class, by comparing 1512 * map keys to field names of the class and assigning map values to the 1513 * corresponding fields. 1490 * Converts a String-Map to an object of a certain class, by comparing map keys to field names of the class and assigning 1491 * map values to the corresponding fields. 1514 1492 * 1515 * The map value (a String) is converted to the field type. Supported 1516 * types are: boolean, Boolean, int, Integer, double, Double, String, 1517 * Map<String, String> and Map<String, List<String>>. 1493 * The map value (a String) is converted to the field type. Supported types are: boolean, Boolean, int, Integer, double, 1494 * Double, String, Map<String, String> and Map<String, List<String>>. 1518 1495 * 1519 1496 * Only fields with annotation {@link pref} are taken into account. … … 1589 1566 */ 1590 1567 public void updateSystemProperties() { 1591 if ("true".equals(get("prefer.ipv6", "auto")) ) {1568 if ("true".equals(get("prefer.ipv6", "auto")) && !"true".equals(Utils.updateSystemProperty("java.net.preferIPv6Addresses", "true"))) { 1592 1569 // never set this to false, only true! 1593 if (!"true".equals(Utils.updateSystemProperty("java.net.preferIPv6Addresses", "true"))) { 1594 Main.info(tr("Try enabling IPv6 network, prefering IPv6 over IPv4 (only works on early startup).")); 1595 } 1570 Main.info(tr("Try enabling IPv6 network, prefering IPv6 over IPv4 (only works on early startup).")); 1596 1571 } 1597 1572 Utils.updateSystemProperty("http.agent", Version.getInstance().getAgentString()); 1598 1573 Utils.updateSystemProperty("user.language", get("language")); 1599 // Workaround to fix a Java bug. 1574 // Workaround to fix a Java bug. This ugly hack comes from Sun bug database: https://bugs.openjdk.java.net/browse/JDK-6292739 1600 1575 // Force AWT toolkit to update its internal preferences (fix #6345). 1601 // This ugly hack comes from Sun bug database: https://bugs.openjdk.java.net/browse/JDK-62927391602 1576 if (!GraphicsEnvironment.isHeadless()) { 1603 1577 try { … … 1620 1594 Utils.updateSystemProperty("jsse.enableSNIExtension", "false"); 1621 1595 } 1622 // Workaround to fix another Java bug 1596 // Workaround to fix another Java bug - The bug seems to have been fixed in Java 8, to remove during transition 1623 1597 // Force Java 7 to use old sorting algorithm of Arrays.sort (fix #8712). 1624 1598 // See Oracle bug database: https://bugs.openjdk.java.net/browse/JDK-7075600 1625 1599 // and https://bugs.openjdk.java.net/browse/JDK-6923200 1626 // The bug seems to have been fixed in Java 8, to remove during transition1627 1600 if (getBoolean("jdk.Arrays.useLegacyMergeSort", !Version.getInstance().isLocalBuild())) { 1628 1601 Utils.updateSystemProperty("java.util.Arrays.useLegacyMergeSort", "true"); … … 1669 1642 1670 1643 public static void validateXML(Reader in) throws IOException, SAXException { 1671 SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);1672 1644 try (InputStream xsdStream = new CachedFile("resource://data/preferences.xsd").getInputStream()) { 1673 Schema schema = factory.newSchema(new StreamSource(xsdStream));1645 Schema schema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(new StreamSource(xsdStream)); 1674 1646 Validator validator = schema.newValidator(); 1675 1647 validator.validate(new StreamSource(in)); … … 1678 1650 1679 1651 protected void fromXML(Reader in) throws XMLStreamException { 1680 XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(in); 1681 this.parser = parser; 1652 this.parser = XMLInputFactory.newInstance().createXMLStreamReader(in); 1682 1653 parse(); 1683 1654 } … … 1968 1939 List<Map<String, String>> l = new LinkedList<>(); 1969 1940 boolean modified = false; 1970 for (Map<String, String> map: ((MapListSetting) setting).getValue()) {1941 for (Map<String, String> map: ((MapListSetting) setting).getValue()) { 1971 1942 Map<String, String> newMap = new HashMap<>(); 1972 1943 for (Entry<String, String> entry: map.entrySet()) { -
trunk/src/org/openstreetmap/josm/tools/OverpassTurboQueryWizard.java
r9704 r9717 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.tools; 3 4 import org.openstreetmap.josm.Main;5 3 6 4 import java.io.IOException; … … 14 12 import javax.script.ScriptEngineManager; 15 13 import javax.script.ScriptException; 14 15 import org.openstreetmap.josm.Main; 16 16 17 17 /** … … 59 59 try { 60 60 final Object result = ((Invocable) engine).invokeMethod(engine.get("global"), 61 "overpassWizard", search, new HashMap<String, Object>() { {61 "overpassWizard", search, new HashMap<String, Object>() { { 62 62 put("comment", false); 63 63 put("outputFormat", "xml"); 64 64 put("outputMode", "recursive_meta"); 65 }}); 65 } } 66 ); 66 67 if (result == Boolean.FALSE) { 67 68 throw new UncheckedParseException();
Note:
See TracChangeset
for help on using the changeset viewer.