Codota Logo
Jerry$JerryParser
Code IndexAdd Codota to your IDE (free)

How to use
Jerry$JerryParser
in
jodd.jerry

Best Java code snippets using jodd.jerry.Jerry$JerryParser (Showing top 20 results out of 315)

  • Common ways to obtain Jerry$JerryParser
private void myMethod () {
Jerry$JerryParser j =
  • Codota Iconnew JerryParser()
  • Codota IconDOMBuilder domBuilder;new JerryParser(domBuilder)
  • Smart code suggestions by Codota
}
origin: oblac/jodd

@Test
void testIterator2() {
  Jerry doc = Jerry.jerry().parse("<div id='one' class='foo'>one</div><div id='two' class='foo'>two</div>");
  Iterator<Jerry> iterator = doc.find(".notfound").iterator();
  String result = "";
  while (iterator.hasNext()) {
    Jerry j = iterator.next();
    result += j.attr("id");
  }
  assertEquals("", result);
}
origin: oblac/jodd

@Test
void testAbstractFormController() throws IOException {
  File file = new File(testDataRoot, "AbstractFormController.html");
  String content = FileUtil.readString(file);
  Jerry.JerryParser jerryParser = new Jerry.JerryParser();
  //jerryParser.getDOMBuilder().setCalculatePosition(true);
  Jerry doc = jerryParser.parse(content);
  // parse
  doc.$("a").each(($this, index) -> {
    assertEquals("<a name=\"navbar_top\"><!-- --></a>", $this.get()[0].getHtml());
    return false;
  });
}
origin: oblac/jodd

@Test
void testNamespaces() throws IOException {
  File file = new File(testDataRoot, "namespace.xml");
  LagartoDOMBuilder lagartoDOMBuilder = new LagartoDOMBuilder();
  lagartoDOMBuilder.enableXmlMode();
  lagartoDOMBuilder.getConfig().setCalculatePosition(true);
  Document doc = lagartoDOMBuilder.parse(FileUtil.readString(file));
  assertTrue(doc.check());
  Element cfgTestElement = (Element) doc.getChild(1);
  assertEquals("cfg:test", cfgTestElement.getNodeName());
  Element cfgNode = (Element) cfgTestElement.getChild(0);
  assertEquals("cfg:node", cfgNode.getNodeName());
  Jerry.JerryParser jerryParser = new Jerry.JerryParser();
  ((LagartoDOMBuilder) jerryParser.getDOMBuilder()).enableXmlMode();
  Jerry jerry = jerryParser.parse(FileUtil.readString(file));
  final StringBuilder result = new StringBuilder();
  jerry.$("cfg\\:test").each(($this, index) -> {
    result.append($this.$("cfg\\:node").text());
    return true;
  });
  assertEquals("This is a text", result.toString());
}
origin: oblac/jodd

@Test
void testAppend2() {
  Jerry.JerryParser jerryParser = Jerry.jerry();
  ((LagartoDOMBuilder) jerryParser.getDOMBuilder()).enableXmlMode();
  Jerry doc = jerryParser.parse("<xml><book><name>Foo</name></book></xml>");
  Jerry book = doc.$("book");
  book.append("<br>");
  assertEquals("<xml><book><name>Foo</name><br></br></book></xml>", doc.html());
}
origin: oblac/jodd

@Test
void testAppendContent3() {
  Jerry.JerryParser jerryParser = Jerry.jerry();
  ((LagartoDOMBuilder) jerryParser.getDOMBuilder()).enableXhtmlMode();
  Jerry doc = jerryParser.parse("<xml><book isbn='123'><name>Foo</name></book></xml>");
  Jerry book = doc.$("book");
  book.append("<br>");
  assertEquals("<xml><book isbn=\"123\"><name>Foo</name><br/></book></xml>", doc.html());
}
origin: oblac/jodd

/**
 * Creates new {@link jodd.jerry.Jerry.JerryParser Jerry runner} with
 * provided implementation of {@link jodd.lagarto.dom.DOMBuilder}.
 */
public static JerryParser jerry(final DOMBuilder domBuilder) {
  return new JerryParser(domBuilder);
}
origin: oblac/jodd

@Test
void testAppend1() {
  Jerry.JerryParser jerryParser = Jerry.jerry();
  ((LagartoDOMBuilder) jerryParser.getDOMBuilder()).enableHtmlMode();
  Jerry doc = jerryParser.parse("<xml><book><name>Foo</name></book></xml>");
  Jerry book = doc.$("book");
  book.append("<br>");
  assertEquals("<xml><book><name>Foo</name><br></book></xml>", doc.html());
}
origin: oblac/jodd

