<commit_before>/******************************************************
 * Imagemagick resize example servlet
 * 
 *
 * Copyright (C) 2012 by <NAME> (http://peterhedenskog.com)
 *
 ******************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in 
 * compliance with the License. You may obtain a copy of the License at
 * 
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is 
 * distributed  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   
 * See the License for the specific language governing permissions and limitations under the License.
 *
 *******************************************************
 */
package com.soulgalore.servlet;

import java.io.File;

class Thumbnail {

	private static final int MASK = 255;
	private static final int BYTE = 8;

	private final String imageFileName;
	private final String originalImageName;
	private final String originalImageNameWithExtension;
	private final String imageFileExtension;
	private final String imageDimensions;
	private final String generatedFilePath;

	/**
	 * Create a thumbnail. Note will not check the file format.
	 * 
	 * @param theFileName
	 */
	Thumbnail(String theFileName) {

		imageFileName = theFileName;<commit_msg>added check for correct thumbnail name<commit_after>/******************************************************
 * Imagemagick resize example servlet
 * 
 *
 * Copyright (C) 2012 by <NAME> (http://peterhedenskog.com)
 *
 ******************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in 
 * compliance with the License. You may obtain a copy of the License at
 * 
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is 
 * distributed  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   
 * See the License for the specific language governing permissions and limitations under the License.
 *
 *******************************************************
 */
package com.soulgalore.servlet;

import java.io.File;
import java.util.regex.Pattern;

class Thumbnail {

	/**
	 * The regexp for the thumbnail name.
	 */
	protected static final String MATCHING_NAME_REGEXP = ".+\\-[0-9]+x[0-9]+\\.(png|jpg|jpeg|gif)";
	
	private static final int MASK = 255;
	private static final int BYTE = 8;

	private final String imageFileName;
	private final String originalImageName;
	private final String originalImageNameWithExtension;
	private final String imageFileExtension;
	private final String imageDimensions;
	private final String generatedFilePath;
	private final Pattern pattern = Pattern
			.compile(MATCHING_NAME_REGEXP);

	/**
	 * Create a thumbnail. Note will not check the file format.
	 * 
	 * @param theFileName
	 * @throws ThumbnailNameException
	 */
	Thumbnail(String theFileName) throws ThumbnailNameException {

		if (theFileName == null || !pattern.matcher(theFileName).matches())
			throw new ThumbnailNameException("The name: " + theFileName
					+ " isn't valid");

		imageFileName = theFileName;
{'fraction_non_alphanumeric': 0.16903493191237418, 'fraction_numerical': 0.008288928359976317, 'mean_word_length': 4.521241830065359, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4664356', 'n_tokens_mistral': 913, 'n_tokens_neox': 841, 'n_words': 333}