Package org.htmlparser.scanners

Examples of org.htmlparser.scanners.TagScanner


    }

    public void testRemoveChars()
    {
        String test = "hello\nworld\n\tqsdsds";
        TagScanner scanner = new TagScanner()
        {
            public Tag scan(
                Tag tag,
                String url,
                NodeReader reader,
View Full Code Here


    }

    public void testRemoveChars2()
    {
        String test = "hello\r\nworld\r\n\tqsdsds";
        TagScanner scanner = new TagScanner()
        {
            public Tag scan(
                Tag tag,
                String url,
                NodeReader reader,
                String currLine)
            {
                return null;
            }
            public boolean evaluate(String s, TagScanner previousOpenScanner)
            {
                return false;
            }
            public String[] getID()
            {
                return null;
            }

        };
        String result = scanner.removeChars(test, "\r\n");
        assertEquals("Removing Chars", "helloworld\tqsdsds", result);
    }
View Full Code Here

    {
        createParser("");
        parser.registerScanners();
        parser.removeScanner(new FormScanner("", parser));
        Map scanners = parser.getScanners();
        TagScanner scanner = (TagScanner) scanners.get("FORM");
        assertNull("shouldnt have found scanner", scanner);
    }
View Full Code Here

            boolean found = false;
            Node retVal = null;
            // Find the first word in the scanners
            String firstWord = extractWord(tagContents.toString());
            // Now, get the scanner associated with this.
            TagScanner scanner = (TagScanner) scanners.get(firstWord);

            // Now do a deep check
            if (scanner != null
                && scanner.evaluate(
                    tagContents.toString(),
                    reader.getPreviousOpenScanner()))
            {
                found = true;
                TagScanner save;
                save = reader.getPreviousOpenScanner();
                reader.setPreviousOpenScanner(scanner);
                retVal = scanner.createScannedNode(this, url, reader, tagLine);
                reader.setPreviousOpenScanner(save);
            }
View Full Code Here

            boolean found = false;
            Node retVal = null;
            // Find the first word in the scanners
            String firstWord = extractWord(tagContents.toString());
            // Now, get the scanner associated with this.
            TagScanner scanner = (TagScanner) scanners.get(firstWord);

            // Now do a deep check
            if (scanner != null
                && scanner.evaluate(
                    tagContents.toString(),
                    reader.getPreviousOpenScanner()))
            {
                found = true;
                TagScanner save;
                save = reader.getPreviousOpenScanner();
                reader.setPreviousOpenScanner(scanner);
                retVal = scanner.createScannedNode(this, url, reader, tagLine);
                reader.setPreviousOpenScanner(save);
            }
View Full Code Here

                    // There is a filter. Find if the associated filter of this node
                    // matches the specified filter
                    if (!(node instanceof Tag))
                        continue;
                    Tag tag = (Tag) node;
                    TagScanner scanner = tag.getThisScanner();
                    if (scanner == null)
                        continue;

                    String tagFilter = scanner.getFilter();
                    if (tagFilter == null)
                        continue;
                    if (tagFilter.equals(filter))
                        System.out.println(node.toString());
                }
View Full Code Here

    assertTrue("OPTION tag could not be identified", TagScanner.isXMLTagFound(node, "OPTION"));
  }

  public void testRemoveChars() {
    String test = "hello\nworld\n\tqsdsds";
    TagScanner scanner = new TagScanner() {
      public Tag scan(Tag tag, String url, NodeReader reader, String currLine) {
        return null;
      }

      public boolean evaluate(String s, TagScanner previousOpenScanner) {
View Full Code Here

    assertEquals("Removing Chars", "helloworld\tqsdsds", result);
  }

  public void testRemoveChars2() {
    String test = "hello\r\nworld\r\n\tqsdsds";
    TagScanner scanner = new TagScanner() {
      public Tag scan(Tag tag, String url, NodeReader reader, String currLine) {
        return null;
      }

      public boolean evaluate(String s, TagScanner previousOpenScanner) {
        return false;
      }

      public String[] getID() {
        return null;
      }

    };
    String result = scanner.removeChars(test, "\r\n");
    assertEquals("Removing Chars", "helloworld\tqsdsds", result);
  }
View Full Code Here

      boolean found = false;
      Node retVal = null;
      // Find the first word in the scanners
      String firstWord = extractWord(tagContents.toString());
      // Now, get the scanner associated with this.
      TagScanner scanner = (TagScanner) scanners.get(firstWord);

      // Now do a deep check
      if (scanner != null && scanner.evaluate(tagContents.toString(), reader.getPreviousOpenScanner())) {
        found = true;
        TagScanner save;
        save = reader.getPreviousOpenScanner();
        reader.setPreviousOpenScanner(scanner);
        retVal = scanner.createScannedNode(this, url, reader, tagLine);
        reader.setPreviousOpenScanner(save);
      }
View Full Code Here

          // node
          // matches the specified filter
          if (!(node instanceof Tag))
            continue;
          Tag tag = (Tag) node;
          TagScanner scanner = tag.getThisScanner();
          if (scanner == null)
            continue;

          String tagFilter = scanner.getFilter();
          if (tagFilter == null)
            continue;
          if (tagFilter.equals(filter))
            System.out.println(node.toString());
        }
View Full Code Here

TOP

Related Classes of org.htmlparser.scanners.TagScanner

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.