@Test
void testPortletUtils() throws IOException {
  File file = new File(testDataRoot, "PortletUtils.html");
  String content = FileUtil.readString(file);
  Jerry.JerryParser jerryParser = new Jerry.JerryParser();
  //jerryParser.getDOMBuilder().setCalculatePosition(true);
  Jerry doc = jerryParser.parse(content);
  // parse
  doc.$("a").each(($this, index) -> {
    assertEquals("<a name=\"navbar_top\"><!-- --></a>", $this.get()[0].getHtml());
    return false;
  });
}
origin: oblac/jodd

@Test
void testConditionalTags() {
  Jerry.JerryParser jerry = new Jerry.JerryParser();
  ((LagartoDOMBuilder) jerry.getDOMBuilder()).getConfig().setIgnoreComments(true);
  Jerry doc = jerry.parse(
      "<html>" +
          "    <!--[if lt IE 7]>  <body class=\"ie ie6 ie_lte_9 ie_lte_8 ie_lte_7\"> <![endif]-->\n" +
          "    <!--[if IE 7]>     <body class=\"ie ie7 ie_lte_9 ie_lte_8 ie_lte_7\"> <![endif]-->\n" +
          "    <!--[if IE 8]>     <body class=\"ie ie8 ie_lte_9 ie_lte_8\">  <![endif]-->\n" +
          "    <!--[if IE 9]>     <body class=\"ie ie9 ie_lte_9\">           <![endif]-->\n" +
          "    <!--[if gt IE 9]>  <body class=\"ie\">                        <![endif]-->\n" +
          "    <!--[if !IE]>xxx--><body><!--<![endif]-->\n" +
          "</body></html>"
  );
  String html = doc.html();
  html = StringUtil.removeChars(html, " \n\r");
  assertEquals("<html><body></body></html>", html);
}
origin: oblac/jodd

@Test
void testConditionalTags2() {
  Jerry.JerryParser jerry = new Jerry.JerryParser();
  ((LagartoDOMBuilder) jerry.getDOMBuilder()).getConfig()
      .setIgnoreComments(true)
      .setEnableConditionalComments(true)
      .setCondCommentIEVersion(8);
  Jerry doc = jerry.parse(
      "<html>" +
          "    <!--[if lt IE 7]>  <body class=\"ie ie6 ie_lte_9 ie_lte_8 ie_lte_7\"> <![endif]-->\n" +
          "    <!--[if IE 7]>     <body class=\"ie ie7 ie_lte_9 ie_lte_8 ie_lte_7\"> <![endif]-->\n" +
          "    <!--[if IE 8]>     <body class=\"ie ie8 ie_lte_9 ie_lte_8\">  <![endif]-->\n" +
          "    <!--[if IE 9]>     <body class=\"ie ie9 ie_lte_9\">           <![endif]-->\n" +
          "    <!--[if gt IE 9]>  <body class=\"ie\">                        <![endif]-->\n" +
          "    <!--[if !IE]>xxx--><body><!--<![endif]-->\n" +
          "</body></html>"
  );
  String html = doc.html();
  html = StringUtil.removeChars(html, " \n\r");
  assertEquals("<html><bodyclass=\"ieie8ie_lte_9ie_lte_8\"></body></html>", html);
}
origin: oblac/jodd

@Test
void testKelkoo() throws Exception {
  File file = new File(testDataRoot, "kelkoo.html");
  Jerry jerry;
  try {
    jerry = Jerry.jerry().parse(FileUtil.readString(file));
  } catch (Exception ex) {
    fail(ex.toString());
    throw ex;
  }
  Element script = (Element) jerry.$("script").get(0);
  assertEquals("script", script.getNodeName());
  assertEquals(6, script.getAttributesCount());
  assertEquals("src", script.getAttribute(0).getName());
  assertEquals("data-config", script.getAttribute(1).getName());
  assertEquals("ext\\u00e9rieur|barbecue,", script.getAttribute(2).getName());
  assertEquals("planchaaccessoires\":\"http:\\", script.getAttribute(3).getName());
  assertEquals("www.kelkoo.fr\"}'", script.getAttribute(4).getName());
  assertEquals("data-adsense-append", script.getAttribute(5).getName());
}
origin: oblac/jodd

