Package org.htmlparser.filters

Examples of org.htmlparser.filters.NodeClassFilter


     * @see ParserUtils#splitTags (String input, String[] tags, boolean recursive, boolean insideTag).
     */
    public static String[] splitTags (String input, Class nodeType, boolean recursive, boolean insideTag)
        throws ParserException, UnsupportedEncodingException
    {
        return splitTags (input, new NodeClassFilter (nodeType), recursive, insideTag);
    }
View Full Code Here


     * @see ParserUtils#trimTags (String input, String[] tags, boolean recursive, boolean insideTag).
     */
    public static String trimTags (String input, Class nodeType)
        throws ParserException, UnsupportedEncodingException
    {
        return trimTags (input, new NodeClassFilter (nodeType), true, true);
    }
View Full Code Here

     * @see ParserUtils#trimTags (String input, String[] tags, boolean recursive, boolean insideTag).
     */
    public static String trimTags (String input, Class nodeType, boolean recursive, boolean insideTag)
        throws ParserException, UnsupportedEncodingException
    {
        return trimTags (input, new NodeClassFilter (nodeType), recursive, insideTag);
    }
View Full Code Here

        createParser(
            "<SPAN>The Refactoring Challenge</SPAN>" +
            "<SPAN>&#013;id: 6</SPAN>"
        );
        parser.setNodeFactory (new PrototypicalNodeFactory (new Span ()));
        assertSpanContent(parser.extractAllNodesThatMatch (new NodeClassFilter (Span.class)).toNodeArray ());
    }
View Full Code Here

     * @return The {@.html <TD>} tags contained by this tag.
     */
    public TableColumn[] getColumns ()
    {
        NodeList kids;
        NodeClassFilter cls;
        HasParentFilter recursion;
        NodeFilter filter;
        TableColumn[] ret;

        kids = getChildren ();
        if (null != kids)
        {
            cls = new NodeClassFilter (TableRow.class);
            recursion = new HasParentFilter (null);
            filter = new OrFilter (
                        new AndFilter (
                            cls,
                            new IsEqualFilter (this)),
                        new AndFilter ( // recurse up the parent chain
                            new NotFilter (cls), // but not past the first row
                            recursion));
            recursion.setParentFilter (filter);
            kids = kids.extractAllNodesThatMatch (
                // it's a column, and has this row as it's enclosing row
                new AndFilter (
                    new NodeClassFilter (TableColumn.class),
                    filter), true);
            ret = new TableColumn[kids.size ()];
            kids.copyToNodeArray (ret);
        }
        else
View Full Code Here

     * @return Table header tags contained in this row.
     */
    public TableHeader[] getHeaders ()
    {
        NodeList kids;
        NodeClassFilter cls;
        HasParentFilter recursion;
        NodeFilter filter;
        TableHeader[] ret;

        kids = getChildren ();
        if (null != kids)
        {
            cls = new NodeClassFilter (TableRow.class);
            recursion = new HasParentFilter (null);
            filter = new OrFilter (
                        new AndFilter (
                            cls,
                            new IsEqualFilter (this)),
                        new AndFilter ( // recurse up the parent chain
                            new NotFilter (cls), // but not past the first row
                            recursion));
            recursion.setParentFilter (filter);
            kids = kids.extractAllNodesThatMatch (
                // it's a header, and has this row as it's enclosing row
                new AndFilter (
                    new NodeClassFilter (TableHeader.class),
                    filter), true);
            ret = new TableHeader[kids.size ()];
            kids.copyToNodeArray (ret);
        }
        else
View Full Code Here

        NodeList list;

        guts = "<body>Now is the time for all good men..</body>";
        html = "<html>" + guts + "</html>";
        createParser (html);
        list = parser.extractAllNodesThatMatch (new NodeClassFilter (BodyTag.class));
        assertEquals ("only one element", 1, list.size ());
        assertType ("should be BodyTag", BodyTag.class, list.elementAt (0));
        BodyTag body = (BodyTag)list.elementAt (0);
        assertEquals ("only one child", 1, body.getChildCount ());
        assertSuperType ("should be Text", Text.class, body.getChildren ().elementAt (0));
View Full Code Here

                "<body>" +
                "</body>" +
                "</html>"
            );
            Node scriptNodes [] =
                parser.extractAllNodesThatMatch (new NodeClassFilter (ScriptTag.class)).toNodeArray ();
            assertType(
                "scriptnode",
                ScriptTag.class,
                scriptNodes[0]
            );
View Full Code Here

    Parser parser;
    NodeList list;
    List<String> versionsList = new ArrayList<String>();
    try {
      parser = new Parser (repositoryUrl);
      list = parser.extractAllNodesThatMatch(new NodeClassFilter(LinkTag.class));
    } catch (ParserException e) {
      System.err.println("Unable to read repository " + repositoryUrl);
      return null;
    }
   
View Full Code Here

    Parser parser;
    NodeList list;
    List<String> versionsList = new ArrayList<String>();
    try {
      parser = new Parser (url);
      list = parser.extractAllNodesThatMatch(new NodeClassFilter(LinkTag.class));
    } catch (ParserException e) {
      System.err.println("Unable to read repository " + url);
      return null;
    }
   
View Full Code Here

TOP

Related Classes of org.htmlparser.filters.NodeClassFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.