<commit_before>/*
 * $Id$
 * $Revision$ $Date$
 * 
 * ==============================================================================
 * 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 wicket.markup.html.form;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import wicket.AttributeModifier;
import wicket.Component;
import wicket.Page;
import wicket.WicketRuntimeException;
import wicket.markup.ComponentTag;
import wicket.markup.html.WebMarkupContainer;
import wicket.markup.html.form.validation.IValidator;
import wicket.markup.html.form.validation.TypeValidator;
import wicket.model.IModel;
import wicket.model.Model;
import wicket.util.string.StringList;
import wicket.util.string.Strings;

/**
 * An HTML form component knows how to validate itself. Validators that
 * implement IValidator can be added to the component. They will be evaluated in
 * the order they were added and the first Validator that returns an error
 * message determines the error message returned by the component.
 * <p>
 * FormComponents are not versioned by default. If you need versioning for your
 * FormComponents, you will need to call Form.setVersioned(true), which will set
 * versioning on for the form and all form component children.
 * 
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 */
public abstract class FormComponent extends WebMarkupContainer
{
	/**
	 * Typesafe interface to code that is called when visiting a form component.
	 */
	public interface IVisitor
	{
		/**
		 * Called when visiting a form component
		 * 
		 * @param formComponent
		 *            The form component
		 */
		public void formComponent(FormComponent formComponent);
	}

	/**
	 * Attribute modifier model that returns 'disabled' if a form component is
	 * disabled or null otherwise (resulting in no attribute being appended).
	 */
	private final class DisabledAttributeModel extends Model
	{
		private static final long serialVersionUID = 1L;

		/**
		 * @see wicket.model.IModel#getObject(wicket.Component)
		 */
		public Object getObject(Component component)
		{
			return (FormComponent.this.authorize(ENABLE) && FormComponent.this.isEnabled())
					? null
					: "disabled";
		}
	}

	/**
	 * Attribute modifier that adds 'disabled="disabled"' to the component tag's
	 * attribute if a form component is disabled.
	 */
	private static final class DisabledAttributeModifier extends AttributeModifier
	{
		private static final long serialVersionUID = 1L;

		/**
		 * Construct.
		 * 
		 * @param model
		 */
		public DisabledAttributeModifier(DisabledAttributeModel model)
		{
			super("disabled", true, model);
		}
	}

	/**
	 * Make empty strings null values boolean. Used by AbstractTextComponent
	 * subclass.
	 */
	protected static final short FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL = FLAG_RESERVED1;

	/**
	 * Whether this form component should save and restore state between
	 * sessions. This is false by default.
	 */
	private static final short FLAG_PERSISTENT = FLAG_RESERVED2;

	private static final String NO_RAW_INPUT = "[-NO-RAW-INPUT-]";

	/**
	 * Raw Input entered by the user or NO_RAW_INPUT if nothing is filled in.
	 */
	private String rawInput = NO_RAW_INPUT;

	/**
	 * Indicates if the model is considered up to date with the last user input.
	 * If true, the model value will be used to render the component. If false,
	 * the rawInput value (last user input) will be used to render the
	 * component. (Can be false if validation fails, or if component not
	 * validated/updated after a user input, for example if a Button with
	 * defaultFormProcessing property set to true, aka "immediate button")
	 */
	// private boolean modelUpToDate = true;
	/**
	 * The list of validators for this form component as either an IValidator
	 * instance or an array of IValidator instances.
	 */
	private Object validators = null;

	/**
	 * The value will be made available to the validator property by means of
	 * ${label}. It does not have any specific meaning to FormComponent itself.
	 */
	private IModel labelModel = null;

	/**
	 * @see wicket.Component#Component(String)
	 */
	public FormComponent(final String id)<commit_msg>"dead" code removed (not really more dead comments :))<commit_after>/*
 * $Id$
 * $Revision$ $Date$
 * 
 * ==============================================================================
 * 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 wicket.markup.html.form;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import wicket.AttributeModifier;
import wicket.Component;
import wicket.Page;
import wicket.WicketRuntimeException;
import wicket.markup.ComponentTag;
import wicket.markup.html.WebMarkupContainer;
import wicket.markup.html.form.validation.IValidator;
import wicket.markup.html.form.validation.TypeValidator;
import wicket.model.IModel;
import wicket.model.Model;
import wicket.util.string.StringList;
import wicket.util.string.Strings;

/**
 * An HTML form component knows how to validate itself. Validators that
 * implement IValidator can be added to the component. They will be evaluated in
 * the order they were added and the first Validator that returns an error
 * message determines the error message returned by the component.
 * <p>
 * FormComponents are not versioned by default. If you need versioning for your
 * FormComponents, you will need to call Form.setVersioned(true), which will set
 * versioning on for the form and all form component children.
 * 
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 */
public abstract class FormComponent extends WebMarkupContainer
{
	/**
	 * Typesafe interface to code that is called when visiting a form component.
	 */
	public interface IVisitor
	{
		/**
		 * Called when visiting a form component
		 * 
		 * @param formComponent
		 *            The form component
		 */
		public void formComponent(FormComponent formComponent);
	}

	/**
	 * Attribute modifier model that returns 'disabled' if a form component is
	 * disabled or null otherwise (resulting in no attribute being appended).
	 */
	private final class DisabledAttributeModel extends Model
	{
		private static final long serialVersionUID = 1L;

		/**
		 * @see wicket.model.IModel#getObject(wicket.Component)
		 */
		public Object getObject(Component component)
		{
			return (FormComponent.this.authorize(ENABLE) && FormComponent.this.isEnabled())
					? null
					: "disabled";
		}
	}

	/**
	 * Attribute modifier that adds 'disabled="disabled"' to the component tag's
	 * attribute if a form component is disabled.
	 */
	private static final class DisabledAttributeModifier extends AttributeModifier
	{
		private static final long serialVersionUID = 1L;

		/**
		 * Construct.
		 * 
		 * @param model
		 */
		public DisabledAttributeModifier(DisabledAttributeModel model)
		{
			super("disabled", true, model);
		}
	}

	/**
	 * Make empty strings null values boolean. Used by AbstractTextComponent
	 * subclass.
	 */
	protected static final short FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL = FLAG_RESERVED1;

	/**
	 * Whether this form component should save and restore state between
	 * sessions. This is false by default.
	 */
	private static final short FLAG_PERSISTENT = FLAG_RESERVED2;

	private static final String NO_RAW_INPUT = "[-NO-RAW-INPUT-]";

	/**
	 * Raw Input entered by the user or NO_RAW_INPUT if nothing is filled in.
	 */
	private String rawInput = NO_RAW_INPUT;

	/**
	 * The list of validators for this form component as either an IValidator
	 * instance or an array of IValidator instances.
	 */
	private Object validators = null;

	/**
	 * The value will be made available to the validator property by means of
	 * ${label}. It does not have any specific meaning to FormComponent itself.
	 */
	private IModel labelModel = null;

	/**
	 * @see wicket.Component#Component(String)
	 */
	public FormComponent(final String id)
{'fraction_non_alphanumeric': 0.0965749578888265, 'fraction_numerical': 0.0017967434025828186, 'mean_word_length': 3.912300055157198, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4439178', 'n_tokens_mistral': 2530, 'n_tokens_neox': 2311, 'n_words': 951}