@Test
void testAppendContent2() {
  Jerry.JerryParser jerryParser = Jerry.jerry();
  ((LagartoDOMBuilder) jerryParser.getDOMBuilder()).enableXmlMode();
  Jerry doc = jerryParser.parse("<xml><book isbn='123'><name>Foo</name></book></xml>");
  Jerry book = doc.$("book");
  book.append("<br>");
  assertEquals("<xml><book isbn=\"123\"><name>Foo</name><br></br></book></xml>", doc.html());
}
origin: oblac/jodd

  @Test
  void testConditionalTags3() {
    Jerry.JerryParser jerry = new Jerry.JerryParser();
    ((LagartoDOMBuilder) jerry.getDOMBuilder()).getConfig()
        .setIgnoreComments(true)
        .setEnableConditionalComments(true)
        .setCondCommentIEVersion(10);

    Jerry doc = jerry.parse(
        "<html>" +
            "    <!--[if lt IE 7]>  <body class=\"ie ie6 ie_lte_9 ie_lte_8 ie_lte_7\"> <![endif]-->\n" +
            "    <!--[if IE 7]>     <body class=\"ie ie7 ie_lte_9 ie_lte_8 ie_lte_7\"> <![endif]-->\n" +
            "    <!--[if IE 8]>     <body class=\"ie ie8 ie_lte_9 ie_lte_8\">      <![endif]-->\n" +
            "    <!--[if IE 9]>     <body class=\"ie ie9 ie_lte_9\">           <![endif]-->\n" +
            "    <!--[if gt IE 9]>  <body class=\"ie\">                    <![endif]-->\n" +
            "    <!--[if !IE]><!--> <body> <!--<![endif]--> \n" +
            "</body></html>"
    );
    String html = doc.html();
    html = StringUtil.removeChars(html, " \n\r");

    assertEquals("<html><bodyclass=\"ie\"></body></html>", html);
  }
}
origin: oblac/jodd

@Test
void testCustomPseudoFunction() {
  PseudoFunctionSelector.registerPseudoFunction(MyPseudoFunction.class);
  Jerry doc = Jerry.jerry().parse("<body><p>not found</p><div>This!</div></body>");
  Jerry p = doc.$(":super-fn(3)");
  assertEquals(1, p.size());
  assertEquals("This!", p.text());
}
origin: oblac/jodd

  @Test
  void testStuck() throws IOException {
    File file = new File(testDataRoot, "stuck.html.gz");
    InputStream in = new GZIPInputStream(new FileInputStream(file));
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    StreamUtil.copy(in, out);
    in.close();

    Jerry.JerryParser jerryParser = new Jerry.JerryParser();
//        LagartoDOMBuilder lagartoDOMBuilder = (LagartoDOMBuilder) jerryParser.getDOMBuilder();
//        lagartoDOMBuilder.setParsingErrorLogLevelName("ERROR");
    Jerry doc = jerryParser.parse(out.toString("UTF-8"));

    // parse
    try {
      doc.$("a").each(($this, index) -> {
        assertEquals("Go to Database Directory", $this.html().trim());
        return false;
      });
    } catch (StackOverflowError stackOverflowError) {
      fail("stack overflow!");
    }
  }
}
origin: oblac/jodd

@Test
void testCustomPseudoClass() {
  PseudoClassSelector.registerPseudoClass(MyPseudoClass.class);
  Jerry doc = Jerry.jerry().parse("<body><p jodd-attr='1'>found</p><p>not found</p></body>");
  Jerry p = doc.$("p:jjjjj");
  assertEquals(1, p.size());
  assertEquals("found", p.text());
}
origin: oblac/jodd

/**
 * Just creates new {@link jodd.jerry.Jerry.JerryParser Jerry runner} to separate
 * parser creation and creation of new Jerry instances.
 */
public static JerryParser jerry() {
  return new JerryParser();
}
origin: oblac/jodd

((LagartoDOMBuilder) jerryParser.getDOMBuilder()).enableHtmlMode();
Jerry doc = jerryParser.parse(str);
Document document = (Document) doc.get(0);
Element divNode = (Element) document.getChild(0);
((LagartoDOMBuilder) jerryParser.getDOMBuilder()).getConfig().setCaseSensitive(true);
doc = jerryParser.parse(str);
document = (Document) doc.get(0);
divNode = (Element) document.getChild(0);
origin: oblac/jodd

/**
 * Parses input content and creates new <code>Jerry</code>.
 */
public static Jerry jerry(final String content) {
  return jerry().parse(content);
}
origin: org.jodd/jodd-lagarto

/**
 * Parses input sequence and creates new <code>Jerry</code>.
 */
public static Jerry jerry(final char[] content) {
  return jerry().parse(content);
}
jodd.jerryJerry$JerryParser

Javadoc

Content parser and Jerry factory.

Most used methods

  • parse
    Invokes parsing on DOMBuilder.
  • <init>
  • getDOMBuilder
  • enableHtmlMode
  • enableXmlMode

Popular in Java

  • Start an intent from android
  • getApplicationContext (Context)
  • addToBackStack (FragmentTransaction)
  • onCreateOptionsMenu (Activity)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate(i
  • StringTokenizer (java.util)
    The string tokenizer class allows an application to break a string into tokens. The tokenization met
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now