org.htmlparser.beans
public class FilterBean extends Object implements Serializable
FilterBean fb = new FilterBean ("http://cbc.ca");
fb.setFilters (new NodeFilter[] { new TagNameFilter ("META") });
fb.setURL ("http://cbc.ca");
System.out.println (fb.getNodes ().toHtml ());
Field Summary | |
---|---|
protected NodeFilter[] | mFilters
The filter set. |
protected NodeList | mNodes
The nodes extracted from the URL. |
protected Parser | mParser
The parser used to filter. |
protected PropertyChangeSupport | mPropertySupport
Bound property support. |
protected boolean | mRecursive
The recursion behaviour for elements of the filter array.
|
static String | PROP_CONNECTION_PROPERTY
Property name in event where the connection changes. |
static String | PROP_NODES_PROPERTY
Property name in event where the URL contents changes. |
static String | PROP_TEXT_PROPERTY
Property name in event where the URL contents changes. |
static String | PROP_URL_PROPERTY
Property name in event where the URL changes. |
Constructor Summary | |
---|---|
FilterBean()
Create a FilterBean object. |
Method Summary | |
---|---|
void | addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list.
|
protected NodeList | applyFilters()
Apply each of the filters.
|
URLConnection | getConnection()
Get the current connection. |
NodeFilter[] | getFilters()
Get the current filter set. |
NodeList | getNodes()
Return the nodes of the URL matching the filter.
|
Parser | getParser()
Get the parser used to fetch nodes. |
boolean | getRecursive()
Get the current recursion behaviour. |
String | getText()
Convenience method to apply a StringBean to the filter results.
|
String | getURL()
Get the current URL. |
static void | main(String[] args)
Unit test. |
void | removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list.
|
void | setConnection(URLConnection connection)
Set the parser's connection.
|
void | setFilters(NodeFilter[] filters)
Set the filters for the bean.
|
protected void | setNodes()
Fetch the URL contents and filter it.
|
void | setParser(Parser parser)
Set the parser for the bean.
|
void | setRecursive(boolean recursive)
Set the recursion behaviour. |
void | setURL(String url)
Set the URL to extract strings from.
|
protected void | updateNodes(NodeList nodes)
Assign the Nodes property, firing the property change. |
true
the filters are applied recursively.See Also: .
Parameters: listener The PropertyChangeListener to be added.
Returns: A list of nodes passed through all filters. If there are no filters, returns the entire page.
Throws: ParserException If an encoding change occurs or there is some other problem.
Returns: The connection that the parser has or null
if it
hasn't been set or the parser hasn't been constructed yet.
Returns: The current filters.
Returns: The nodes from the URL matching the current filter.
Returns: The parser used by the bean.
Returns: The recursion (applies to children, children's children, etc) behavior currently being used.
Returns: The textual contents of the nodes that pass through the filter set, as collected by the StringBean.
Returns: The URL from which text has been extracted, or null
if this property has not been set yet.
Parameters: args Pass arg[0] as the URL to process, and optionally a node name for filtering.
Parameters: listener The PropertyChangeListener to be removed.
Parameters: connection New value of property Connection.
Parameters: filters The filter set to use.
Parameters: parser The parser to use.
Parameters: recursive If true
the
extractAllNodesThatMatch()
call is performed recursively.
See Also: .
Parameters: url The URL that text should be fetched from.
Nodes
property, firing the property change.Parameters: nodes The new value of the Nodes
property.
HTML Parser is an open source library released under LGPL. | |