Deprecated API

Deprecated Classes
org.htmlparser.nodeDecorators.AbstractNodeDecorator
          Use direct subclasses or dynamic proxies instead.

Use either direct subclasses of the appropriate node and set them on the PrototypicalNodeFactory, or use a dynamic proxy implementing the required node type interface. In the former case this avoids the wrapping and delegation, while the latter case handles the wrapping and delegation without this class.

Here is an example of how to use dynamic proxies to accomplish the same effect as using decorators to wrap Text nodes:

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

import org.htmlparser.Parser;
import org.htmlparser.PrototypicalNodeFactory;
import org.htmlparser.Text;
import org.htmlparser.nodes.TextNode;
import org.htmlparser.util.ParserException;

public class TextProxy
    implements
        InvocationHandler
{
    protected Object mObject;

    public static Object newInstance (Object object)
    {
        Class cls;

        cls = object.getClass ();
        return (Proxy.newProxyInstance (
            cls.getClassLoader (),
            cls.getInterfaces (),
            new TextProxy (object)));
    }

    private TextProxy (Object object)
    {
        mObject = object;
    }

    public Object invoke (Object proxy, Method m, Object[] args)
        throws Throwable
    {
        Object result;
        String name;
        try
        {
            result = m.invoke (mObject, args);
            name = m.getName ();
            if (name.equals ("clone"))
                result = newInstance (result); // wrap the cloned object
            else if (name.equals ("doSemanticAction")) // or other methods
               System.out.println (mObject); // do the needful on the TextNode
        }
        catch (InvocationTargetException e)
        {
            throw e.getTargetException ();
        }
        catch (Exception e)
        {
            throw new RuntimeException ("unexpected invocation exception: " +
                                       e.getMessage());
        }
        finally
        {
        }

        return (result);
    }

    public static void main (String[] args)
        throws
            ParserException
    {
        // create the wrapped text node and set it as the prototype
        Text text = (Text) TextProxy.newInstance (new TextNode (null, 0, 0));
        PrototypicalNodeFactory factory = new PrototypicalNodeFactory ();
        factory.setTextPrototype (text);
        // perform the parse
        Parser parser = new Parser (args[0]);
        parser.setNodeFactory (factory);
        parser.parse (null);
    }
}
 

 
org.htmlparser.nodeDecorators.DecodingNode
          Use direct subclasses or dynamic proxies instead.

Use either direct subclasses of the appropriate node and set them on the PrototypicalNodeFactory, or use a dynamic proxy implementing the required node type interface.

 
org.htmlparser.nodeDecorators.EscapeCharacterRemovingNode
          Use direct subclasses or dynamic proxies instead.

Use either direct subclasses of the appropriate node and set them on the PrototypicalNodeFactory, or use a dynamic proxy implementing the required node type interface.

 
org.htmlparser.util.LinkProcessor
          Use a Page object instead. 
org.htmlparser.nodeDecorators.NonBreakingSpaceConvertingNode
          Use direct subclasses or dynamic proxies instead.

Use either direct subclasses of the appropriate node and set them on the PrototypicalNodeFactory, or use a dynamic proxy implementing the required node type interface.

 
org.htmlparser.StringNodeFactory
          Use PrototypicalNodeFactory#setTextPrototype(Text)

A more efficient implementation of affecting all string nodes, is to replace the Text node prototype in the PrototypicalNodeFactory with a custom TextNode that performs the required operation.

For example, if you were using:

 StringNodeFactory factory = new StringNodeFactory();
 factory.setDecode(true);
 
to decode all text issued from Text.toPlainTextString(), you would instead create a subclass of TextNode and set it as the prototype for text node generation:
 PrototypicalNodeFactory factory = new PrototypicalNodeFactory ();
 factory.setTextPrototype (new TextNode () {
     public String toPlainTextString()
     {
         return (org.htmlparser.util.Translate.decode (super.toPlainTextString ()));
     }
 });
 
Similar constructs apply to removing escapes and converting non-breaking spaces, which were the examples previously provided.

Using a subclass avoids the wrapping and delegation inherent in the decorator pattern, with subsequent improvements in processing speed and memory usage.

 
 

Deprecated Methods
org.htmlparser.util.LinkProcessor.constructUrl(String, String)
          Use Page.constructUrl() instead. 
org.htmlparser.util.Translate.convertToChar(String)
          Use decode. 
org.htmlparser.util.Translate.convertToChar(String, int, int)
          Use decode. 
org.htmlparser.util.Translate.convertToString(int)
          Use encode. 
org.htmlparser.util.LinkProcessor.extract(String, String)
          Use Page.getAbsoluteURL() instead. 
org.htmlparser.Parser.extractAllNodesThatAre(Class)
          Use extractAllNodesThatMatch (new NodeClassFilter (cls)). 
org.htmlparser.util.LinkProcessor.fixSpaces(String)
          Use Parser.fixSpaces() instead. 
org.htmlparser.Tag.getAttributes()
          Use getAttributesEx() instead. 
org.htmlparser.nodes.TagNode.getParsed()
          This method is deprecated. Use getAttributes() instead. 
org.htmlparser.tags.LinkTag.linkData()
          Use children() instead. 
org.htmlparser.util.LinkProcessor.removeLastSlash(String)
          Removing the last slash from a URL is a bad idea. 
org.htmlparser.Tag.setAttributes(Hashtable)
          Use setAttributesEx() instead.