Examples of StringBean


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); //TODO make this configurable

         // 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 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 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); //TODO make this configurable

         // 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 org.htmlparser.beans.StringBean

      if (sTextBody==null) {
          // ****************************
          // Extract plain text from HTML

          StringBean oStrBn = new StringBean();

          try {
            oPrsr.visitAllNodesWith (oStrBn);
          } catch (ParserException pe) {
          throw new MessagingException(pe.getMessage(), pe);
          }

          sTextBody = oStrBn.getStrings();

          oStrBn = null;
      } // fi (sTextBody==null)

      // *******************************
 
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); //TODO make this configurable

         // 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 org.htmlparser.beans.StringBean

        super(name);
    }

    public void testNonEnglishCharacters() throws ParserException
    {
        StringBean sb;
       
        sb = new StringBean ();
        sb.setURL ("http://www.kobe-np.co.jp/");
        sb.getStrings ();
        sb.setURL ("http://book.asahi.com/"); // this used to throw an exception
        sb.getStrings ();
    }
View Full Code Here

Examples of org.htmlparser.beans.StringBean

     */
    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

        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

        }
    }

    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

    /**
     * Test no text returns empty string.
     */
    public void testCollapsed1 ()
    {
        StringBean sb;

        sb = new StringBean ();
        sb.setLinks (false);
        sb.setReplaceNonBreakingSpaces (true);
        sb.setCollapse (false);
        check (sb, "<html><head></head><body></body></html>", "");
        check (sb, "<html><head></head><body> </body></html>", " ");
        check (sb, "<html><head></head><body>\t</body></html>", "\t");
        sb.setCollapse (true);
        check (sb, "<html><head></head><body></body></html>", "");
        check (sb, "<html><head></head><body> </body></html>", "");
        check (sb, "<html><head></head><body>\t</body></html>", "");
    }
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.