Пример #1
0
 @Test
 public void Basic() {
   Tst_parse(
       String_.Concat_lines_nl(
           "<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
           "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">",
           "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">",
           "<head>",
           "<title>Index of /simplewiki/</title>",
           "<link rel=\"stylesheet\" type=\"text/css\" href=\"/pub/misc/lighttpd-white-dir.css\" />",
           "</head>",
           "<body>",
           "<h2>Index of /simplewiki/</h2>",
           "<div class=\"list\">",
           "<table summary=\"Directory Listing\" cellpadding=\"0\" cellspacing=\"0\">",
           "<thead><tr><th class=\"n\">Name</th><th class=\"m\">Last Modified</th><th class=\"s\">Size</th><th class=\"t\">Type</th></tr></thead>",
           "<tbody>",
           "<tr><td class=\"n\"><a href=\"../\">Parent Directory</a>/</td><td class=\"m\">&nbsp;</td><td class=\"s\">- &nbsp;</td><td class=\"t\">Directory</td></tr>",
           "<tr><td class=\"n\"><a href=\"20120516/\">20120516</a>/</td><td class=\"m\">2012-May-17 01:04:39</td><td class=\"s\">- &nbsp;</td><td class=\"t\">Directory</td></tr>",
           "<tr><td class=\"n\"><a href=\"20121220/\">20121220</a>/</td><td class=\"m\">2012-Dec-20 20:15:55</td><td class=\"s\">- &nbsp;</td><td class=\"t\">Directory</td></tr>",
           "<tr><td class=\"n\"><a href=\"20130214/\">20130214</a>/</td><td class=\"m\">2013-Feb-14 06:28:41</td><td class=\"s\">- &nbsp;</td><td class=\"t\">Directory</td></tr>",
           "<tr><td class=\"n\"><a href=\"latest/\">latest</a>/</td><td class=\"m\">2013-Feb-14 06:28:41</td><td class=\"s\">- &nbsp;</td><td class=\"t\">Directory</td></tr>",
           "</tbody>",
           "</table>",
           "</div>",
           "<div class=\"foot\">lighttpd</div>",
           "</body>",
           "</html>"),
       String_.Ary("20120516", "20121220", "20130214", "latest"));
 }
 public Xobc_import_step_itm[] Select_by_task_id(int task_id) {
   List_adp list = List_adp_.New();
   Db_rdr rdr =
       conn.Stmt_sql(
               Db_sql_.Make_by_fmt(
                   String_.Ary(
                       "SELECT  s.*",
                       "FROM    import_step s",
                       "        JOIN step_map sm ON s.step_id = sm.step_id",
                       "WHERE   sm.task_id = {0}"),
                   task_id))
           .Exec_select__rls_auto();
   try {
     while (rdr.Move_next()) {
       list.Add(New_itm(rdr));
     }
   } finally {
     rdr.Rls();
   }
   return (Xobc_import_step_itm[]) list.To_ary_and_clear(Xobc_import_step_itm.class);
 }
Пример #3
0
 @Test
 public void Find_last_lte() {
   Tst_find_last_lte(
       String_.Ary("20120516", "20121220", "20130214", "latest"), "20130101", "20121220");
   Tst_find_last_lte(String_.Ary("20120516", "20121220", "20130214", "latest"), "20120101", "");
 }
Пример #4
0
public class Pfunc_scrib_lib implements Scrib_lib {
  private Scrib_core core;

  public Scrib_lua_mod Mod() {
    return mod;
  }

  private Scrib_lua_mod mod;

  public Scrib_lib Init() {
    procs.Init_by_lib(this, Proc_names);
    return this;
  }

  public void Core_(Scrib_core v) {
    this.core = v;
  } // TEST:

  public Scrib_lib Clone_lib(Scrib_core core) {
    return new Pfunc_scrib_lib();
  }

  public Scrib_lua_mod Register(Scrib_core core, Io_url script_dir) {
    this.core = core;
    Init();
    mod =
        core.RegisterInterface(
            this,
            core.App()
                .Fsys_mgr()
                .Bin_xtns_dir()
                .GenSubFil_nest("ParserFunctions", "mw.ext.ParserFunctions.lua"));
    return mod;
  }

