<commit_before>/*******************************************************************************
 * Copyright (c) 2008, <NAME> and Elexis
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    <NAME> - initial implementation
 *    
 *******************************************************************************/
package ch.rgw.tools;

public class MimeTool {
	final static String[][] mapping = {
		{
			"pdf", "application/pdf"
		}, {
			"odt", "application/vnd.oasis.opendocument.text"
		}, {
			"jpg", "image/jpeg"
		}, {
			"pps", "application/mspowerpoint"
		}, {
			"png", "image/png"
		}
	};
	
	/**
	 * find the mimetype for a given extension
	 * 
	 * @param ext
	 *            an extension with or without dot. Case doesn't matter
	 * @return the matching mimetype or application/octet-stream if none was found, or the empty
	 *         string if ext was null
	 */
	public static String getMimeType(String ext){
		if (ext == null) {
			return "";
		}
		if (ext.startsWith(".")) {
			ext = ext.substring(1);
		}
		for (String[] line : mapping) {
			if (line[0].equalsIgnoreCase(ext)) {
				return line[1];
			}
		}
		return "application/octet-stream";
	}
	
	/**
	 * find the file extension for a given mimetype. If more than one extension is known for a
	 * mimetyoe, only the first one will be chosen
	 * 
	 * @param mimetype
	 *            a mimetype. Case doesn't matter
	 * @return the matching extension or the empty string if none was found
	 */
	public static String getExtension(String mimetype){
		if (mimetype == null) {
			return "";
		}
		for (String[] line : mapping) {
			if (line[1].equalsIgnoreCase(mimetype)) {
				return line[0];
			}
		}
		return "";
	}
}
<commit_msg>[22384] Provide additional mimetypes to MimeTool<commit_after>/*******************************************************************************
 * Copyright (c) 2008, <NAME> and Elexis
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    <NAME> - initial implementation
 *    
 *******************************************************************************/
package ch.rgw.tools;

public class MimeTool {
	final static String[][] mapping = {
		{
			"pdf", "application/pdf"
		}, {
			"odt", "application/vnd.oasis.opendocument.text"
		}, {
			"jpg", "image/jpeg"
		}, {
			"pps", "application/mspowerpoint"
		}, {
			"png", "image/png"
		}, {
			"docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
		}, {
			"doc", "application/msword"
		}
	};
	
	/**
	 * find the mimetype for a given extension
	 * 
	 * @param ext
	 *            an extension with or without dot. Case doesn't matter
	 * @return the matching mimetype or application/octet-stream if none was found, or the empty
	 *         string if ext was null
	 */
	public static String getMimeType(String ext){
		if (ext == null) {
			return "";
		}
		if (ext.startsWith(".")) {
			ext = ext.substring(1);
		}
		for (String[] line : mapping) {
			if (line[0].equalsIgnoreCase(ext)) {
				return line[1];
			}
		}
		return "application/octet-stream";
	}
	
	/**
	 * find the file extension for a given mimetype. If more than one extension is known for a
	 * mimetyoe, only the first one will be chosen
	 * 
	 * @param mimetype
	 *            a mimetype. Case doesn't matter
	 * @return the matching extension or the empty string if none was found
	 */
	public static String getExtension(String mimetype){
		if (mimetype == null) {
			return "";
		}
		for (String[] line : mapping) {
			if (line[1].equalsIgnoreCase(mimetype)) {
				return line[0];
			}
		}
		return "";
	}
}

{'fraction_non_alphanumeric': 0.19413092550790068, 'fraction_numerical': 0.007775269626285428, 'mean_word_length': 3.2335456475583864, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 1}, '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': '5826589', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1159, 'n_words': 371}