<commit_before>/**
 * $RCSfile: ByteFormat.java,v $
 * $Revision: 1.6 $
 * $Date: 2005/04/12 19:17:41 $
 *
 * Copyright (C) 1999-2002 Jive Software. All rights reserved.
 *
 * This software is the proprietary information of Jive Software. Use is subject to license terms.
 */

package org.jivesoftware.spark.util;

import java.text.DecimalFormat;
import java.text.FieldPosition;
import java.text.Format;
import java.text.ParsePosition;

/**
 * A formatter for formatting byte sizes. For example, formatting 12345 byes results in
 * "12.1 K" and 1234567 results in "1.18 MB".
 *
 * @author <NAME>
 */
public class ByteFormat extends Format {

    public ByteFormat() {
    }

    // Implemented from the Format class

    /**
     * Formats a long which represent a number of kilobytes.
     *
     * @param kilobytes Long kbytes to format as a string.
     * @return String representation of kbytes.
     */
    public String formatKB(long kilobytes) {
        return format(kilobytes * 1024);
    }

    /**
     * Format the given object (must be a Long).
     *
     * @param obj assumed to be the number of bytes as a Long.
     * @param buf the StringBuffer to append to.
     * @param pos field position.
     * @return A formatted string representing the given bytes in more human-readable form.
     */
    public StringBuffer format(Object obj, StringBuffer buf, FieldPosition pos) {
        if (obj instanceof Long) {
            long numBytes = (Long) obj;
            if (numBytes < 1024) {
                DecimalFormat formatter = new DecimalFormat("#,##0");
                buf.append(formatter.format((double)numBytes)).append(" bytes");<commit_msg>Added back missing method.<commit_after>/**
 * $RCSfile: ByteFormat.java,v $
 * $Revision: 1.6 $
 * $Date: 2005/04/12 19:17:41 $
 *
 * Copyright (C) 1999-2002 Jive Software. All rights reserved.
 *
 * This software is the proprietary information of Jive Software. Use is subject to license terms.
 */

package org.jivesoftware.spark.util;

import java.text.DecimalFormat;
import java.text.FieldPosition;
import java.text.Format;
import java.text.ParsePosition;

/**
 * A formatter for formatting byte sizes. For example, formatting 12345 byes results in
 * "12.1 K" and 1234567 results in "1.18 MB".
 *
 * @author <NAME>
 */
public class ByteFormat extends Format {

    public ByteFormat() {
    }

    // Implemented from the Format class

    /**
     * Formats a long which represent a number of bytes.
     */
    public String format(long bytes) {
        return super.format(bytes);
    }

    /**
     * Formats a long which represent a number of kilobytes.
     *
     * @param kilobytes Long kbytes to format as a string.
     * @return String representation of kbytes.
     */
    public String formatKB(long kilobytes) {
        return super.format(kilobytes * 1024);
    }

    /**
     * Format the given object (must be a Long).
     *
     * @param obj assumed to be the number of bytes as a Long.
     * @param buf the StringBuffer to append to.
     * @param pos field position.
     * @return A formatted string representing the given bytes in more human-readable form.
     */
    public StringBuffer format(Object obj, StringBuffer buf, FieldPosition pos) {
        if (obj instanceof Long) {
            long numBytes = (Long) obj;
            if (numBytes < 1024) {
                DecimalFormat formatter = new DecimalFormat("#,##0");
                buf.append(formatter.format((double)numBytes)).append(" bytes");
{'fraction_non_alphanumeric': 0.10017123287671233, 'fraction_numerical': 0.02910958904109589, 'mean_word_length': 2.670157068062827, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2363648', 'n_tokens_mistral': 1087, 'n_tokens_neox': 979, 'n_words': 365}