Examples of LagartoParser


Examples of jodd.lagarto.LagartoParser

    /**
     * Initialize processor by creating new Lagarto and root TagWriter.
     */
    public void init(char[] content) {
      // create Lagarto
      lagartoParser = new LagartoParser(content, emitStrings);

      // prepare root tag writer
      fastCharArrayWriter = new FastCharArrayWriter();
      tagWriter = new TagWriter(fastCharArrayWriter);
    }
View Full Code Here

Examples of jodd.lagarto.LagartoParser

  /**
   * Creates DOM tree from provided content.
   */
  public Document parse(char[] content) {
    LagartoParser lagartoParser = new LagartoParser(content, true);
    return doParse(lagartoParser);
  }
View Full Code Here

Examples of jodd.lagarto.LagartoParser

  /**
   * Creates DOM tree from the provided content.
   */
  public Document parse(String content) {
    LagartoParser lagartoParser = new LagartoParser(content, true);
    return doParse(lagartoParser);
  }
View Full Code Here

Examples of jodd.lagarto.LagartoParser

public class StripHtmlTest {

  @Test
  public void testStripHtml() {
    LagartoParser lagartoParser = new LagartoParser(
        "<html>  <div   id='a'>   x \n\n\n </div>  </html>", false);

    StringBuilder out = new StringBuilder();
    StripHtmlTagAdapter stripHtmlTagAdapter = new StripHtmlTagAdapter(new TagWriter(out));

    lagartoParser.parse(stripHtmlTagAdapter);

    assertEquals("<html><div id=\"a\"> x </div></html>", out.toString());
  }
View Full Code Here

Examples of jodd.lagarto.LagartoParser

public class UrlRewriterTest {

  @Test
  public void testUrlRewriter() {
    LagartoParser lagartoParser = new LagartoParser(
        "<a href=\"http://jodd.org\">1</a><a href=\"page.html\">2</a>", false);

    StringBuilder out = new StringBuilder();
    UrlRewriterTagAdapter urlRewriterTagAdapter = new UrlRewriterTagAdapter(new TagWriter(out)) {

      @Override
      protected CharSequence rewriteUrl(CharSequence url) {
        String u = url.toString();
        if (u.startsWith("http")) {
          return url;
        }

        return "/ctx/" + url;
      }
    };

    lagartoParser.parse(urlRewriterTagAdapter);

    assertEquals(
        "<a href=\"http://jodd.org\">1</a><a href=\"/ctx/page.html\">2</a>", out.toString());
  }
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.