📄 formcontroltype.java
字号:
// Jericho HTML Parser - Java based library for analysing and manipulating HTML
// Version 3.0
// Copyright (C) 2007 Martin Jericho
// http://jerichohtml.sourceforge.net/
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of either one of the following licences:
//
// 1. The Eclipse Public License (EPL) version 1.0,
// included in this distribution in the file licence-epl-1.0.html
// or available at http://www.eclipse.org/legal/epl-v10.html
//
// 2. The GNU Lesser General Public License (LGPL) version 2.1 or later,
// included in this distribution in the file licence-lgpl-2.1.txt
// or available at http://www.gnu.org/licenses/lgpl.txt
//
// This library is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
// See the individual licence texts for more details.
package net.htmlparser.jericho;
import java.util.*;
/**
* Represents the <a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#h-17.2.1">control type</a>
* of a {@link FormControl}.
* <p>
* Use the {@link FormControl#getFormControlType()} method to determine the type of a form control.
* <p>
* The following table shows the relationship between the HTML 4.01 specification control type descriptions,
* their associated {@link Element} names and attributes, and the <code>FormControlType</code> constants defined in this class:
* <table class="bordered" style="margin: 15px" cellspacing="0">
* <tr>
* <th><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#h-17.2.1">Description</a>
* <th>{@linkplain Element#getName() Element Name}
* <th>Distinguishing Attribute
* <th><code>FormControlType</code>
* <tr>
* <td rowspan="3"><a name="submit-button" target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#buttons">buttons</a> - <a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#submit-button">submit button</a>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#edef-BUTTON">BUTTON</a></code>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#adef-type-BUTTON">type</a>="submit"</code>
* <td>{@link #BUTTON}
* <tr>
* <td rowspan="2"><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#edef-INPUT">INPUT</a></code>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#adef-type-INPUT">type</a>="submit"</code>
* <td>{@link #SUBMIT}
* <tr>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#adef-type-INPUT">type</a>="<a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#input-control-types">image</a>"</code>
* <td>{@link #IMAGE}
* <tr>
* <td><a name="reset-button-control" target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#buttons">buttons</a> - <a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#reset-button">reset button</a>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#edef-BUTTON">BUTTON</a></code>,
* <code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#edef-INPUT">INPUT</a></code>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#adef-type-BUTTON">type</a>="reset"</code>
* <td>-
* <tr>
* <td><a name="push-button-control" target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#buttons">buttons</a> - <a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#push-button">push button</a>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#edef-BUTTON">BUTTON</a></code>,
* <code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#edef-INPUT">INPUT</a></code>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#adef-type-BUTTON">type</a>="button"</code>
* <td>-
* <tr>
* <td><a name="checkbox-control" target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#checkbox">checkboxes</a>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#edef-INPUT">INPUT</a></code>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#adef-type-INPUT">type</a>="checkbox"</code>
* <td>{@link #CHECKBOX}
* <tr>
* <td><a name="radio-button-control" target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#radio">radio buttons</a>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#edef-INPUT">INPUT</a></code>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#adef-type-INPUT">type</a>="radio"</code>
* <td>{@link #RADIO}
* <tr>
* <td rowspan="2"><a name="menu-control" target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#menu">menus</a>
* <td rowspan="2"><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#edef-SELECT">SELECT</a></code>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#adef-multiple">multiple</a></code>
* <td>{@link #SELECT_MULTIPLE}
* <tr>
* <td>absence of <code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#adef-multiple">multiple</a></code>
* <td>{@link #SELECT_SINGLE}
* <tr>
* <td rowspan="3"><a name="text-input-control" target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#text-input">text input</a>
* <td rowspan="2"><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#edef-INPUT">INPUT</a></code>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#adef-type-INPUT">type</a>="<a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#idx-text_input_control-1">text</a>"</code>
* <td>{@link #TEXT}
* <tr>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#adef-type-INPUT">type</a>="<a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#idx-password_input_control">password</a>"</code>
* <td>{@link #PASSWORD}
* <tr>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#edef-TEXTAREA">TEXTAREA</a></code>
* <td>-
* <td>{@link #TEXTAREA}
* <tr>
* <td><a name="file-select-control" target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#file-select">file select</a>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#edef-INPUT">INPUT</a></code>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#adef-type-INPUT">type</a>="file"</code>
* <td>{@link #FILE}
* <tr>
* <td><a name="hidden-control" target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#hidden-control">hidden controls</a>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#edef-INPUT">INPUT</a></code>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#adef-type-INPUT">type</a>="hidden"</code>
* <td>{@link #HIDDEN}
* <tr>
* <td><a name="object-control" target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#object-control">object controls</a>
* <td><code><a target="_blank" href="http://www.w3.org/TR/html401/struct/objects.html#edef-OBJECT">OBJECT</a></code>
* <td><code>-
* <td>-
* </table>
* <a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#reset-button-control">Reset buttons</a> and
* <a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#push-button-control">push buttons</a>
* have no associated <code>FormControlType</code> because they do not contribute to the
* <a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#form-data-set">form data set</a>
* of a <a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#submit-format">submitted</a> form,
* and so have no relevance to the methods provided in the {@link FormControl} and associated classes.
* If required they can be found and manipulated as normal {@linkplain Element elements}.
* <p>
* <a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#object-control">Object controls</a>
* have no associated <code>FormControlType</code> because any data they might contribute to the
* <a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#form-data-set">form data set</a>
* is entirely dependent on the
* <a target="_blank" href="http://www.w3.org/TR/html401/struct/objects.html#adef-classid">class</a> of object,
* the interpretation of which is is beyond the scope of this library.
* <p>
* This library does not consider the
* <code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#edef-OPTION">OPTION</a></code>
* elements found within
* <code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#edef-SELECT">SELECT</a></code>
* elements to be controls themselves, despite them being referred to as such in some
* <a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#adef-value-OPTION">parts</a>
* of the HTML 4.01 specification.
* Hence the absence of an <code>OPTION</code> control type.
*
* @see FormControl
* @see FormField
*/
public enum FormControlType {
/**
* The form control type given to a <a href="#submit-button">submit button</a> control implemented using a
* <code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#edef-BUTTON">BUTTON</a></code> element.
* <p>
* <dl>
* <dt>Example:</dt>
* <dd><code><button type="submit" name="FieldName" value="PredefinedValue">Send</button></code>
* <dt>Properties:</dt>
* <dd>
* <code>{@link #getElementName()} = {@link HTMLElementName#BUTTON}</code><br />
* <code>{@link #hasPredefinedValue()} = true</code><br />
* <code>{@link #isSubmit()} = true</code><br />
* </dl>
*/
BUTTON (HTMLElementName.BUTTON,true,true),
/**
* The form control type given to a <a href="#checkbox-control">checkbox</a> control.
* <p>
* <dl>
* <dt>Example:</dt>
* <dd><code><input type="checkbox" name="FieldName" value="PredefinedValue" /></code>
* <dt>Properties:</dt>
* <dd>
* <code>{@link #getElementName()} = {@link HTMLElementName#INPUT}</code><br />
* <code>{@link #hasPredefinedValue()} = true</code><br />
* <code>{@link #isSubmit()} = false</code><br />
* </dl>
*/
CHECKBOX (HTMLElementName.INPUT,true,false),
/**
* The form control type given to a <a href="#file-select-control">file select</a> control.
* <p>
* This library considers the <a href="FormControl.html#SubmissionValue">submission value</a> of this type of control
* to be consist of only the selected file name, regardless of whether the file content would normally be included in the
* <a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#form-data-set">form data set</a>.
* <p>
* To determine manually whether the file content is included in the form data set, the
* <code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#adef-enctype">enctype</a></code>
* attribute of the control's associated <a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#edef-FORM">FORM</a>
* element can be examined.
* Although the exact behaviour is not defined in the HTML 4.01 specification, the convention is that the content
* is not included unless an <code>enctype</code> value of
* "<code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#didx-multipartform-data">multipart/form-data</a></code>"
* is specified.
* <p>
* For more information see the
* <a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4">HTML 4.01 specification section 17.13.4 - Form content types</a>.
* <p>
* <dl>
* <dt>Example:</dt>
* <dd><code><input type="file" name="FieldName" value="DefaultFileName" /></code>
* <dt>Properties:</dt>
* <dd>
* <code>{@link #getElementName()} = {@link HTMLElementName#INPUT}</code><br />
* <code>{@link #hasPredefinedValue()} = false</code><br />
* <code>{@link #isSubmit()} = false</code><br />
* </dl>
*/
FILE (HTMLElementName.INPUT,false,false),
/**
* The form control type given to a <a href="#hidden-control">hidden</a> control.
* <p>
* <dl>
* <dt>Example:</dt>
* <dd><code><input type="hidden" name="FieldName" value="DefaultValue" /></code>
* <dt>Properties:</dt>
* <dd>
* <code>{@link #getElementName()} = {@link HTMLElementName#INPUT}</code><br />
* <code>{@link #hasPredefinedValue()} = false</code><br />
* <code>{@link #isSubmit()} = false</code><br />
* </dl>
* Note that {@link #hasPredefinedValue()} returns <code>false</code> for this control type
* because the value of hidden fields is usually set via server or client side scripting.
*/
HIDDEN (HTMLElementName.INPUT,false,false),
/**
* The form control type given to a <a href="#submit-button">submit button</a> control implemented using an
* <code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#edef-INPUT">INPUT</a></code> element with attribute
* <code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#adef-type-INPUT">type</a>="<a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#input-control-types">image</a>"</code>.
* <p>
* See the description under the heading "image" in the
* <a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#h-17.4.1">HTML 4.01 specification section 17.4.1 - Form control types created with INPUT</a>.
* <p>
* When a {@linkplain FormControl form control} of type <code>IMAGE</code> is present in the form used to
* {@linkplain FormFields#FormFields(Collection) construct} a {@link FormFields} instance, three separate
* {@link FormField} objects are created for the one control.
* One has the {@linkplain FormField#getName() name} specified in the
* <code><a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#adef-name-INPUT">name</a></code>
* attribute of the <code>INPUT</code> element, and the other two have this name with the suffixes
* "<code>.x</code>" and "<code>.y</code>" appended to them to represent the additional
* <a target="_blank" href="http://www.w3.org/TR/html401/interact/forms.html#idx-coordinates">click coordinates</a>
* submitted by this control when activated using a pointing device.
* <p>
* This type of control is also mentioned in the
* <a target="_blank" href="http://www.w3.org/TR/html401/struct/objects.html#h-13.6.2">HTML 4.01 specification section 13.6.2 - Server-side image maps</a>.
* <p>
* <dl>
* <dt>Example:</dt>
* <dd><code><input type="image" name="FieldName" src="ImageURL" value="PredefinedValue" /></code>
* <dt>Properties:</dt>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -