Tabnine Logo
Jerry$JerryParser
Code IndexAdd Tabnine 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)

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: com.meltmedia.cadmium/cadmium-core

jerryParser = Jerry.jerry().enableHtmlMode();
jerryParser.getDOMBuilder().setCaseSensitive(false);
jerryParser.getDOMBuilder().setParseSpecialTagsAsCdata(true);
jerryParser.getDOMBuilder().setSelfCloseVoidTags(false);
jerryParser.getDOMBuilder().setConditionalCommentExpression(null);
jerryParser.getDOMBuilder().setEnableConditionalComments(false);
jerryParser.getDOMBuilder().setImpliedEndTags(false);
jerryParser.getDOMBuilder().setIgnoreComments(true);
 ipAddress = EntityUtils.toString(response.getEntity());
 try {
  Jerry html = jerryParser.parse(ipAddress);
  Jerry ipNode = html.$("#greenip");
  if(ipNode.length() == 1) {
origin: com.meltmedia.cadmium/cadmium-copyright

/**
 * Updates the copyright dates in the given file.
 */
@Override
public void handleFile(File htmlFile) {
if(jerryParser == null){
 jerryParser = Jerry.jerry().enableHtmlMode();
 jerryParser.getDOMBuilder().setCaseSensitive(false);
 jerryParser.getDOMBuilder().setParseSpecialTagsAsCdata(true);
 jerryParser.getDOMBuilder().setSelfCloseVoidTags(false);
 jerryParser.getDOMBuilder().setConditionalCommentExpression(null);
 jerryParser.getDOMBuilder().setEnableConditionalComments(false);
 jerryParser.getDOMBuilder().setImpliedEndTags(false);
}
 log.trace("Handling file {}", htmlFile);
 try {
  String fileContents = FileUtils.readFileToString(htmlFile);
  Jerry html = jerryParser.parse(fileContents);
  Jerry selector = html.$("[data-cadmium='copyright']");
  log.debug("Found {} copyright tags.", selector.length());
  if(selector.length() > 0) {
   selector.text(year.toString());
   log.trace("Writing updated file {}",htmlFile);
   FileUtils.writeStringToFile(htmlFile, html.html(), false);
  }
 } catch(Throwable t) {
  log.warn("Failed to update file "+htmlFile, t);
 }
}
origin: fivesmallq/web-data-extractor

/**
 * Parses input content and creates new <code>Jerry</code>.
 */
public static Jerry jerry(String content) {
  return jerry().parse(content);
}
origin: fivesmallq/web-data-extractor

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

/**
 * Parses input sequence and creates new <code>Jerry</code>.
 */
public static Jerry jerry(char[] content) {
  return jerry().parse(content);
}
origin: fivesmallq/web-data-extractor

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

/**
 * 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: org.jodd/jodd-lagarto

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

/**
 * 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: com.meltmedia.cadmium/cadmium-core

private static void getDeploymentInfo(WarInfo info, CadmiumWar warHelper)
  throws Exception {
 if(warHelper.fileExists("WEB-INF/jboss-web.xml")) {
  String jbossWeb = warHelper.fileToString("WEB-INF/jboss-web.xml");
  Jerry jbossWebJerry = Jerry.jerry().enableXmlMode().parse(jbossWeb);
  info.setDomain(jbossWebJerry.$("jboss-web > virtual-host").text());
  info.setContext(jbossWebJerry.$("jboss-web > context-root").text());
 }
}
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);
}
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

  @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 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 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 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 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 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 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;
  });
}
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
  • runOnUiThread (Activity)
  • onRequestPermissionsResult (Fragment)
  • getResourceAsStream (ClassLoader)
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now