Changeset 9717 in josm for trunk/src/org


Ignore:
Timestamp:
2016-02-02T23:13:51+01:00 (9 years ago)
Author:
Don-vip
Message:

checkstyle

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

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

    r9715 r9717  
    662662     * Get the directory where cached content of any kind should be stored.
    663663     *
    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.
    666665     *
    667666     * @return the cache directory
     
    737736     * Get settings value for a certain key.
    738737     * @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.
    741739     */
    742740    public synchronized String get(final String key) {
     
    748746     * Get settings value for a certain key and provide default a value.
    749747     * @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
    754750     */
    755751    public synchronized String get(final String key, final String def) {
     
    817813     * Set a value for a certain setting.
    818814     * @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.
    821816     * @return {@code true}, if something has changed (i.e. value is different than before)
    822817     */
     
    11461141     * @param key the identifier for the setting
    11471142     * @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
    11501144     */
    11511145    public Collection<String> getCollection(String key, Collection<String> def) {
     
    11561150     * Get a list of values for a certain key
    11571151     * @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.
    11601153     */
    11611154    public Collection<String> getCollection(String key) {
     
    11711164
    11721165    /**
    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.
    11761168     * @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.
    11791170     * @return {@code true}, if something has changed (i.e. value is different than before)
    11801171     */
     
    12201211     * @param <T> the setting type
    12211212     * @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.
    12251215     * @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
    12281217     */
    12291218    @SuppressWarnings("unchecked")
     
    13121301    /**
    13131302     * 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.
    13161304     *
    13171305     * @see #serializeStruct(java.lang.Object, java.lang.Class)
     
    13231311    /**
    13241312     * 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.
    13271314     *
    13281315     * @see #serializeStruct(java.lang.Object, java.lang.Class)
     
    13331320    /**
    13341321     * 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.
    13391324     * @param <T> klass type
    13401325     * @param key main preference key
     
    13721357
    13731358    /**
    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.
    13761360     *
    1377      * Each object is converted to a <code>Map&lt;String, String&gt;</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&lt;String, String&gt;</code> using the fields with {@link pref} annotation.
     1362     * The field name is the key and the value will be converted to a string.
    13801363     *
    13811364     * Considers only fields that have the @pref annotation.
    13821365     * 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.
    13871368     * @param <T> the class,
    13881369     * @param key main preference key
     
    14571438
    14581439    /**
    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.
    14611441     *
    14621442     * The field value is converted to a String.
     
    14661446     * Fields will not be written to the map if the value is null or unchanged
    14671447     * (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.
    14701449     *
    14711450     * @param <T> the class of the object <code>struct</code>
     
    15091488
    15101489    /**
    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.
    15141492     *
    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&lt;String, String&gt; and Map&lt;String, List&lt;String&gt;&gt;.
     1493     * The map value (a String) is converted to the field type. Supported types are: boolean, Boolean, int, Integer, double,
     1494     * Double, String, Map&lt;String, String&gt; and Map&lt;String, List&lt;String&gt;&gt;.
    15181495     *
    15191496     * Only fields with annotation {@link pref} are taken into account.
     
    15891566     */
    15901567    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"))) {
    15921569            // 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)."));
    15961571        }
    15971572        Utils.updateSystemProperty("http.agent", Version.getInstance().getAgentString());
    15981573        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
    16001575        // 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-6292739
    16021576        if (!GraphicsEnvironment.isHeadless()) {
    16031577            try {
     
    16201594            Utils.updateSystemProperty("jsse.enableSNIExtension", "false");
    16211595        }
    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
    16231597        // Force Java 7 to use old sorting algorithm of Arrays.sort (fix #8712).
    16241598        // See Oracle bug database: https://bugs.openjdk.java.net/browse/JDK-7075600
    16251599        // and https://bugs.openjdk.java.net/browse/JDK-6923200
    1626         // The bug seems to have been fixed in Java 8, to remove during transition
    16271600        if (getBoolean("jdk.Arrays.useLegacyMergeSort", !Version.getInstance().isLocalBuild())) {
    16281601            Utils.updateSystemProperty("java.util.Arrays.useLegacyMergeSort", "true");
     
    16691642
    16701643    public static void validateXML(Reader in) throws IOException, SAXException {
    1671         SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    16721644        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));
    16741646            Validator validator = schema.newValidator();
    16751647            validator.validate(new StreamSource(in));
     
    16781650
    16791651    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);
    16821653        parse();
    16831654    }
     
    19681939                List<Map<String, String>> l = new LinkedList<>();
    19691940                boolean modified = false;
    1970                 for (Map<String, String> map: ((MapListSetting)setting).getValue()) {
     1941                for (Map<String, String> map: ((MapListSetting) setting).getValue()) {
    19711942                    Map<String, String> newMap = new HashMap<>();
    19721943                    for (Entry<String, String> entry: map.entrySet()) {
  • trunk/src/org/openstreetmap/josm/tools/OverpassTurboQueryWizard.java

    r9704 r9717  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.tools;
    3 
    4 import org.openstreetmap.josm.Main;
    53
    64import java.io.IOException;
     
    1412import javax.script.ScriptEngineManager;
    1513import javax.script.ScriptException;
     14
     15import org.openstreetmap.josm.Main;
    1616
    1717/**
     
    5959        try {
    6060            final Object result = ((Invocable) engine).invokeMethod(engine.get("global"),
    61                     "overpassWizard", search, new HashMap<String, Object>() {{
     61                    "overpassWizard", search, new HashMap<String, Object>() { {
    6262                        put("comment", false);
    6363                        put("outputFormat", "xml");
    6464                        put("outputMode", "recursive_meta");
    65                     }});
     65                    } }
     66            );
    6667            if (result == Boolean.FALSE) {
    6768                throw new UncheckedParseException();
Note: See TracChangeset for help on using the changeset viewer.