Menu

public constructors for html classes

2002-09-26
2002-12-04
  • Troy Waldrep

    Troy Waldrep - 2002-09-26

    Hi,

    I'm building a xpath layer to use on top of httpunit in our environment and would like to be able to instantiate my own instances of WebForm, WebImage, WebLink, WebTable, etc.  Unfortunately, the constructors are either package-scoped or private (WebTable).  Would it be possible to open these classes up a little more or at least provide public factories to get the appropriate instances of HttpUnit classes associated with provided DOM Nodes?

     
    • Bill Smith

      Bill Smith - 2002-12-04

      I ran into the same problem.  I'm trying to call httpunit from Jython.

      Jython is a Python interpreter written in Java.  Using Jython, you can call Java methods from a Python script.  Jython uses Java reflection to lookup and invoke Java methods.

      The TableCell class inherits most of its methods from the ParsedHTML class.  Since ParsedHTML is  package-private, I can do this:

      links = cell.getLinks();

      but I can't do this:

      Method method = cell.getClass().getMethod("getLinks", new Class[0]);
      links = (WebLink[]) method.invoke(cell, new Object[0]);

      Would the httpunit authors mind making ParsedHTML a public class?

       

Log in to post a comment.

Auth0 Logo