Ignore:
Timestamp:
2015-09-13T22:45:59+02:00 (6 years ago)
Author:
simon04
Message:

fix #10023 - Add history of Overpass queries

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java

    r8513 r8756  
    236236                    "<html>Uploading to the server <strong>failed</strong> because your current<br>"
    237237                    + "dataset violates a precondition.<br>" + "The error message is:<br>" + "{0}" + "</html>",
    238                     escapeReservedCharactersHTML(e.getMessage()));
     238                    Utils.escapeReservedCharactersHTML(e.getMessage()));
    239239        }
    240240    }
     
    424424        }
    425425        Main.error(e);
    426         return escapeReservedCharactersHTML(msg);
     426        return Utils.escapeReservedCharactersHTML(msg);
    427427    }
    428428
     
    691691                + "<br>"
    692692                + "The error message is:<br>" + "{0}"
    693                 + "</html>", escapeReservedCharactersHTML(e.getMessage()));
     693                + "</html>", Utils.escapeReservedCharactersHTML(e.getMessage()));
    694694    }
    695695
     
    709709    }
    710710
    711     /**
    712      * Replaces some HTML reserved characters (&lt;, &gt; and &amp;) by their equivalent entity (&amp;lt;, &amp;gt; and &amp;amp;);
    713      * @param s The unescaped string
    714      * @return The escaped string
    715      */
    716     public static String escapeReservedCharactersHTML(String s) {
    717         return s == null ? "" : s.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;");
    718     }
    719711}
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r8734 r8756  
    646646
    647647    /**
     648     * Replaces some HTML reserved characters (&lt;, &gt; and &amp;) by their equivalent entity (&amp;lt;, &amp;gt; and &amp;amp;);
     649     * @param s The unescaped string
     650     * @return The escaped string
     651     */
     652    public static String escapeReservedCharactersHTML(String s) {
     653        return s == null ? "" : s.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;");
     654    }
     655
     656    /**
    648657     * Represents a function that can be applied to objects of {@code A} and
    649658     * returns objects of {@code B}.
     
    11841193        } else {
    11851194            return s;
     1195        }
     1196    }
     1197
     1198    /**
     1199     * If the string {@code s} is longer than {@code maxLines} lines, the string is cut and a "..." line is appended.
     1200     * @param s String to shorten
     1201     * @param maxLines maximum number of lines to keep (including including the "..." line)
     1202     * @return the shortened string
     1203     */
     1204    public static String restrictStringLines(String s, int maxLines) {
     1205        if (s == null) {
     1206            return null;
     1207        } else {
     1208            final List<String> lines = Arrays.asList(s.split("\\n"));
     1209            if (lines.size() > maxLines) {
     1210                return join("\n", lines.subList(0, maxLines - 1)) + "\n" + "...";
     1211            } else {
     1212                return s;
     1213            }
    11861214        }
    11871215    }
Note: See TracChangeset for help on using the changeset viewer.