<commit_before>/*
 * The Spring Framework is published under the terms
 * of the Apache Software License.
 */

package org.springframework.beans;

import java.beans.MethodDescriptor;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyDescriptor;
import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
import java.beans.PropertyVetoException;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.propertyeditors.ClassEditor;
import org.springframework.beans.propertyeditors.LocaleEditor;
import org.springframework.beans.propertyeditors.PropertiesEditor;
import org.springframework.beans.propertyeditors.PropertyValuesEditor;
import org.springframework.beans.propertyeditors.StringArrayPropertyEditor;
import org.springframework.util.StringUtils;

/**
 * Default implementation of the BeanWrapper interface that should be sufficient
 * for all normal uses. Caches introspection results for efficiency.
 *
 * <p>Note: this class never tries to load a class by name, as this can pose
 * class loading problems in J2EE applications with multiple deployment modules.
 * For example, loading a class by name won't work in some application servers
 * if the class is used in a WAR but was loaded by the EJB class loader and the
 * class to be loaded is in the WAR. (This class would use the EJB class loader,
 * which couldn't see the required class.) We don't attempt to solve such problems
 * by obtaining the classloader at runtime, because this violates the EJB
 * programming restrictions.
 *
 * <p>Note: Regards property editors in org.springframework.beans.propertyeditors.
 * Also explictly register the default ones to care for JREs that do not use
 * the thread context class loader for editor search paths.
 * Applications can either use a standard PropertyEditorManager to register a
 * custom editor before using a BeanWrapperImpl instance, or call the instance's
 * registerCustomEditor method to register an editor for the particular instance.
 *
 * <p>Collections custom property editors can be written against comma delimited String
 * as String arrays are converted in such a format if the array itself is not assignable.
 *
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 * @since 15 April 2001
 * @version $Id: BeanWrapperImpl.java,v 1.19 2003-12-10 08:53:42 jhoeller Exp $
 * @see #registerCustomEditor
 * @see java.beans.PropertyEditorManager
 */
public class BeanWrapperImpl implements BeanWrapper {

	/** We'll create a lot of these objects, so we don't want a new logger every time */
	private static final Log logger = LogFactory.getLog(BeanWrapperImpl.class);

	/** Registry for default PropertyEditors */
	private static final Map defaultEditors = new HashMap();

	static {
		// install default property editors
		try {
			// this one can't apply the <ClassName>Editor naming pattern
			PropertyEditorManager.registerEditor(String[].class, StringArrayPropertyEditor.class);
			// register all editors in our standard package
			PropertyEditorManager.setEditorSearchPath(new String[]{
				"sun.beans.editors",
				"org.springframework.beans.propertyeditors"
			});
		}
		catch (SecurityException ex) {
			// e.g. in applets -> log and proceed
			logger.warn("Cannot register property editors with PropertyEditorManager", ex);
		}

		// register default editors in this class, for restricted environments
		// where the above threw a SecurityException, and for JDKs that don't
		// use the thread context class loader for property editor lookup
		defaultEditors.put(String[].class, new StringArrayPropertyEditor());
		defaultEditors.put(PropertyValues.class, new PropertyValuesEditor());
		defaultEditors.put(Properties.class, new PropertiesEditor());
		defaultEditors.put(Class.class, new ClassEditor());
		defaultEditors.put(Locale.class, new LocaleEditor());
	}


	//---------------------------------------------------------------------
	// Instance data
	//---------------------------------------------------------------------

	/** The wrapped object */
	private Object object;

	/** The nested path of the object */
	private String nestedPath = "";

	/* Map with cached nested BeanWrappers */
	private Map nestedBeanWrappers;

	/** Map with custom PropertyEditor instances */
	private Map customEditors;

