<commit_before>/*<license>
  Copyright 2004-2005, PeopleWare n.v.
  NO RIGHTS ARE GRANTED FOR THE USE OF THIS SOFTWARE, EXCEPT, IN WRITING,
  TO SELECTED PARTIES.
</license>*/


package be.peopleware.value_I;


import java.beans.PropertyEditor;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;

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


/**
 * Support for converters based on {@link PropertyEditor PropertyEditors}.
 * Derive from this class and implement {@link #getPropertyEditor(FacesContext, UIComponent)}.
 * Then add an entry in <kbd>faces-config.xml</kbd> to map the target types
 * to the correct converter class descendant.
 *
 * @author <NAME>
 * @author <NAME>
 * @author PeopleWare n.v.
 *
 * @invar getPropertyEditor() != null;
 */

public abstract class AbstractPropertyEditorConverter implements Converter {

  /*<section name="Meta Information">*/
  //------------------------------------------------------------------
  /** {@value} */
  public static final String CVS_REVISION = "$Revision$"; //$NON-NLS-1$
  /** {@value} */
  public static final String CVS_DATE = "$Date$"; //$NON-NLS-1$
  /** {@value} */
  public static final String CVS_STATE = "$State$"; //$NON-NLS-1$
  /** {@value} */
  public static final String CVS_TAG = "$Name$"; //$NON-NLS-1$
  /*</section>*/


  private static final Log LOG =
    LogFactory.getLog(AbstractPropertyEditorConverter.class);


  /**
   * @pre context != null;
   * @pre component != null;
   * @return ; the result of the conversion of <code>value</code>
   *           to an Object by {@link #getPropertyEditor(FacesContext, UIComponent)}
   * @throws ConverterException
   *         getPropertyEditor(context, component);
   * @throws ConverterException
   *         getPropertyEditor(context, component).getValue()#IllegalArgumentException;
   */
  public final Object getAsObject(FacesContext context, UIComponent component, String value)
      throws ConverterException {
    assert context != null;
    assert component != null;
    try {
      LOG.debug("request to convert \"" + value + "\" to object for " +
                component + "(id = " + component.getClientId(context) + ")");
      PropertyEditor editor = getPropertyEditor(context, component); // ConverterException
      LOG.debug("retrieved PropertyEditor: " + editor);
      editor.setAsText(value);
      Object result = editor.getValue();
      if (LOG.isDebugEnabled()) {
        LOG.debug("convertion result: " + result);<commit_msg>More debugging<commit_after>/*<license>
  Copyright 2004-2005, PeopleWare n.v.
  NO RIGHTS ARE GRANTED FOR THE USE OF THIS SOFTWARE, EXCEPT, IN WRITING,
  TO SELECTED PARTIES.
</license>*/


package be.peopleware.value_I;


import java.beans.PropertyEditor;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;

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


/**
 * Support for converters based on {@link PropertyEditor PropertyEditors}.
 * Derive from this class and implement {@link #getPropertyEditor(FacesContext, UIComponent)}.
 * Then add an entry in <kbd>faces-config.xml</kbd> to map the target types
 * to the correct converter class descendant.
 *
 * @author <NAME>
 * @author <NAME>
 * @author PeopleWare n.v.
 *
 * @invar getPropertyEditor() != null;
 */

public abstract class AbstractPropertyEditorConverter implements Converter {

  /*<section name="Meta Information">*/
  //------------------------------------------------------------------
  /** {@value} */
  public static final String CVS_REVISION = "$Revision$"; //$NON-NLS-1$
  /** {@value} */
  public static final String CVS_DATE = "$Date$"; //$NON-NLS-1$
  /** {@value} */
  public static final String CVS_STATE = "$State$"; //$NON-NLS-1$
  /** {@value} */
  public static final String CVS_TAG = "$Name$"; //$NON-NLS-1$
  /*</section>*/


  private static final Log LOG =
    LogFactory.getLog(AbstractPropertyEditorConverter.class);

  protected AbstractPropertyEditorConverter() {
    LOG.debug("creation of new ...PropertyEditorConverter (" +
              getClass().getName() + ")");
  }


  /**
   * @pre context != null;
   * @pre component != null;
   * @return ; the result of the conversion of <code>value</code>
   *           to an Object by {@link #getPropertyEditor(FacesContext, UIComponent)}
   * @throws ConverterException
   *         getPropertyEditor(context, component);
   * @throws ConverterException
   *         getPropertyEditor(context, component).getValue()#IllegalArgumentException;
   */
  public final Object getAsObject(FacesContext context, UIComponent component, String value)
      throws ConverterException {
    assert context != null;
    assert component != null;
    try {
      LOG.debug("request to convert \"" + value + "\" to object for " +
                component + "(id = " + component.getClientId(context) + ")");
      PropertyEditor editor = getPropertyEditor(context, component); // ConverterException
      LOG.debug("retrieved PropertyEditor: " + editor);
      editor.setAsText(value);
      Object result = editor.getValue();
      if (LOG.isDebugEnabled()) {
        LOG.debug("convertion result: " + result);
{'fraction_non_alphanumeric': 0.15169366715758467, 'fraction_numerical': 0.004418262150220913, 'mean_word_length': 3.2545027407987472, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '3440408', 'n_tokens_mistral': 1558, 'n_tokens_neox': 1524, 'n_words': 415}