Changeset 7060 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2014-05-04T14:53:35+02:00 (10 years ago)
Author:
Don-vip
Message:

fix issue in bug report URL (regression from r7037), add javadoc and unit test

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

Legend:

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

    r6380 r7060  
    44import java.nio.ByteBuffer;
    55
     6/**
     7 * This class implements an encoder for encoding byte and character data using the
     8 * <a href="https://en.wikipedia.org/wiki/Base64">Base64</a> encoding scheme as specified in
     9 * <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a> ("base64", default) and
     10 * <a href="http://tools.ietf.org/html/rfc4648#section-4">RFC 4648</a> ("base64url").
     11 * @since 195
     12 */
    613public final class Base64 {
     14    // TODO: Remove this class when switching to Java 8 (finally integrated in Java SE as java.util.Base64.Encoder)
    715
    816    private Base64() {
     
    1018    }
    1119   
     20    /** "base64": RFC 2045 default encoding */
    1221    private static String encDefault = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
     22    /** "base64url": RFC 4648 url-safe encoding */
    1323    private static String encUrlSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
    1424
     25    /**
     26     * Encodes all characters from the specified string into a new String using the Base64 default encoding scheme.
     27     * @param s the string to encode
     28     * @return A new string containing the resulting encoded characters.
     29     */
    1530    public static String encode(String s) {
    1631        return encode(s, false);
    1732    }
    1833
     34    /**
     35     * Encodes all characters from the specified string into a new String using a supported Base64 encoding scheme.
     36     * @param s the string to encode
     37     * @param urlsafe if {@code true}, uses "base64url" encoding, otherwise use the "base64" default encoding
     38     * @return A new string containing the resulting encoded characters.
     39     * @since 3840
     40     */
    1941    public static String encode(String s, boolean urlsafe) {
    2042        StringBuilder out = new StringBuilder();
     
    3557    }
    3658
     59    /**
     60     * Encodes all remaining bytes from the specified byte buffer into a new string using the Base64 default encoding scheme.
     61     * Upon return, the source buffer's position will be updated to its limit; its limit will not have been changed.
     62     * @param s the source ByteBuffer to encode
     63     * @return A new string containing the resulting encoded characters.
     64     */
    3765    public static String encode(ByteBuffer s) {
    3866        return encode(s, false);
    3967    }
    4068
     69    /**
     70     * Encodes all remaining bytes from the specified byte buffer into a new string using a supported Base64 encoding scheme.
     71     * Upon return, the source buffer's position will be updated to its limit; its limit will not have been changed.
     72     * @param s the source ByteBuffer to encode
     73     * @param urlsafe if {@code true}, uses "base64url" encoding, otherwise use the "base64" default encoding
     74     * @return A new string containing the resulting encoded characters.
     75     * @since 3840
     76     */
    4177    public static String encode(ByteBuffer s, boolean urlsafe) {
    4278        StringBuilder out = new StringBuilder();
  • trunk/src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java

    r7037 r7060  
    216216        ) {
    217217            gzip.write(debugText.getBytes(Utils.UTF_8));
     218            gzip.finish();
    218219
    219220            return new URL(Main.getJOSMWebsite()+"/josmticket?" +
Note: See TracChangeset for help on using the changeset viewer.