Package org.rssowl.core.util

Examples of org.rssowl.core.util.ExpandingReader


        RGB searchRGB = OwlUI.getThemeRGB(OwlUI.SEARCH_HIGHLIGHT_BG_COLOR_ID, new RGB(255, 255, 0));
        String preHighlight = "<span style=\"background-color:rgb(" + OwlUI.toString(searchRGB) + ");\">"; //$NON-NLS-1$ //$NON-NLS-2$
        String postHighlight = "</span>"; //$NON-NLS-1$

        ExpandingReader resultHighlightReader = new ExpandingReader(new StringReader(result), wordsToHighlight, preHighlight, postHighlight, true);

        int len = 0;
        char[] buf = new char[1000];
        try {
          while ((len = resultHighlightReader.read(buf)) != -1)
            highlightedResult.append(buf, 0, len);

          return highlightedResult.toString();
        } catch (IOException e) {
          Activator.getDefault().logError(e.getMessage(), e);
View Full Code Here


        RGB searchRGB = OwlUI.getThemeRGB(OwlUI.SEARCH_HIGHLIGHT_BG_COLOR_ID, new RGB(255, 255, 0));
        String preHighlight = "<span style=\"background-color:rgb(" + OwlUI.toString(searchRGB) + ");\">"; //$NON-NLS-1$ //$NON-NLS-2$
        String postHighlight = "</span>"; //$NON-NLS-1$

        ExpandingReader resultHighlightReader = new ExpandingReader(new StringReader(str), wordsToHighlight, preHighlight, postHighlight, true);

        int len = 0;
        char[] buf = new char[1000];
        try {
          while ((len = resultHighlightReader.read(buf)) != -1)
            highlightedResult.append(buf, 0, len);

          return highlightedResult.toString();
        } catch (IOException e) {
          Activator.getDefault().logError(e.getMessage(), e);
View Full Code Here

    String postExpand = ")";

    boolean skipTags = true;

    //1
    ExpandingReader reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, skipTags);
    String result = readFully(reader);

    assertEquals("Hello", result);

    //2
    skipTags = false;
    reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, skipTags);
    result = readFully(reader);

    assertEquals("Hello", result);

    //3
    skipTags = true;
    words = Arrays.asList("hello");
    reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, skipTags);
    result = readFully(reader);

    assertEquals("(Hello)", result);

    //4
    skipTags = false;
    words = Arrays.asList("hello");
    reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, skipTags);
    result = readFully(reader);

    assertEquals("(Hello)", result);

    //5
    preExpand = "hello";
    postExpand = "Hello";
    skipTags = true;
    words = Arrays.asList("hello");
    reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, skipTags);
    result = readFully(reader);

    assertEquals("helloHelloHello", result);
  }
View Full Code Here

    String postExpand = ")";

    boolean skipTags = true;

    //1
    ExpandingReader reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, skipTags);
    String result = readFully(reader);

    assertEquals("<Hello>", result);

    //2
    skipTags = false;
    reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, skipTags);
    result = readFully(reader);

    assertEquals("<Hello>", result);

    //3
    skipTags = true;
    words = Arrays.asList("hello");
    reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, skipTags);
    result = readFully(reader);

    assertEquals("<Hello>", result);

    //4
    skipTags = false;
    words = Arrays.asList("hello");
    reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, skipTags);
    result = readFully(reader);

    assertEquals("<(Hello)>", result);
  }
View Full Code Here

    String preExpand = "<span>";
    String postExpand = "</span>";

    //1
    ExpandingReader reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, true);
    String result = readFully(reader);

    assertEquals("<html>\n<body>\n\t<p>Hello <b><span>World</span></b> in <a href=\"http://www.rssowl.org\">RSSOwl.org</a></p></body></html>", result);

    //2
    words = Arrays.asList("html");
    reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, true);
    result = readFully(reader);

    assertEquals("<html>\n<body>\n\t<p>Hello <b>World</b> in <a href=\"http://www.rssowl.org\">RSSOwl.org</a></p></body></html>", result);

    //3
    words = Arrays.asList("www.rssowl.org");
    reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, true);
    result = readFully(reader);

    assertEquals("<html>\n<body>\n\t<p>Hello <b>World</b> in <a href=\"http://www.rssowl.org\">RSSOwl.org</a></p></body></html>", result);

    //4
    words = Arrays.asList("rssowl");
    reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, true);
    result = readFully(reader);

    assertEquals("<html>\n<body>\n\t<p>Hello <b>World</b> in <a href=\"http://www.rssowl.org\"><span>RSSOwl</span>.org</a></p></body></html>", result);
  }
View Full Code Here

    String preExpand = "<span>";
    String postExpand = "</span>";

    //1
    ExpandingReader reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, true);
    String result = readFully(reader);

    assertEquals("<html\n<body>\n\t<p>Hello <b><span>World</span></b> in <a href=\"http://www.rssowl.org\">RSSOwl.org/a></p></body></html>", result);

    //2
    words = Arrays.asList("html");
    reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, true);
    result = readFully(reader);

    assertEquals("<html\n<body>\n\t<p>Hello <b>World</b> in <a href=\"http://www.rssowl.org\">RSSOwl.org/a></p></body></html>", result);

    //3
    words = Arrays.asList("www.rssowl.org");
    reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, true);
    result = readFully(reader);

    assertEquals("<html\n<body>\n\t<p>Hello <b>World</b> in <a href=\"http://www.rssowl.org\">RSSOwl.org/a></p></body></html>", result);

    //4
    words = Arrays.asList("rssowl");
    reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, true);
    result = readFully(reader);

    assertEquals("<html\n<body>\n\t<p>Hello <b>World</b> in <a href=\"http://www.rssowl.org\"><span>RSSOwl</span>.org/a></p></body></html>", result);
  }
View Full Code Here

    String postExpand = "</span>";

    /* Just make sure no Exception is thrown with this content */
    List<String> words = Arrays.asList("rssowl", "blog", "news", "boreal", "download", "about", "contact", "img", "href", "\"", "\'", ".", ",");

    ExpandingReader reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, true);
    readFully(reader);
  }
View Full Code Here

    String postExpand = ")";

    boolean skipTags = true;

    //1
    ExpandingReader reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, skipTags);
    String result = readFully(reader);

    assertEquals("<a>Foo</a>", result);
  }
View Full Code Here

    String postExpand = ")";

    boolean skipTags = true;

    //1
    ExpandingReader reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, skipTags);
    String result = readFully(reader);

    assertEquals("(Hello) <a>(World)</a>", result);
  }
View Full Code Here

    String postExpand = ")";

    boolean skipTags = true;

    //1
    ExpandingReader reader = new ExpandingReader(new StringReader(s), words, preExpand, postExpand, skipTags);
    String result = readFully(reader);

    assertEquals("Hello (i) <a>World</a>", result);
  }
View Full Code Here

TOP

Related Classes of org.rssowl.core.util.ExpandingReader

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.