<commit_before>package am.app.mappingEngine;

import java.awt.Color;
import java.util.EnumSet;

import am.app.Core;
import am.userInterface.Colors;

public class MatcherFactory {
	
	/**
	 * When adding a matcher add the line names[NEWINDEX] = "My name"; Name shouldn't be too long but at the same time should be a user clear name;
	 * @return the list of matchers names ordered by the indexes of each matcher, this is the same list shown in the AgreementMaker combo box, so the selectedIndex of the combobox must correspond to a valid matcher
	 */
	public static String[] getMatcherNames() {
		EnumSet<MatchersRegistry> matchers = EnumSet.allOf(MatchersRegistry.class);
		
		Object[] matchersArray = matchers.toArray();
		String[] matchersList = new String[matchersArray.length];
		for( int i = 0; i < matchersArray.length; i++ ) {
			matchersList[i] = ((MatchersRegistry) matchersArray[i]).getMatcherName();
		}
		
		return matchersList;
	}

	/**
	 * When adding a matcher add the line names[NEWINDEX] = "My name"; Name shouldn't be too long but at the same time should be a user clear name;
	 * @return the list of matchers names ordered by the indexes of each matcher, this is the same list shown in the AgreementMaker combo box, so the selectedIndex of the combobox must correspond to a valid matcher
	 */
	public static String[] getMatcherComboList() {
		EnumSet<MatchersRegistry> matchers = EnumSet.allOf(MatchersRegistry.class);

		Object[] matchersArray = matchers.toArray();

		int visibleMatchers = 0;
		for( int i = 0; i < matchersArray.length; i++ ) {
			if( ((MatchersRegistry) matchersArray[i]).isShown() ) {
				visibleMatchers++;
			}
		}
		

		int j = 0;
		String[] matchersList = new String[visibleMatchers];
		for( int i = 0; i < matchersArray.length; i++ ) {
			if( ((MatchersRegistry) matchersArray[i]).isShown() ) {
				matchersList[j] = ((MatchersRegistry) matchersArray[i]).getMatcherName();
				j++;
			}
			
		}
		
		return matchersList;
	}
	
	
	/**Return the real istance of the matcher given the selected nameindex
	 * the instanceIndex is the unique identifier of this algorithm, is the unique parameter of the constructor and is the identifier of the matcher instance in the run matchers list (the table of the AM)
	 * */
	public static AbstractMatcher getMatcherInstance(MatchersRegistry name, int instanceIndex) {
		
		Class<?> matcherClass = null;
		try {
			matcherClass = Class.forName( name.getMatcherClass() );
		} catch (ClassNotFoundException e) {
			System.out.println("DEVELOPER: You have entered a wrong class name in the MatcherRegistry");
			e.printStackTrace();
			return null;
		}
		
		AbstractMatcher a = null;
		try {<commit_msg>Transition method.<commit_after>package am.app.mappingEngine;

import java.awt.Color;
import java.util.EnumSet;

import am.app.Core;
import am.app.osgi.MatcherNotFoundException;
import am.userInterface.Colors;

public class MatcherFactory {
	
	/**
	 * When adding a matcher add the line names[NEWINDEX] = "My name"; Name shouldn't be too long but at the same time should be a user clear name;
	 * @return the list of matchers names ordered by the indexes of each matcher, this is the same list shown in the AgreementMaker combo box, so the selectedIndex of the combobox must correspond to a valid matcher
	 */
	public static String[] getMatcherNames() {
		EnumSet<MatchersRegistry> matchers = EnumSet.allOf(MatchersRegistry.class);
		
		Object[] matchersArray = matchers.toArray();
		String[] matchersList = new String[matchersArray.length];
		for( int i = 0; i < matchersArray.length; i++ ) {
			matchersList[i] = ((MatchersRegistry) matchersArray[i]).getMatcherName();
		}
		
		return matchersList;
	}

	/**
	 * When adding a matcher add the line names[NEWINDEX] = "My name"; Name shouldn't be too long but at the same time should be a user clear name;
	 * @return the list of matchers names ordered by the indexes of each matcher, this is the same list shown in the AgreementMaker combo box, so the selectedIndex of the combobox must correspond to a valid matcher
	 */
	public static String[] getMatcherComboList() {
		EnumSet<MatchersRegistry> matchers = EnumSet.allOf(MatchersRegistry.class);

		Object[] matchersArray = matchers.toArray();

		int visibleMatchers = 0;
		for( int i = 0; i < matchersArray.length; i++ ) {
			if( ((MatchersRegistry) matchersArray[i]).isShown() ) {
				visibleMatchers++;
			}
		}
		

		int j = 0;
		String[] matchersList = new String[visibleMatchers];
		for( int i = 0; i < matchersArray.length; i++ ) {
			if( ((MatchersRegistry) matchersArray[i]).isShown() ) {
				matchersList[j] = ((MatchersRegistry) matchersArray[i]).getMatcherName();
				j++;
			}
			
		}
		
		return matchersList;
	}
	
	
	public static AbstractMatcher getMatcherInstance( String matcherName ) {
		try {
			return Core.getInstance().getFramework().getRegistry().getMatcherByName(matcherName);
		}
		catch (MatcherNotFoundException e) {
			e.printStackTrace();
			return null;
		}
	}
	
	/**Return the real istance of the matcher given the selected nameindex
	 * the instanceIndex is the unique identifier of this algorithm, is the unique parameter of the constructor and is the identifier of the matcher instance in the run matchers list (the table of the AM)
	 * */
	public static AbstractMatcher getMatcherInstance(MatchersRegistry name, int instanceIndex) {
		
		Class<?> matcherClass = null;
		try {
			matcherClass = Class.forName( name.getMatcherClass() );
		} catch (ClassNotFoundException e) {
			System.out.println("DEVELOPER: You have entered a wrong class name in the MatcherRegistry");
			e.printStackTrace();
			return null;
		}
		
		AbstractMatcher a = null;
		try {
{'fraction_non_alphanumeric': 0.09617081348155991, 'fraction_numerical': 0.0017646020822304571, 'mean_word_length': 4.124773960216999, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 9, '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': '5393642', 'n_tokens_mistral': 1834, 'n_tokens_neox': 1624, 'n_words': 598}