<commit_before>/*
 * #%L
 * Bitrepository Core
 * %%
 * Copyright (C) 2010 - 2013 The State and University Library, The Royal Library and The State Archives, Denmark
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 2.1 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public 
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/lgpl-2.1.html>.
 * #L%
 */
package org.bitrepository.common.utils;

/**
 * Util class for handling formatting of datasizes. 
 */
public class FileSizeUtils {

	private static final int unitSize = 1024;
	private static final long byteSize = 1;
	private static final long kiloSize = byteSize * unitSize;
	private static final long megaSize = kiloSize * unitSize;
	private static final long gigaSize = megaSize * unitSize;
	private static final long teraSize = gigaSize * unitSize;
	private static final long petaSize = teraSize * unitSize;
	private static final long exaSize = petaSize * unitSize;

	private static final String bytePostfix = "B";
	private static final String kiloPostfix = "KB";
	private static final String megaPostfix = "MB";
	private static final String gigaPostfix = "GB";
	private static final String teraPostfix = "TB";
	private static final String petaPostfix = "PB";
	private static final String exaPostfix = "EB";

	/*
	 * Returns the appropiate unit for a given byte size. Ie. MB or GB
	 * 
	 */	
	public static String toHumanUnit(Long size) {
		if (size == null) {
			return bytePostfix;
		}
		if (size >= exaSize) {
			return exaPostfix;<commit_msg>put a space between value and unit, as requested by JHH<commit_after>/*
 * #%L
 * Bitrepository Core
 * %%
 * Copyright (C) 2010 - 2013 The State and University Library, The Royal Library and The State Archives, Denmark
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 2.1 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public 
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/lgpl-2.1.html>.
 * #L%
 */
package org.bitrepository.common.utils;

/**
 * Util class for handling formatting of datasizes. 
 */
public class FileSizeUtils {

	private static final int unitSize = 1024;
	private static final long byteSize = 1;
	private static final long kiloSize = byteSize * unitSize;
	private static final long megaSize = kiloSize * unitSize;
	private static final long gigaSize = megaSize * unitSize;
	private static final long teraSize = gigaSize * unitSize;
	private static final long petaSize = teraSize * unitSize;
	private static final long exaSize = petaSize * unitSize;

	private static final String bytePostfix = " B";
	private static final String kiloPostfix = " KB";
	private static final String megaPostfix = " MB";
	private static final String gigaPostfix = " GB";
	private static final String teraPostfix = " TB";
	private static final String petaPostfix = " PB";
	private static final String exaPostfix = " EB";

	/*
	 * Returns the appropiate unit for a given byte size. Ie. MB or GB
	 * 
	 */	
	public static String toHumanUnit(Long size) {
		if (size == null) {
			return bytePostfix;
		}
		if (size >= exaSize) {
			return exaPostfix;
{'fraction_non_alphanumeric': 0.07451746884925482, 'fraction_numerical': 0.008306865379916931, 'mean_word_length': 3.8051643192488265, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5531189', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1113, 'n_words': 529}