@@ -0,0 +1,2473 @@
+package me.izstas.rfs.client.util;%0A%0Aimport java.text.DateFormat;%0Aimport java.util.Date;%0A%0Aimport me.izstas.rfs.model.Attributes;%0Aimport me.izstas.rfs.model.DosAttributes;%0Aimport me.izstas.rfs.model.PosixAttributes;%0A%0A/**%0A * An utility class with static methods for formatting various values.%0A */%0Apublic final class FormatUtil %7B%0A    /**%0A     * Formats a file size.%0A     * @param size the file size in bytes%0A     * @return formatted file size, e.g. 1 KB, 2 MB, etc%0A     */%0A    public static String formatSize(Long size) %7B%0A        if (size == null) %7B%0A            return null;%0A        %7D%0A%0A        // Based on code by aioobe, http://stackoverflow.com/a/3758880%0A        int unit = 1024;%0A        if (size %3C unit) %7B%0A            return String.format(%22%25d B%22, size);%0A        %7D%0A%0A        int exp = (int) (Math.log(size) / Math.log(unit));%0A        return String.format(%22%25.2f %25cB%22, size / Math.pow(unit, exp), %22KMGTPE%22.charAt(exp - 1));%0A    %7D%0A%0A    /**%0A     * Formats a date.%0A     * @param date the date%0A     * @return formatted date%0A     */%0A    public static String formatDate(Date date) %7B%0A        if (date == null) %7B%0A            return null;%0A        %7D%0A%0A        return DateFormat.getDateTimeInstance().format(date);%0A    %7D%0A%0A    /**%0A     * Formats file attributes.%0A     * @param attributes the attributes%0A     * @return string representation of the attributes%0A     */%0A    public static String formatAttributes(Attributes attributes) %7B%0A        if (attributes instanceof PosixAttributes) %7B%0A            return formatPosixAttributes((PosixAttributes) attributes);%0A        %7D%0A%0A        if (attributes instanceof DosAttributes) %7B%0A            return formatDosAttributes((DosAttributes) attributes);%0A        %7D%0A%0A        return null;%0A    %7D%0A%0A    private static String formatPosixAttributes(PosixAttributes attributes) %7B%0A        return String.format(%22%25s:%25s %25s%22, attributes.getUser(), attributes.getGroup(), attributes.getPermissions());%0A    %7D%0A%0A    private static String formatDosAttributes(DosAttributes attributes) %7B%0A        StringBuilder result = new StringBuilder();%0A%0A        if (attributes.getReadOnly()) %7B%0A            result.append('R');%0A        %7D%0A        if (attributes.getHidden()) %7B%0A            result.append('H');%0A        %7D%0A        if (attributes.getSystem()) %7B%0A            result.append('S');%0A        %7D%0A        if (attributes.getSystem()) %7B%0A            result.append('A');%0A        %7D%0A%0A        return result.toString();%0A    %7D%0A%0A%0A    private FormatUtil() %7B%0A        throw new AssertionError();%0A    %7D%0A%7D%0A

Add utility class for formatting various values