  public Scrib_proc_mgr Procs() {
    return procs;
  }

  private Scrib_proc_mgr procs = new Scrib_proc_mgr();

  public boolean Procs_exec(int key, Scrib_proc_args args, Scrib_proc_rslt rslt) {
    switch (key) {
      case Proc_expr:
        return Expr(args, rslt);
      default:
        throw Err_.new_unhandled(key);
    }
  }

  private static final int Proc_expr = 0;
  public static final String Invk_expr = "expr";
  private static final String[] Proc_names = String_.Ary(Invk_expr);

  public boolean Expr(Scrib_proc_args args, Scrib_proc_rslt rslt) {
    byte[] expr_bry =
        args.Xstr_bry_or_null(
            0); // NOTE: some modules will pass in an int; PAGE:en.w:531_BC DATE:2016-04-29
    Bry_bfr tmp_bfr = core.Wiki().Utl__bfr_mkr().Get_b128();
    Pfunc_expr.Evaluate(tmp_bfr, core.Ctx(), expr_bry);
    String expr_rslt = tmp_bfr.To_str_and_rls();
    return rslt.Init_obj(
        expr_rslt); // NOTE: always return rslt; don't throw error even if expr is invalid;
                    // EX:mw.ParserFuntion.expr('fail'); PAGE:es.w:Freer_(Texas) DATE:2015-07-28
  }
}
Пример #5
0
 private void Init(Db_engine engine) {
   init = false;
   tbl_mgr.Clear();
   idx_mgr.Clear();
   Dbmeta_parser__tbl tbl_parser = new Dbmeta_parser__tbl();
   Dbmeta_parser__idx idx_parser = new Dbmeta_parser__idx();
   Db_qry__select_in_tbl qry =
       Db_qry__select_in_tbl.new_(
           "sqlite_master",
           String_.Ary_empty,
           String_.Ary("type", "name", "sql"),
           Db_qry__select_in_tbl.Order_by_null);
   Db_rdr rdr = engine.Stmt_by_qry(qry).Exec_select__rls_auto();
   try {
     Gfo_usr_dlg_.Instance.Log_many(
         "", "", "db.schema.load.bgn: conn=~{0}", engine.Conn_info().Db_api());
     while (rdr.Move_next()) {
       String type_str = rdr.Read_str("type");
       String name = rdr.Read_str("name");
       String sql = rdr.Read_str("sql");
       try {
         int type_int = Dbmeta_itm_tid.Xto_int(type_str);
         switch (type_int) {
           case Dbmeta_itm_tid.Tid_table:
             if (String_.Has_at_bgn(name, "sqlite_"))
               continue; // ignore b/c of non-orthodox syntax; EX: "CREATE TABLE
                         // sqlite_sequence(name, seq)"; also "CREATE TABLE
                         // sqlite_stat(tbl,idx,stat)";
             tbl_mgr.Add(tbl_parser.Parse(Bry_.new_u8(sql)));
             break;
           case Dbmeta_itm_tid.Tid_index:
             if (sql == null)
               continue; // ignore "autoindex"; EX: sqlite_autoindex_temp_page_len_avg_1
             idx_mgr.Add(idx_parser.Parse(Bry_.new_u8(sql)));
             break;
           default:
             Gfo_usr_dlg_.Instance.Log_many(
                 "",
                 "",
                 "db.schema.unknown type: conn=~{0} type=~{1} name=~{2} sql=~{3}",
                 engine.Conn_info().Db_api(),
                 type_str,
                 name,
                 sql);
             break;
         }
       } catch (
           Exception
               e) { // tables / indexes may be unparseable; skip them; EX: CREATE TABLE unparseable
                    // (col_1 /*comment*/ int); DATE:2016-06-08
         Gfo_usr_dlg_.Instance.Log_many(
             "",
             "",
             "db.schema.unparseable: conn=~{0} type=~{1} name=~{2} sql=~{3} err=~{4}",
             engine.Conn_info().Db_api(),
             type_str,
             name,
             sql,
             Err_.Message_gplx_log(e));
       }
     }
   } finally {
     rdr.Rls();
   }
 }