public class Form
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
Form(ScrapingSession session,
ScrapeableFile scrapeableFile,
java.lang.String formText)
Constructs a Form from text, parsing it into it's parts
|
Modifier and Type | Method and Description |
---|---|
void |
addInput(Input input)
Adds a new input value to this form
|
java.lang.String |
getAction()
Gets the action this form will perform.
|
java.lang.String |
getEncodeType()
Returns the EncodeType for the object
|
java.util.List<Input> |
getFormInputs()
Returns the inputs parsed for this form.
|
Input |
getInputByName(java.lang.String name)
Gets the first input with the given name.
|
java.lang.String |
getMethod()
Gets the method, GET or POST, of the form
|
java.lang.String |
getName()
Gets the name of the current form
|
boolean |
removeInput(Input input)
Removes an input from the form
|
boolean |
removeInput(java.lang.String name)
Removes an input from the form.
|
void |
setAction(java.lang.String action)
Sets the action for the form
|
void |
setEncodeType(java.lang.String encodeType)
Sets the EncodeType for the object
|
void |
setMethod(java.lang.String method)
Sets the method.
|
void |
setName(java.lang.String name)
Sets the name of the form
|
void |
setScrapeableFileParameters(ScrapeableFile scrapeableFile)
Sets the parameters on a scrapeable file to the input values as determined by the current form settings
|
void |
setValue(java.lang.String name,
java.lang.Object value)
Sets the value for a given name, overwriting the value it contained before.
|
void |
setValueChecked(java.lang.String name,
java.lang.Object value)
Sets the value for a given name, overwriting the value it contained before.
|
java.lang.String |
toString() |
public Form(@NotNull ScrapingSession session, @Nullable ScrapeableFile scrapeableFile, @NotNull java.lang.String formText)
session
- The scraping session associated with the formscrapeableFile
- The scrapeable file used to resolve URLSformText
- HTML containing the form input elements, and possibly (useful) the form tag itselfpublic void setValue(@NotNull java.lang.String name, @NotNull java.lang.Object value)
name
- The keyvalue
- The valuepublic void setValueChecked(@NotNull java.lang.String name, @NotNull java.lang.Object value)
name
- The keyvalue
- The valuejava.lang.IllegalArgumentException
- If the value was invalid for the type or the name wasn't found on the form@Nullable public java.lang.String getName()
public void setName(@Nullable java.lang.String name)
name
- The new name for the form@Nullable public java.lang.String getMethod()
public void setMethod(@Nullable java.lang.String method)
method
- The new method used by the form@Nullable public java.lang.String getAction()
public void setAction(@Nullable java.lang.String action)
action
- The new action URL for the formpublic void setScrapeableFileParameters(@Nullable ScrapeableFile scrapeableFile)
scrapeableFile
- The scrapeable file on which to set the parameterspublic java.util.List<Input> getFormInputs()
public void addInput(@Nullable Input input)
input
- The input to be added@Nullable public java.lang.String getEncodeType()
public void setEncodeType(@Nullable java.lang.String encodeType)
encodeType
- The new value for EncodeType@Nullable public Input getInputByName(@Nullable java.lang.String name)
name
- The name of the inputpublic boolean removeInput(@NotNull Input input)
input
- The input to remove from the Formpublic boolean removeInput(@NotNull java.lang.String name)
name
- The name of the input to remove from the Form@NotNull public java.lang.String toString()
toString
in class java.lang.Object