Package barrysoft.web

Examples of barrysoft.web.ParserRuleParam


    search.getParser().setName("ITSA Search");
   
    ParserRule inr = new ParserRule("(?i)(?s).*?<a href=\"([^<>]+)\">\\s[series]</a>.*?");
    inr.setQuickRule(" [series]<");
    inr.setGroupName("season link", 0);
    inr.addParam(new ParserRuleParam("series", "How I Met Your Mother"));
   
    search.getParser().addRule(inr);
    try {
      search.getDownloader().setUrl("http://www.italiansubs.net/index.php?option=com_remository");
    } catch (MalformedURLException e) {
View Full Code Here


    /*p.addRule(parseRule);
    p.addRuleParam(parseRule, p.new ParserRuleParam("city", "Rome"));
    p.addRuleParam(parseRule, p.new ParserRuleParam("country", "Italy"));*/
   
    ParserRule pr = new ParserRule(parseRule);
    pr.addParam(new ParserRuleParam("city", "Rome"));
    pr.addParam(new ParserRuleParam("country", "Italy"));
   
    p.addRule(pr);
     
    p.parseData(plainData);
   
View Full Code Here

  @Test
  public void testParserITSA() {
   
    Parser p = new Parser("ITSA Parser");
   
    ParserRuleParam prp = new ParserRuleParam("series");
   
    for (String s : series)
      prp.addValue(s);
   
    ParserRule pr = new ParserRule(itsaRule, prp);
    pr.setQuickRule(" [series]<");
   
    p.addRule(pr);
View Full Code Here

   
    for (String rule : multipleParamsRules)
      p.addRule(new ParserRule(rule));
   
    ParserRule pr = p.getRule(multipleParamsRules.length-1);
    pr.addParam(new ParserRuleParam("tag", "Inviato il "));
   
    try {
     
      pr.getParam("tag").addValue("Dimensioni del file: ");
     
View Full Code Here

    for (String rule : regexs) {
      ParserRule pr = new ParserRule(rule);
     
      for (int i=0; i < 3; i++) {
       
        ParserRuleParam prp = new ParserRuleParam("param"+(i+1));
       
        for (int j=0; j < 5; j++)
          prp.addValue("value"+(j+1));
       
        pr.addParam(prp);
       
      }
     
      pr.setGroupName("group1", 0);
      pr.setGroupName("group2", 1);
     
      p.addRule(pr);
    }
   
    String xmlSource = p.getXML(0);
   
    System.out.println(xmlSource);
   
    InputSource is = new InputSource(new StringReader(xmlSource));
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = null;
   
    try {
      db = dbf.newDocumentBuilder();
    } catch (ParserConfigurationException e1) {
      fail(e1.getMessage());
    }
   
    Document doc = null;
    try {
      doc = db.parse(is);
    } catch (SAXException e) {
      fail(e.getMessage());
    } catch (IOException e) {
      fail(e.getMessage());
    }
   
    Parser p2 = new Parser();
    p2.loadFromXML(doc.getFirstChild());
   
    assertEquals(p2.getRulesCount(), regexs.length);
   
    for (int i=0; i < p2.getRulesCount(); i++) {
     
      ParserRule pr = p2.getRule(i);
     
      assertEquals(pr.getRule(), regexs[i]);
      assertEquals(3, pr.getParamsCount());
     
      for (int j=0; j < pr.getParamsCount(); j++) {
        try {
          ParserRuleParam prp = pr.getParam("param"+(j+1));
         
          assertEquals(5, prp.getValues().length);
         
          for (int k=0; k < prp.getValues().length; k++)
            assertEquals("value"+(k+1), prp.getValues()[k]);
         
        } catch (IllegalArgumentException e) {
          fail(e.getMessage());
        }
      }
View Full Code Here

TOP

Related Classes of barrysoft.web.ParserRuleParam

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.