Changeset 10137 in josm


Ignore:
Timestamp:
2016-04-10T23:53:54+02:00 (4 years ago)
Author:
Don-vip
Message:

sonar, javadoc

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/util/Entities.java

    r9970 r10137  
    3030 * @see <a href="http://www.w3.org/TR/html401/charset.html#h-5.3">HTML 4.01 Character References</a>
    3131 * @see <a href="http://www.w3.org/TR/html401/charset.html#code-position">HTML 4.01 Code positions</a>
     32 * @since 3669
    3233 */
    3334public final class Entities {
     
    340341    }
    341342
     343    /**
     344     * Returns unescaped entity representation.
     345     * @param str entity
     346     * @return unescaped entity representation
     347     */
    342348    public static String unescape(String str) {
    343349        int firstAmp = str.indexOf('&');
     
    357363                int amphersandIdx = str.indexOf('&', i + 1);
    358364                if (amphersandIdx != -1 && amphersandIdx < semiColonIdx) {
    359                     // Then the text looks like &...&...;
     365                    // Then the text looks like "&...&...;"
    360366                    res.append(c);
    361367                    continue;
     
    365371                int entityContentLen = entityContent.length();
    366372                if (entityContentLen > 0) {
    367                     if (entityContent.charAt(0) == '#') { // escaped value content is an integer (decimal or
    368                         // hexidecimal)
     373                    if (entityContent.charAt(0) == '#') { // escaped value content is an integer (decimal or hexidecimal)
    369374                        if (entityContentLen > 1) {
    370375                            char isHexChar = entityContent.charAt(1);
  • trunk/src/org/openstreetmap/josm/data/validation/util/MultipleNameVisitor.java

    r8873 r10137  
    1919public class MultipleNameVisitor extends NameVisitor {
    2020
     21    /**
     22     * Maximum displayed length, in characters.
     23     */
    2124    public static final int MULTIPLE_NAME_MAX_LENGTH = 80;
    2225
  • trunk/src/org/openstreetmap/josm/data/validation/util/NameVisitor.java

    r8509 r10137  
    1919 * @author imi
    2020 */
    21 //TODO This class used to be in JOSM but it was removed. MultipleNameVisitor depends on it so I copied it here,
    22 // but MultipleNameVisitor should be refactored instead of using this class
    2321public class NameVisitor extends AbstractVisitor {
    2422
     
    2725     */
    2826    public String className;
     27
     28    /**
     29     * The plural name of the item class
     30     */
    2931    public String classNamePlural;
     32
    3033    /**
    3134     * The name of this item.
    3235     */
    3336    public String name = "";
     37
    3438    /**
    3539     * The icon of this item.
     
    3842
    3943    /**
    40      * If the node has a name-key or id-key, this is displayed. If not, (lat,lon)
    41      * is displayed.
     44     * If the node has a name-key or id-key, this is displayed. If not, (lat,lon) is displayed.
    4245     */
    4346    @Override
     
    6972    }
    7073
     74    /**
     75     * Returns an horizontal {@code JLabel} with icon and name.
     76     * @return horizontal {@code JLabel} with icon and name
     77     */
    7178    public JLabel toLabel() {
    7279        return new JLabel(name, icon, JLabel.HORIZONTAL);
  • trunk/src/org/openstreetmap/josm/gui/help/HelpContentReader.java

    r9249 r10137  
    5151            }
    5252        } catch (MalformedURLException e) {
    53             throw new HelpContentReaderException(e);
     53            throw new HelpContentReaderException(e, 0);
    5454        } catch (IOException e) {
    55             HelpContentReaderException ex = new HelpContentReaderException(e);
    56             if (con != null) {
    57                 ex.setResponseCode(con.getResponseCode());
    58             }
    59             throw ex;
     55            throw new HelpContentReaderException(e, con != null ? con.getResponseCode() : 0);
    6056        }
    6157    }
     
    8177            s = readFromTrac(in, url);
    8278        } catch (IOException e) {
    83             throw new HelpContentReaderException(e);
     79            throw new HelpContentReaderException(e, 0);
    8480        }
    8581        if (dotest && s.isEmpty())
  • trunk/src/org/openstreetmap/josm/gui/help/HelpContentReaderException.java

    r10103 r10137  
    22package org.openstreetmap.josm.gui.help;
    33
     4/**
     5 * Exception thrown when a problem occurs during help contents fetching.
     6 * @since 2308
     7 */
    48public class HelpContentReaderException extends Exception {
    5     private int responseCode;
     9
     10    private final int responseCode;
    611
    712    /**
    813     * Constructs a new {@code HelpContentReaderException}.
    914     * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
     15     * @param responseCode HTTP response code related to the wiki access exception (0 if not applicable)
    1016     */
    11     public HelpContentReaderException(String message) {
     17    public HelpContentReaderException(String message, int responseCode) {
    1218        super(message);
     19        this.responseCode = responseCode;
    1320    }
    1421
     
    1724     * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method).
    1825     *        (A <tt>null</tt> value is permitted, and indicates that the cause is nonexistent or unknown.)
     26     * @param responseCode HTTP response code related to the wiki access exception (0 if not applicable)
    1927     */
    20     public HelpContentReaderException(Throwable cause) {
     28    public HelpContentReaderException(Throwable cause, int responseCode) {
    2129        super(cause);
     30        this.responseCode = responseCode;
    2231    }
    2332
     
    2837     * @return the http response code
    2938     */
    30     public int getResponseCode() {
     39    public final int getResponseCode() {
    3140        return responseCode;
    3241    }
    33 
    34     /**
    35      * Sets the HTTP response code
    36      *
    37      * @param responseCode the response code
    38      */
    39     public void setResponseCode(int responseCode) {
    40         this.responseCode = responseCode;
    41     }
    4242}
  • trunk/src/org/openstreetmap/josm/gui/help/Helpful.java

    r3083 r10137  
    22package org.openstreetmap.josm.gui.help;
    33
     4/**
     5 * Anything on which we can provide help.
     6 * @since 2252
     7 */
    48public interface Helpful {
     9
     10    /**
     11     * Returns the help topic on JOSM wiki for this feature.
     12     * @return the help topic on JOSM wiki for this feature
     13     */
    514    String helpTopic();
    615}
  • trunk/src/org/openstreetmap/josm/gui/help/MissingHelpContentException.java

    r10103 r10137  
    1313     */
    1414    public MissingHelpContentException(String message) {
    15         super(message);
     15        super(message, 0);
    1616    }
    1717}
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginListPanel.java

    r8836 r10137  
    7070
    7171    protected String formatPluginLocalVersion(PluginInformation pi) {
    72         if (pi == null) return tr("unknown");
     72        if (pi == null)
     73            return tr("unknown");
    7374        if (pi.localversion == null || pi.localversion.trim().isEmpty())
    7475            return tr("unknown");
     
    7778
    7879    protected String formatCheckboxTooltipText(PluginInformation pi) {
    79         if (pi == null) return "";
     80        if (pi == null)
     81            return "";
    8082        if (pi.downloadlink == null)
    8183            return tr("Plugin bundled with JOSM");
     
    107109    /**
    108110     * A plugin checkbox.
    109      *
    110111     */
    111112    private class JPluginCheckBox extends JCheckBox {
    112         public final transient PluginInformation pi;
     113        protected final transient PluginInformation pi;
    113114
    114115        JPluginCheckBox(final PluginInformation pi, boolean selected) {
     
    122123    /**
    123124     * Listener called when the user selects/unselects a plugin checkbox.
    124      *
    125125     */
    126126    private class PluginCbActionListener implements ActionListener {
     
    172172    }
    173173
    174 
    175174    /**
    176175     * Alerts the user if an unselected plugin is still required by another plugins
     
    181180     */
    182181    private static void alertPluginStillRequired(Component parent, String plugin, Set<String> otherPlugins) {
    183         StringBuilder sb = new StringBuilder();
    184         sb.append("<html>")
     182        StringBuilder sb = new StringBuilder("<html>")
    185183          .append(trn("Plugin {0} is still required by this plugin:",
    186184                "Plugin {0} is still required by these {1} plugins:",
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java

    r10035 r10137  
    270270        if (answer != 0 /* OK */)
    271271            return;
    272         List<String> sites = pnl.getUpdateSites();
    273         Main.pref.setPluginSites(sites);
     272        Main.pref.setPluginSites(pnl.getUpdateSites());
    274273    }
    275274
     
    497496
    498497    /**
    499      * Applies the current filter condition in the filter text field to the
    500      * model
     498     * Applies the current filter condition in the filter text field to the model.
    501499     */
    502500    class SearchFieldAdapter implements DocumentListener {
    503         public void filter() {
     501        private void filter() {
    504502            String expr = tfFilter.getText().trim();
    505503            if (expr.isEmpty()) {
     
    597595        }
    598596
    599         public List<String> getUpdateSites() {
     597        protected List<String> getUpdateSites() {
    600598            if (model.getSize() == 0)
    601599                return Collections.emptyList();
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java

    r9543 r10137  
    4343 *
    4444 * For initial authorisation see {@link OAuthAuthorizationWizard}.
    45  *
     45 * @since 2745
    4646 */
    4747public class OAuthAuthenticationPreferencesPanel extends JPanel implements PropertyChangeListener {
     
    5353    private JCheckBox cbShowAdvancedParameters;
    5454    private JCheckBox cbSaveToPreferences;
     55
     56    /**
     57     * Create the panel
     58     */
     59    public OAuthAuthenticationPreferencesPanel() {
     60        build();
     61        refreshView();
     62    }
    5563
    5664    /**
     
    140148
    141149    /**
    142      * Create the panel
    143      */
    144     public OAuthAuthenticationPreferencesPanel() {
    145         build();
    146         refreshView();
    147     }
    148 
    149     /**
    150150     * Sets the URL of the OSM API for which this panel is currently displaying OAuth properties.
    151151     *
     
    224224        private JosmTextField tfAccessTokenSecret;
    225225
     226        /**
     227         * Constructs a new {@code AlreadyAuthorisedPanel}.
     228         */
     229        AlreadyAuthorisedPanel() {
     230            build();
     231            refreshView();
     232        }
     233
    226234        protected void build() {
    227235            setLayout(new GridBagLayout());
     
    291299            gc.weighty = 1.0;
    292300            add(new JPanel(), gc);
    293 
    294         }
    295 
    296         public final void refreshView() {
     301        }
     302
     303        protected final void refreshView() {
    297304            String v = OAuthAccessTokenHolder.getInstance().getAccessTokenKey();
    298305            tfAccessTokenKey.setText(v == null ? "" : v);
     
    300307            tfAccessTokenSecret.setText(v == null ? "" : v);
    301308            cbSaveToPreferences.setSelected(OAuthAccessTokenHolder.getInstance().isSaveToPreferences());
    302         }
    303 
    304         /**
    305          * Constructs a new {@code AlreadyAuthorisedPanel}.
    306          */
    307         AlreadyAuthorisedPanel() {
    308             build();
    309             refreshView();
    310309        }
    311310    }
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/OsmApiUrlInputPanel.java

    r9694 r10137  
    6161    private transient ApiUrlPropagator propagator;
    6262
     63    /**
     64     * Constructs a new {@code OsmApiUrlInputPanel}.
     65     */
     66    public OsmApiUrlInputPanel() {
     67        build();
     68        HelpUtil.setHelpContext(this, HelpUtil.ht("/Preferences/Connection#ApiUrl"));
     69    }
     70
    6371    protected JComponent buildDefaultServerUrlPanel() {
    6472        cbUseDefaultServerUrl = new JCheckBox(tr("<html>Use the default OSM server URL (<strong>{0}</strong>)</html>", OsmApi.DEFAULT_API_URL));
     
    109117        tfOsmServerUrl.getEditorComponent().getDocument().addDocumentListener(actTest);
    110118        add(btnTest = new SideButton(actTest), gc);
    111     }
    112 
    113     /**
    114      * Constructs a new {@code OsmApiUrlInputPanel}.
    115      */
    116     public OsmApiUrlInputPanel() {
    117         build();
    118         HelpUtil.setHelpContext(this, HelpUtil.ht("/Preferences/Connection#ApiUrl"));
    119119    }
    120120
     
    152152        String newUrl = OsmApi.getOsmApi().getServerUrl();
    153153
    154         // When API URL changes, re-initialize API connection so we may adjust
    155         // server-dependent settings.
     154        // When API URL changes, re-initialize API connection so we may adjust server-dependent settings.
    156155        if (!oldUrl.equals(newUrl)) {
    157156            try {
     
    303302
    304303    class ApiUrlPropagator extends FocusAdapter implements ActionListener {
    305         public void propagate() {
     304        protected void propagate() {
    306305            propagate(getStrippedApiUrl());
    307306        }
    308307
    309         public void propagate(String url) {
     308        protected void propagate(String url) {
    310309            firePropertyChange(API_URL_PROP, null, url);
    311310        }
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionItemPriority.java

    r9231 r10137  
    77 *
    88 * Instances of this class are not modifiable.
     9 * @since 1762
    910 */
    1011public class AutoCompletionItemPriority implements Comparable<AutoCompletionItemPriority> {
     
    4445    private final boolean selected;
    4546
    46 
    4747    /**
    48      * Create new AutoCompletionItemPriority object.
     48     * Constructs a new {@code AutoCompletionItemPriority}.
    4949     *
    5050     * @param inDataSet true, if the item is found in the currently active data layer
    51      * @param inStandard true, if the item is a standard tag, e.g. from the presets.
     51     * @param inStandard true, if the item is a standard tag, e.g. from the presets
    5252     * @param selected true, if it is found on an object that is currently selected
    5353     * @param userInput null, if the user hasn't entered this tag so far. A number when
     
    6262    }
    6363
     64    /**
     65     * Constructs a new {@code AutoCompletionItemPriority}.
     66     *
     67     * @param inDataSet true, if the item is found in the currently active data layer
     68     * @param inStandard true, if the item is a standard tag, e.g. from the presets
     69     * @param selected true, if it is found on an object that is currently selected
     70     */
    6471    public AutoCompletionItemPriority(boolean inDataSet, boolean inStandard, boolean selected) {
    6572        this(inDataSet, inStandard, selected, NO_USER_INPUT);
    6673    }
    6774
     75    /**
     76     * Determines if the item is found in the currently active data layer.
     77     * @return {@code true} if the item is found in the currently active data layer
     78     */
    6879    public boolean isInDataSet() {
    6980        return inDataSet;
    7081    }
    7182
     83    /**
     84     * Determines if the item is a standard tag, e.g. from the presets.
     85     * @return {@code true} if the item is a standard tag, e.g. from the presets
     86     */
    7287    public boolean isInStandard() {
    7388        return inStandard;
    7489    }
    7590
     91    /**
     92     * Determines if it is found on an object that is currently selected.
     93     * @return {@code true} if it is found on an object that is currently selected
     94     */
    7695    public boolean isSelected() {
    7796        return selected;
    7897    }
    7998
     99    /**
     100     * Returns a number when the tag key / value has been entered by the user before.
     101     * A lower number means this happened more recently and beats a higher number in priority.
     102     * @return a number when the tag key / value has been entered by the user before.
     103     *         {@code null}, if the user hasn't entered this tag so far.
     104     */
    80105    public Integer getUserInput() {
    81106        return userInput == NO_USER_INPUT ? null : userInput;
     
    89114    public int compareTo(AutoCompletionItemPriority other) {
    90115        int ui = Integer.compare(other.userInput, userInput);
    91         if (ui != 0) return ui;
     116        if (ui != 0)
     117            return ui;
    92118
    93119        int sel = Boolean.valueOf(selected).compareTo(other.selected);
    94         if (sel != 0) return sel;
     120        if (sel != 0)
     121            return sel;
    95122
    96123        int ds = Boolean.valueOf(inDataSet).compareTo(other.inDataSet);
    97         if (ds != 0) return ds;
     124        if (ds != 0)
     125            return ds;
    98126
    99127        int std = Boolean.valueOf(inStandard).compareTo(other.inStandard);
    100         if (std != 0) return std;
     128        if (std != 0)
     129            return std;
    101130
    102131        return 0;
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionList.java

    r9078 r10137  
    2828 * AutoCompletionList is an {@link AbstractTableModel} which serves the list of filtered
    2929 * items to a {@link JTable}.
    30  *
     30 * @since 1762
    3131 */
    3232public class AutoCompletionList extends AbstractTableModel {
     
    6767    /**
    6868     * clears the current filter
    69      *
    7069     */
    7170    public void clearFilter() {
     
    135134     */
    136135    public void add(Collection<String> values, AutoCompletionItemPriority priority) {
    137         if (values == null) return;
    138         for (String value: values) {
     136        if (values == null)
     137            return;
     138        for (String value : values) {
    139139            if (value == null) {
    140140                continue;
     
    148148    }
    149149
     150    /**
     151     * Adds values that have been entered by the user.
     152     * @param values values that have been entered by the user
     153     */
    150154    public void addUserInput(Collection<String> values) {
    151         if (values == null) return;
     155        if (values == null)
     156            return;
    152157        int i = 0;
    153         for (String value: values) {
    154             if (value == null) {
    155                 continue;
    156             }
    157             AutoCompletionListItem item = new AutoCompletionListItem(value, new AutoCompletionItemPriority(false, false, false, i));
    158             appendOrUpdatePriority(item);
    159             i++;
     158        for (String value : values) {
     159            if (value != null) {
     160                appendOrUpdatePriority(
     161                        new AutoCompletionListItem(value, new AutoCompletionItemPriority(false, false, false, i++)));
     162            }
    160163        }
    161164        sort();
Note: See TracChangeset for help on using the changeset viewer.