Examples of StringBean


Examples of org.htmlparser.beans.StringBean

   * @return
   */
  public static String trimHtml(String html) {
    Parser parser = Parser.createParser(html, "GBK");
    if (parser != null) {
      StringBean sb = new StringBean();
      try {
        parser.visitAllNodesWith(sb);
        html = sb.getStrings();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    return html;
View Full Code Here

Examples of org.htmlparser.beans.StringBean

      assertEquals("Nodes before and after serialization differ", ((Node) vector.remove(0)).toHtml(),
          ((Node) enumeration.nextNode()).toHtml());
  }

  public void testSerializableStringBean() throws IOException, ClassNotFoundException, ParserException {
    StringBean sb;
    String text;
    byte[] data;

    sb = new StringBean();
    sb.setURL("http://htmlparser.sourceforge.net/test/example.html");
    text = sb.getStrings();

    data = pickle(sb);
    sb = (StringBean) unpickle(data);

    assertEquals("Strings before and after serialization differ", text, sb.getStrings());
  }
View Full Code Here

Examples of org.htmlparser.beans.StringBean

      assertEquals("Links before and after serialization differ", links[i], links2[i]);
    }
  }

  public void testStringBeanListener() {
    final StringBean sb;
    final Boolean hit[] = new Boolean[1];

    sb = new StringBean();
    hit[0] = Boolean.FALSE;
    sb.addPropertyChangeListener(new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent event) {
        if (event.getSource().equals(sb))
          if (event.getPropertyName().equals(StringBean.PROP_STRINGS_PROPERTY))
            hit[0] = Boolean.TRUE;
      }
    });

    hit[0] = Boolean.FALSE;
    sb.setURL("http://htmlparser.sourceforge.net/test/example.html");
    assertTrue("Strings property change not fired for URL change", hit[0].booleanValue());

    hit[0] = Boolean.FALSE;
    sb.setLinks(true);
    assertTrue("Strings property change not fired for links change", hit[0].booleanValue());
  }
View Full Code Here

Examples of org.htmlparser.beans.StringBean

   * @param links
   *            if <code>true</code> include hyperlinks in output.
   * @return The textual contents of the page.
   */
  public String extractStrings(boolean links) throws ParserException {
    StringBean sb;

    sb = new StringBean();
    sb.setLinks(links);
    sb.setURL(resource);

    return (sb.getStrings());
  }
View Full Code Here

Examples of org.htmlparser.beans.StringBean

         bos.close();

         String html = new String(bos.toByteArray());

         Parser parser = Parser.createParser(html, null);
         StringBean sb = new StringBean();

         // read links or not
         // sb.setLinks(true);

         // extract text
         parser.visitAllNodesWith(sb);

         String text = sb.getStrings();
         refined_text = (text != null) ? text : ""; // delete(text);

      }
      catch (ParserException e)
      {
View Full Code Here

Examples of stubs.validation.StringBean

    private InnerBean innerBean;
    private CollectionBean collectionBean;

    @Before
    public void setUp() throws Exception {
        stringBean = new StringBean();
        numberBean = new NumberBean();
        numberBean.setDoubleNumber(2);
        dateBean = new DateBean();
        innerBean = new InnerBean();
        innerBean.setInnerBean(new InnerBeanExtension());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.