gt:                     mParser = new Parser (url);
context: // HTMLParser Library - A java-based parser for HTML
  // http://htmlparser.org
  // Copyright (C) 2006 Derrick Oswald
  //
  // Revision Control Information
  //
  // $URL: file:///svn/p/htmlparser/code/tags/HTMLParserProject-2.1/parser/src/main/java/org/htmlparser/beans/FilterBean.java $
  // $Author: derrickoswald $
  // $Date: 2006-09-16 14:44:17 +0000 (Sat, 16 Sep 2006) $
  // $Revision: 4 $
  //
  // This library is free software; you can redistribute it and/or
  // modify it under the terms of the Common Public License; either
  // version 1.0 of the License, or (at your option) any later version.
  //
  // This library is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  // Common Public License for more details.
  //
  // You should have received a copy of the Common Public License
  // along with this library; if not, the license is available from
  // the Open Source Initiative (OSI) website:
  //   http://opensource.org/licenses/cpl1.0.php
  
  package org.htmlparser.beans;
  
  import java.beans.PropertyChangeListener;
  import java.beans.PropertyChangeSupport;
  import java.io.Serializable;
  import java.net.URLConnection;
  
  import org.htmlparser.NodeFilter;
  import org.htmlparser.Parser;
  import org.htmlparser.util.NodeList;
  import org.htmlparser.util.ParserException;
  import org.htmlparser.util.EncodingChangeException;
  
  /**
   * Extract nodes from a URL using a filter.
   * <pre>
   * <code>
   *     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 ());
   * </code>
   * </pre>
   */
  public class FilterBean
      implements
          Serializable
  {
      /**
       * Property name in event where the URL contents changes.
       */
      public static final String PROP_NODES_PROPERTY = "nodes";
  
      /**
       * Property name in event where the URL contents changes.
       */
      public static final String PROP_TEXT_PROPERTY = "text";
  
      /**
       * Property name in event where the URL changes.
       */
      public static final String PROP_URL_PROPERTY = "URL";
  
      /**
       * Property name in event where the connection changes.
       */
      public static final String PROP_CONNECTION_PROPERTY = "connection";
  
      /**
       * Bound property support.
       */
      protected PropertyChangeSupport mPropertySupport;
  
      /**
       * The parser used to filter.
       */
      protected Parser mParser;
  
      /**
       * The filter set.
       */
      protected NodeFilter[] mFilters;
  
      /**
       * The nodes extracted from the URL.
       */
      protected NodeList mNodes;
  
      /**
       * The recursion behaviour for elements of the filter array.
       * If <code>true</code> the filters are applied recursively.
       * @see org.htmlparser.util.NodeList#extractAllNodesThatMatch(NodeFilter, boolean).
       */
      protected boolean mRecursive;
  
     /**
       * Create a FilterBean object.
       */
      public FilterBean ()
      {
          mPropertySupport = new PropertyChangeSupport (this);
          mParser = new Parser ();
          mFilters = null;
          mNodes = null;
          mRecursive = true;
      }
  
      //
      // internals
      //
  
      /**
       * Assign the <code>Nodes</code> property, firing the property change.
       * @param nodes The new value of the <code>Nodes</code> property.
       */
      protected void updateNodes (NodeList nodes)
      {
          NodeList oldValue;
          String oldText;
          String newText;
  
          if ((null == mNodes) || !mNodes.equals (nodes))
          {
              oldValue = mNodes;
              if (null != oldValue)
                  oldText = getText ();
              else
                  oldText = "";
              if (null == oldText)
                  oldText = "";
              mNodes = nodes;
              if (null != mNodes) // TODO: fix this null problem
                  newText = getText ();
              else // StringBean finds no nodes
                  newText = "";
              if (null == newText)
                  newText = "";
              mPropertySupport.firePropertyChange (
                  PROP_NODES_PROPERTY, oldValue, nodes);
              if (!newText.equals (oldText))
                  mPropertySupport.firePropertyChange (
                      PROP_TEXT_PROPERTY, oldText, newText);
          }
      }
  
      /**
       * Apply each of the filters.
       * The first filter is applied to the output of the parser.
       * Subsequent filters are applied to the output of the prior filter.
       * @return 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.
       */
      protected NodeList applyFilters ()
          throws
              ParserException
      {
          NodeFilter[] filters;
          NodeList ret;
  
          ret = mParser.parse (null);
          filters = getFilters ();
          if (null != filters)
              for (int i = 0; i < filters.length; i++)
                  ret = ret.extractAllNodesThatMatch (filters[i], mRecursive);
  
          return (ret);
      }
  
      /**
       * Fetch the URL contents and filter it.
       * Only do work if there is a valid parser with it's URL set.
       */
      protected void setNodes ()
      {
          NodeList list;
  
          if (null != getURL ())
              try
              {
                  list = applyFilters ();
                  updateNodes (list);
              }
              catch (EncodingChangeException ece)
              {
                  try
                  {   // try again with the encoding now in force
                      mParser.reset ();
                      list = applyFilters ();
                      updateNodes (list);
                  }
                  catch (ParserException pe)
                  {
                      updateNodes (new NodeList ());
                  }
               }
              catch (ParserException pe)
              {
                  updateNodes (new NodeList ());
              }
      }
  
      //
      // Property change support.
      //
  
      /**
       * Add a PropertyChangeListener to the listener list.
       * The listener is registered for all properties.
       * @param listener The PropertyChangeListener to be added.
       */
      public void addPropertyChangeListener (PropertyChangeListener listener)
      {
          mPropertySupport.addPropertyChangeListener (listener);
      }
  
      /**
       * Remove a PropertyChangeListener from the listener list.
       * This removes a registered PropertyChangeListener.
       * @param listener The PropertyChangeListener to be removed.
       */
      public void removePropertyChangeListener (PropertyChangeListener listener)
      {
          mPropertySupport.removePropertyChangeListener (listener);
      }
  
      //
      // Properties
      //
  
      /**
       * Return the nodes of the URL matching the filter.
       * This is the primary output of the bean.
       * @return The nodes from the URL matching the current filter.
       */
      public NodeList getNodes ()
      {
          if (null == mNodes)
              setNodes ();
  
          return (mNodes);
      }
  
      /**
       * Get the current URL.
       * @return The URL from which text has been extracted, or <code>null</code>
       * if this property has not been set yet.
       */
      public String getURL ()
      {
           return ((null != mParser) ? mParser.getURL () : null);
      }
  
      /**
       * Set the URL to extract strings from.
       * The text from the URL will be fetched, which may be expensive, so this
       * property should be set last.
       * @param url The URL that text should be fetched from.
       */
      public void setURL (String url)
      {
          String old;
          URLConnection conn;
  
          old = getURL ();
          conn = getConnection ();
          if (((null == old) && (null != url)) || ((null != old)
              && !old.equals (url)))
          {
              try
              {
                  if (null == mParser)
  