	/**
	 * Cached introspections results for this object, to prevent encountering the cost
	 * of JavaBeans introspection every time.
	 */
	private CachedIntrospectionResults cachedIntrospectionResults;
<commit_msg>adapted default editor registration<commit_after>/*
 * The Spring Framework is published under the terms
 * of the Apache Software License.
 */

package org.springframework.beans;

import java.beans.MethodDescriptor;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyDescriptor;
import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
import java.beans.PropertyVetoException;
import java.io.File;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.beans.propertyeditors.ClassEditor;
import org.springframework.beans.propertyeditors.FileEditor;
import org.springframework.beans.propertyeditors.LocaleEditor;
import org.springframework.beans.propertyeditors.PropertiesEditor;
import org.springframework.beans.propertyeditors.StringArrayPropertyEditor;
import org.springframework.beans.propertyeditors.URLEditor;
import org.springframework.util.StringUtils;

/**
 * Default implementation of the BeanWrapper interface that should be sufficient
 * for all normal uses. Caches introspection results for efficiency.
 *
 * <p>Note: this class never tries to load a class by name, as this can pose
 * class loading problems in J2EE applications with multiple deployment modules.
 * For example, loading a class by name won't work in some application servers
 * if the class is used in a WAR but was loaded by the EJB class loader and the
 * class to be loaded is in the WAR. (This class would use the EJB class loader,
 * which couldn't see the required class.) We don't attempt to solve such problems
 * by obtaining the classloader at runtime, because this violates the EJB
 * programming restrictions.
 *
 * <p>Note: Regards property editors in org.springframework.beans.propertyeditors.
 * Also explictly register the default ones to care for JREs that do not use
 * the thread context class loader for editor search paths.
 * Applications can either use a standard PropertyEditorManager to register a
 * custom editor before using a BeanWrapperImpl instance, or call the instance's
 * registerCustomEditor method to register an editor for the particular instance.
 *
 * <p>Collections custom property editors can be written against comma delimited String
 * as String arrays are converted in such a format if the array itself is not assignable.
 *
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 * @since 15 April 2001
 * @version $Id: BeanWrapperImpl.java,v 1.20 2003-12-30 01:23:16 jhoeller Exp $
 * @see #registerCustomEditor
 * @see java.beans.PropertyEditorManager
 */
public class BeanWrapperImpl implements BeanWrapper {

	/** We'll create a lot of these objects, so we don't want a new logger every time */
	private static final Log logger = LogFactory.getLog(BeanWrapperImpl.class);

	/** Registry for default PropertyEditors */
	private static final Map defaultEditors = new HashMap();

	static {
		// install default property editors
		try {
			// this one can't apply the <ClassName>Editor naming pattern
			PropertyEditorManager.registerEditor(String[].class, StringArrayPropertyEditor.class);
			// register all editors in our standard package
			PropertyEditorManager.setEditorSearchPath(new String[]{
				"sun.beans.editors",
				"org.springframework.beans.propertyeditors"
			});
		}
		catch (SecurityException ex) {
			// e.g. in applets -> log and proceed
			logger.warn("Cannot register property editors with PropertyEditorManager", ex);
		}

		// register default editors in this class, for restricted environments
		// where the above threw a SecurityException, and for JDKs that don't
		// use the thread context class loader for property editor lookup
		defaultEditors.put(Class.class, new ClassEditor());
		defaultEditors.put(File.class, new FileEditor());
		defaultEditors.put(Locale.class, new LocaleEditor());
		defaultEditors.put(Properties.class, new PropertiesEditor());
		defaultEditors.put(String[].class, new StringArrayPropertyEditor());
		defaultEditors.put(URL.class, new URLEditor());
	}


	//---------------------------------------------------------------------
	// Instance data
	//---------------------------------------------------------------------

	/** The wrapped object */
	private Object object;

	/** The nested path of the object */
	private String nestedPath = "";

	/* Map with cached nested BeanWrappers */
	private Map nestedBeanWrappers;

	/** Map with custom PropertyEditor instances */
	private Map customEditors;

	/**
	 * Cached introspections results for this object, to prevent encountering the cost
	 * of JavaBeans introspection every time.
	 */
	private CachedIntrospectionResults cachedIntrospectionResults;

{'fraction_non_alphanumeric': 0.10499034454721008, 'fraction_numerical': 0.004878544567537352, 'mean_word_length': 4.056526207605344, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '6534968', 'n_tokens_mistral': 2621, 'n_tokens_neox': 2433, 'n_words': 948}