org.htmlparser.parserapplications.filterbuilder.wrappers

Class HasAttributeFilterWrapper

Implemented Interfaces:
ActionListener, Cloneable, DocumentListener, NodeFilter, Serializable

public class HasAttributeFilterWrapper
extends Filter
implements ActionListener, DocumentListener

Wrapper for HasAttributeFilters.

Field Summary

protected JComboBox
mAttributeName
Combo box for attribute name.
protected JTextArea
mAttributeValue
Value to check for.
protected HasAttributeFilter
mFilter
The underlying filter.
protected JCheckBox
mValued
The check box for has value.

Fields inherited from class org.htmlparser.parserapplications.filterbuilder.Filter

mWrappers

Constructor Summary

HasAttributeFilterWrapper()
Create a wrapper over a new HasAttributeFilter.

Method Summary

boolean
accept(Node node)
Predicate to determine whether or not to keep the given node.
void
actionPerformed(ActionEvent event)
Invoked when an action occurs on the combo box.
protected void
addAttributeValues(Set set, Node node)
Add the attribute values from the node to the set of attribute values.
protected void
addAttributes(Set set, Node node)
Add the attribute names from the node to the set of attribute names.
void
changedUpdate(DocumentEvent e)
Handle a change update event.
String
getDescription()
Get the name of the filter.
String
getIconSpec()
Get the resource name for the icon.
NodeFilter
getNodeFilter()
Get the underlying node filter object.
NodeFilter[]
getSubNodeFilters()
Get the underlying node filter's subordinate filters.
void
insertUpdate(DocumentEvent e)
Handle an insert update event.
void
removeUpdate(DocumentEvent e)
Handle a remove update event.
void
setNodeFilter(NodeFilter filter, Parser context)
Assign the underlying node filter for this wrapper.
void
setSubNodeFilters(NodeFilter[] filters)
Assign the underlying node filter's subordinate filters.
String
toJavaCode(StringBuffer out, int[] context)
Convert this filter into Java code.

Methods inherited from class org.htmlparser.parserapplications.filterbuilder.Filter

deconstitute, deserialize, getDescription, getEnclosed, getIcon, getIconSpec, getNodeFilter, getSubNodeFilters, instantiate, newline, pickle, reconstitute, serialize, setExpanded, setNodeFilter, setSelected, setSubNodeFilters, spaces, toJavaCode, toString, unpickle, wrap

Field Details

mAttributeName

protected JComboBox mAttributeName
Combo box for attribute name.

mAttributeValue

protected JTextArea mAttributeValue
Value to check for.

mFilter

protected HasAttributeFilter mFilter
The underlying filter.

mValued

protected JCheckBox mValued
The check box for has value.

Constructor Details

HasAttributeFilterWrapper

public HasAttributeFilterWrapper()
Create a wrapper over a new HasAttributeFilter.

Method Details

accept

public boolean accept(Node node)
Predicate to determine whether or not to keep the given node. The behaviour based on this outcome is determined by the context in which it is called. It may lead to the node being added to a list or printed out. See the calling routine for details.
Specified by:
accept in interface NodeFilter
Parameters:
node - The node to test.
Returns:
true if the node is to be kept, false if it is to be discarded.

actionPerformed

public void actionPerformed(ActionEvent event)
Invoked when an action occurs on the combo box.
Parameters:
event - Details about the action event.

addAttributeValues

protected void addAttributeValues(Set set,
                                  Node node)
Add the attribute values from the node to the set of attribute values.
Parameters:
set - The set to add to.
node - The node with attributes to add.

addAttributes

protected void addAttributes(Set set,
                             Node node)
Add the attribute names from the node to the set of attribute names.
Parameters:
set - The set to add to.
node - The node with attributes to add.

changedUpdate

public void changedUpdate(DocumentEvent e)
Handle a change update event.
Parameters:
e - Details about the change event.

getDescription

public String getDescription()
Get the name of the filter.
Overrides:
getDescription in interface Filter
Returns:
A descriptive name for the filter.

getIconSpec

public String getIconSpec()
Get the resource name for the icon.
Overrides:
getIconSpec in interface Filter
Returns:
The icon resource specification.

getNodeFilter

public NodeFilter getNodeFilter()
Get the underlying node filter object.
Overrides:
getNodeFilter in interface Filter
Returns:
The node filter object suitable for serialization.

getSubNodeFilters

public NodeFilter[] getSubNodeFilters()
Get the underlying node filter's subordinate filters.
Overrides:
getSubNodeFilters in interface Filter
Returns:
The node filter object's contained filters.

insertUpdate

public void insertUpdate(DocumentEvent e)
Handle an insert update event.
Parameters:
e - Details about the insert event.

removeUpdate

public void removeUpdate(DocumentEvent e)
Handle a remove update event.
Parameters:
e - Details about the remove event.

setNodeFilter

public void setNodeFilter(NodeFilter filter,
                          Parser context)
Assign the underlying node filter for this wrapper.
Overrides:
setNodeFilter in interface Filter
Parameters:
filter - The filter to wrap.
context - The parser to use for conditioning this filter. Some filters need contextual information to provide to the user, i.e. for tag names or attribute names or values, so the Parser context is provided.

setSubNodeFilters

public void setSubNodeFilters(NodeFilter[] filters)
Assign the underlying node filter's subordinate filters.
Overrides:
setSubNodeFilters in interface Filter
Parameters:
filters - The filters to insert into the underlying node filter.

toJavaCode

public String toJavaCode(StringBuffer out,
                         int[] context)
Convert this filter into Java code. Output whatever text necessary and return the variable name.
Overrides:
toJavaCode in interface Filter
Parameters:
out - The output buffer.
context - Three integers as follows:
  • indent level - the number of spaces to insert at the beginning of each line
  • filter number - the next available filter number
  • filter array number - the next available array of filters number
  • Returns:
    The variable name to use when referencing this filter (usually "filter" + context[1]++)

    HTML Parser is an open source library released under LGPL. SourceForge.net