Agent System POND 1.2 (28.2.2002)

FIM.Util.WWW.Form
Class SelectableElement

java.lang.Object
  |
  +--FIM.Util.WWW.Form.FormElement
        |
        +--FIM.Util.WWW.Form.SelectableElement
All Implemented Interfaces:
Element, Serializable
Direct Known Subclasses:
InputCheckboxElement, InputRadioElement

public abstract class SelectableElement
extends FormElement

Parent class for elements, which may be selected (on/off only). All those elements must belong to a ElementGroup (which might contain only a single selectable element). Forms are stored flat, so the groups are not the parent of those elements!

Version:
1.0, 1.7.2000
Author:
Michael Sonntag
See Also:
ElementGroup, Serialized Form

Field Summary
(package private)  boolean selected
          Whether this element is selected or not.
 
Fields inherited from class FIM.Util.WWW.Form.FormElement
attributes, children
 
Constructor Summary
SelectableElement(HTMLDocument doc, Element parent, ElementGroup group, int startOffs, int endOffs, String name, String value, boolean initiallySelected)
          Creates a new INPUT/HIDDEN element, which just stores a piece of text.
 
Method Summary
 void deselect()
          Sets the state of the element to not selected.
 String getEncoded()
          Selectable elements are never encoded (this is done by the group, they belong to), so throws always a IllegalStateException.
 ElementGroup getGroup()
          Retrieve the group this element belongs to.
 String getValue()
          Retrieve the value of this element.
 boolean isSelected()
          Retrieve whether this element is currently selected or not.
 int match(String[] matchStr)
          Matches this element against a number of strings and returns a measure for matching them. 0=no match, 100=perfect match.
Extension to FormElement: Value match=70 exact, 60 substring
 void reset()
          Resets this element to its initial state.
 void select()
          Sets the state of the element to selected.
 void setSelected(boolean isSelected)
          Sets the state of this element.
 String toString()
          Returns a string representation of the selectable element.
 
Methods inherited from class FIM.Util.WWW.Form.FormElement
getAttributes, getDocument, getElement, getElementCount, getElementIndex, getEndOffset, getLabel, getName, getParentElement, getStartOffset, isLeaf, setLabel
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

selected

boolean selected
Whether this element is selected or not. Package access for SingleSelectionGroup.
Constructor Detail

SelectableElement

public SelectableElement(HTMLDocument doc,
                         Element parent,
                         ElementGroup group,
                         int startOffs,
                         int endOffs,
                         String name,
                         String value,
                         boolean initiallySelected)
Creates a new INPUT/HIDDEN element, which just stores a piece of text.
Parameters:
doc - the document this element belongs to
parent - the parent of this element
group - the group this element belongs to
startOffs - start offset of the element in the document
endOffs - end offset of the element in the document
name - the name of the element
value - the value of the element (which is submitted if it is selected) (Must be provided according to the specification, although not always done; see HTMLForm.parseForm(HTMLDocument.Iterator)() for more)
initiallySelected - if true, this element is selected at the beginning
Method Detail

getGroup

public ElementGroup getGroup()
Retrieve the group this element belongs to.
Parameters:
the - group of this element

reset

public void reset()
Resets this element to its initial state.
Overrides:
reset in class FormElement

setSelected

public void setSelected(boolean isSelected)
Sets the state of this element.
Parameters:
isSelected - if true, the element is selected, otherwise not

select

public void select()
Sets the state of the element to selected.

deselect

public void deselect()
Sets the state of the element to not selected.

isSelected

public boolean isSelected()
Retrieve whether this element is currently selected or not.
Returns:
true if this element is selected, false otherwise

getValue

public String getValue()
Retrieve the value of this element.
Returns:
the value of the element

getEncoded

public String getEncoded()
Selectable elements are never encoded (this is done by the group, they belong to), so throws always a IllegalStateException.
Overrides:
getEncoded in class FormElement
Following copied from class: FIM.Util.WWW.Form.FormElement
Returns:
the element in encoded form or an empty string ("") if it shall not be passed to the server
See Also:
URLEncoder

match

public int match(String[] matchStr)
Matches this element against a number of strings and returns a measure for matching them. 0=no match, 100=perfect match.
Extension to FormElement: Value match=70 exact, 60 substring
Overrides:
match in class FormElement
Parameters:
matchStr - an array of strings which are matched against this element
Returns:
measure how much this element matches the parameter

toString

public String toString()
Returns a string representation of the selectable element.
Overrides:
toString in class FormElement
Returns:
string representation of the form element

Agent System POND 1.2 (28.2.2002)

Submit a bug

Copyright 2001,2002 Michael Sonntag & Institute for Information Processing and Microprocessor Technology (FIM), Johannes-Kepler-University Linz, Altenbergerstr. 69, A-4040 Linz, Austria.