<commit_before>package com.handmark.pulltorefresh.library;

import java.lang.reflect.Constructor;

import java.lang.reflect.InvocationTargetException;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.Log;
import android.view.View;

import com.handmark.pulltorefresh.configuration.xml.PullToRefreshXmlConfiguration;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Orientation;
import com.handmark.pulltorefresh.library.internal.FlipLoadingLayout;
import com.handmark.pulltorefresh.library.internal.LoadingLayout;
/**
 * Factory which creates loading layouts 
 * <br />Loading layouts must be listed in pulltorefresh.xml as "PullToRefresh/LoadingLayouts/layout" nodes
 * @author <NAME>
 */
class LoadingLayoutFactory {

	private static final String LOG_TAG = LoadingLayoutFactory.class
			.getSimpleName();
	/**
	 * Create the class token matched by <b>{@code layoutCode}</b>
	 * @param layoutCode Loading layout code, which must be defined in pulltorefresh.xml 
	 * @return Class token which is matched by {@code layoutCode}, or the class token of {@code FlipLoadingLayout} instance if not
	 */
	public static Class<? extends LoadingLayout> createLoadingLayoutClazzByLayoutCode(String layoutCode) {
		String clazzName = PullToRefreshXmlConfiguration.getInstance().getLoadingLayoutClazzName(layoutCode);
		return createLoadingLayoutClazz(clazzName);
	}
	/**
	 * Create a {@code LoadingLayout} instance matched by <b>{@code clazz} token</b> 
	 * @param layoutCode Loading layout code, which must be defined in pulltorefresh.xml
	 * @param context 
	 * @param mode 
	 * @return {@code LoadingLayout} instance if the class matched by {@code layoutCode} exists, or {@code FlipLoadingLayout} instance if not  
	 */
	public static Class<? extends LoadingLayout> createLoadingLayoutClazz(
			String clazzName) {
		Class<? extends LoadingLayout> loadingLayoutClazz = null;
		if ( clazzName == null ) {
			loadingLayoutClazz = FlipLoadingLayoutFactory.createLoadingLayoutClazz(clazzName);
			return loadingLayoutClazz;
		}
		
		try {
			// FIXME unchecked
			loadingLayoutClazz = (Class<LoadingLayout>) Class.forName(clazzName);

		} catch (ClassNotFoundException e) {
			Log.e(LOG_TAG,
					"Selected loading layout class has not been found.");
			loadingLayoutClazz = FlipLoadingLayoutFactory.createLoadingLayoutClazz(clazzName);
		} 

		return loadingLayoutClazz;
	}
	/**
	 * Create a {@code LoadingLayout} instance matched by <b>{@code layoutCode}</b> 
	 * @param layoutCode Loading layout code, which must be defined in pulltorefresh.xml
	 * @param context 
	 * @param mode 
	 * @return {@code LoadingLayout} instance if the class matched by {@code layoutCode} exists, or {@code FlipLoadingLayout} instance if not  
	 */
	public static LoadingLayout createLoadingLayout(String layoutCode, Context context, Mode mode,
			Orientation orientation, TypedArray attrs) {
		Class<? extends LoadingLayout> clazz = createLoadingLayoutClazz(layoutCode);
		return createLoadingLayout(clazz, context, mode, orientation, attrs);
	}<commit_msg>[issue-43] Add @SuppressWarnings("unchecked") at LoadingLayoutFactory.createLoadingLayoutClazz(...)<commit_after>package com.handmark.pulltorefresh.library;

import java.lang.reflect.Constructor;

import java.lang.reflect.InvocationTargetException;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.Log;
import android.view.View;

import com.handmark.pulltorefresh.configuration.xml.PullToRefreshXmlConfiguration;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Orientation;
import com.handmark.pulltorefresh.library.internal.FlipLoadingLayout;
import com.handmark.pulltorefresh.library.internal.LoadingLayout;
/**
 * Factory which creates loading layouts 
 * <br />Loading layouts must be listed in pulltorefresh.xml as "PullToRefresh/LoadingLayouts/layout" nodes
 * @author <NAME>
 */
class LoadingLayoutFactory {

	private static final String LOG_TAG = LoadingLayoutFactory.class
			.getSimpleName();
	/**
	 * Create the class token matched by <b>{@code layoutCode}</b>
	 * @param layoutCode Loading layout code, which must be defined in pulltorefresh.xml 
	 * @return Class token which is matched by {@code layoutCode}, or the class token of {@code FlipLoadingLayout} instance if not
	 */
	public static Class<? extends LoadingLayout> createLoadingLayoutClazzByLayoutCode(String layoutCode) {
		String clazzName = PullToRefreshXmlConfiguration.getInstance().getLoadingLayoutClazzName(layoutCode);
		return createLoadingLayoutClazz(clazzName);
	}
	/**
	 * Create a {@code LoadingLayout} instance matched by <b>{@code clazz} token</b> 
	 * @param layoutCode Loading layout code, which must be defined in pulltorefresh.xml
	 * @param context 
	 * @param mode 
	 * @return {@code LoadingLayout} instance if the class matched by {@code layoutCode} exists, or {@code FlipLoadingLayout} instance if not  
	 */
	@SuppressWarnings("unchecked")
	public static Class<? extends LoadingLayout> createLoadingLayoutClazz(
			String clazzName) {
		Class<? extends LoadingLayout> loadingLayoutClazz = null;
		if ( clazzName == null ) {
			loadingLayoutClazz = FlipLoadingLayoutFactory.createLoadingLayoutClazz(clazzName);
			return loadingLayoutClazz;
		}
		
		try {
			loadingLayoutClazz = (Class<LoadingLayout>) Class.forName(clazzName);

		} catch (ClassNotFoundException e) {
			Log.e(LOG_TAG,
					"Selected loading layout class has not been found.");
			loadingLayoutClazz = FlipLoadingLayoutFactory.createLoadingLayoutClazz(clazzName);
		} 

		return loadingLayoutClazz;
	}
	/**
	 * Create a {@code LoadingLayout} instance matched by <b>{@code layoutCode}</b> 
	 * @param layoutCode Loading layout code, which must be defined in pulltorefresh.xml
	 * @param context 
	 * @param mode 
	 * @return {@code LoadingLayout} instance if the class matched by {@code layoutCode} exists, or {@code FlipLoadingLayout} instance if not  
	 */
	public static LoadingLayout createLoadingLayout(String layoutCode, Context context, Mode mode,
			Orientation orientation, TypedArray attrs) {
		Class<? extends LoadingLayout> clazz = createLoadingLayoutClazz(layoutCode);
		return createLoadingLayout(clazz, context, mode, orientation, attrs);
	}
{'fraction_non_alphanumeric': 0.09035389915440024, 'fraction_numerical': 0.00031318509238960227, 'mean_word_length': 5.438508064516129, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '2896615', 'n_tokens_mistral': 1906, 'n_tokens_neox': 1730, 'n_words': 507}