示例#1
0
 public void Test_search(String search_word_str, int... expd) {
   Xowe_wiki wiki = bldr_fxt.Wiki();
   List_adp rv = List_adp_.new_();
   byte[] search_word_bry = Bry_.new_a7(search_word_str);
   wiki.Db_mgr_as_sql().Load_mgr().Load_search(Cancelable_.Never, rv, search_word_bry, 100);
   Tfds.Eq_ary(expd, Xto_int_ary(rv));
 }
public class Xog_tab_close_mgr {
  private List_adp list = List_adp_.New();

  public void Clear() {
    list.Clear();
  }

  public void Add(Xog_tab_close_lnr lnr) {
    list.Add(lnr);
  }

  public int Len() {
    return list.Count();
  }

  public Xog_tab_close_lnr Get_at(int i) {
    return (Xog_tab_close_lnr) list.Get_at(i);
  }

  public boolean When_close(Xog_tab_itm tab, Xoa_url url) {
    int len = list.Count();
    for (int i = 0; i < len; ++i) {
      Xog_tab_close_lnr lnr = Get_at(i);
      if (!lnr.When_close(tab, url)) return false;
    }
    return true;
  }
}
示例#3
0
  public static void Find_pages(List_adp rv, Xowe_wiki wiki, Dpl_itm itm) {
    rv.Clear();
    List_adp includes = itm.Ctg_includes();
    if (includes == null) return;
    int includes_len = includes.Count();
    Ordered_hash old_regy = Ordered_hash_.New(),
        new_regy = Ordered_hash_.New(),
        cur_regy = Ordered_hash_.New();
    Xodb_load_mgr load_mgr = wiki.Db_mgr().Load_mgr();
    Xowd_page_itm tmp_page = new Xowd_page_itm();
    Int_obj_ref tmp_id = Int_obj_ref.New_zero();
    List_adp del_list = List_adp_.New();
    int ns_filter = itm.Ns_filter();
    Ordered_hash exclude_pages = Ordered_hash_.New();
    Find_excludes(exclude_pages, wiki, load_mgr, tmp_page, tmp_id, itm.Ctg_excludes());

    for (int i = 0; i < includes_len; i++) { // loop over includes
      byte[] include = (byte[]) includes.Get_at(i);
      cur_regy.Clear();
      del_list.Clear();
      Find_pages_in_ctg(cur_regy, wiki, load_mgr, tmp_page, tmp_id, include);
      Del_old_pages_not_in_cur(i, tmp_id, old_regy, cur_regy, del_list);
      Add_cur_pages_also_in_old(i, tmp_id, old_regy, cur_regy, new_regy, exclude_pages, ns_filter);
      old_regy = new_regy;
      new_regy = Ordered_hash_.New();
    }
    int pages_len = old_regy.Count();
    for (int i = 0; i < pages_len; i++) { // loop over old and create pages
      Int_obj_ref old_id = (Int_obj_ref) old_regy.Get_at(i);
      rv.Add(new Xowd_page_itm().Id_(old_id.Val()));
    }
    wiki.Db_mgr().Load_mgr().Load_by_ids(Cancelable_.Never, rv, 0, pages_len);
    rv.Sort_by(Xowd_page_itm_sorter.IdAsc);
  }
  public List_adp Load(
      Xomp_mgr_db mgr_db, String machine_name, List_adp list, int list_idx, int list_len) {
    List_adp rv = List_adp_.New();

    // add remaining pages from old pool to new_pool;
    for (int i = list_idx; i < list_len; ++i) {
      rv.Add((Xomp_page_itm) list.Get_at(i));
    }

    // load pages into new pool
    Xomp_lock_mgr lock_mgr = mgr_db.Lock_mgr();
    int uid_db = lock_mgr.Uid_prv__get(machine_name);
    if (uid_db == Xomp_lock_mgr__fsys.Uid__eos)
      return rv; // assert that uids must be incrementally larger; handle one machine reaching end,
                 // and putting -1 in queue;
    int uid_new = 0;
    try {
      uid_new = this.Load_from_db(rv, uid_db);
    } finally {
      lock_mgr.Uid_prv__rls(machine_name, uid_new);
    }
    if (show_msg__fetched_pool)
      Gfo_usr_dlg_.Instance.Note_many(
          "", "", "fetched new pool: old=~{0} new=~{1}", uid_db, uid_new);
    return rv;
  }
示例#5
0
  public static Keyval[] new_() {
    Ordered_hash translated = Ordered_hash_.New_bry();
    List_adp untranslated = List_adp_.New();
    Add_itm_many(
        translated,
        Xol_lang_stub_.Id_en,
        Xol_lang_stub_.Id_de,
        Xol_lang_stub_.Id_pl,
        Xol_lang_stub_.Id_zh_hans,
        Xol_lang_stub_
            .Id_zh_hant); // add langs with translations first, so they alphabetize to top of list
    int len = Xol_lang_stub_.Id__max;
    for (int i = 0; i < len; i++) { // add rest of langs, but sort by code
      Xol_lang_stub itm = Xol_lang_stub_.Get_by_id(i);
      if (translated.Has(itm.Key())) continue;
      untranslated.Add(itm);
    }
    untranslated.Sort_by(Xol_lang_stub_.Comparer_key);

    Keyval[] rv = new Keyval[len];
    int translated_max = translated.Count();
    for (int i = 0; i < translated_max; i++) rv[i] = new_itm((Xol_lang_stub) translated.Get_at(i));

    for (int i = translated_max; i < len; i++)
      rv[i] = new_itm((Xol_lang_stub) untranslated.Get_at(i - translated_max));
    return rv;
  }
 public void Chk(byte[] wiki_domain, Io_url css_fil) {
   this.wiki_domain = wiki_domain;
   List_adp img_list = List_adp_.New();
   byte[] old_bry = Io_mgr.Instance.LoadFilBry(css_fil);
   byte[] rel_url_prefix = Bry_.Add(Bry_fwd_slashes, wiki_domain);
   byte[] new_bry = Convert_to_local_urls(rel_url_prefix, old_bry, img_list);
   Io_url img_dir = css_fil.OwnerDir();
   Download_fils(img_dir, img_list.To_str_ary());
   Io_mgr.Instance.SaveFilBry(css_fil, new_bry);
 }
示例#7
0
 public Xoud_site_row[] Select_all() {
   List_adp rv = List_adp_.new_();
   Db_rdr rdr = conn.Stmt_select(tbl_name, flds).Exec_select__rls_auto();
   try {
     while (rdr.Move_next()) rv.Add(new_row(rdr));
     return (Xoud_site_row[]) rv.To_ary_and_clear(Xoud_site_row.class);
   } finally {
     rdr.Rls();
   }
 }
示例#8
0
	@gplx.Internal protected void Focus(GfuiElem cur, boolean fwd) {
		List_adp allElemsInOwnerWin = List_adp_.new_(); AddSubs(cur.OwnerWin(), allElemsInOwnerWin);
		int curIdx = allElemsInOwnerWin.Idx_of(cur);
		GfuiElem target = cur;
		while (true) {	// find next visible elem
			int cycle = TabBox_.Cycle(fwd, curIdx, allElemsInOwnerWin.Count());
			target = GfuiElem_.cast_(allElemsInOwnerWin.Get_at(cycle));
			if (target.Visible()) break;
			if (cycle == curIdx) break;	// either (a) one elem in allElemsInOwnerWin or (b) n elems, and cycled back to start; break, else infinite loop
			curIdx = cycle;
		}
		target.Focus();
	}
示例#9
0
 int[] Xto_int_ary(Xoctg_data_ctg ctg) {
   List_adp list = List_adp_.new_();
   byte tid_max = Xoa_ctg_mgr.Tid__max;
   for (byte tid = 0; tid < tid_max; tid++) {
     Xoctg_idx_mgr grp = ctg.Grp_by_tid(tid);
     if (grp == null) continue;
     int len = grp.Itms_len();
     for (int i = 0; i < len; i++) {
       Xoctg_idx_itm itm = grp.Itms_get_at(i);
       list.Add(itm.Id());
     }
   }
   return (int[]) list.To_ary_and_clear(int.class);
 }
示例#10
0
 public static Xow_import_doc New(IoItmDir owner_dir, byte[] dir_cmd) {
   List_adp sub_list = List_adp_.New();
   New_subs(owner_dir.Url(), sub_list, owner_dir.SubDirs(), dir_cmd);
   New_subs(owner_dir.Url(), sub_list, owner_dir.SubFils(), Bry_.Empty);
   Xow_import_doc[] subs = (Xow_import_doc[]) sub_list.To_ary_and_clear(Xow_import_doc.class);
   return new Xow_import_doc(
       Bool_.Y,
       Bool_.N,
       0,
       owner_dir.Url().OwnerDir().RawBry(),
       owner_dir.Url().RawBry(),
       Bry_.new_u8(owner_dir.Name()),
       Bry_.Empty,
       Bry_.Empty,
       dir_cmd,
       subs);
 }
 @Override
 public void Cmd_run() {
   Init_bldr_bmks();
   this.time_bgn = System_.Ticks();
   int total_pending = Xob_xfer_regy_tbl.Select_total_pending(bldr_conn);
   // if (total_pending > 250000 && src_bin_mgr__fsdb_version == null)
   usr_dlg.Note_many("", "", "total pending: ~{0}", total_pending);
   List_adp list = List_adp_.New();
   boolean loop = true;
   while (loop) {
     byte rslt = Select_fsdb_itms(list);
     switch (rslt) {
       case Select_rv_stop:
         if (bin_db_mgr.Tier_id_is_last(tier_id_val)) loop = false;
         else {
           ++tier_id_val;
           page_id_val = 0;
           continue;
         }
         break;
       case Select_rv_next_page:
         ++page_id_val;
         lnki_id_val = 0;
         continue;
       case Select_rv_process:
         break;
     }
     if (!loop) break; // no more ttls found
     int len = list.Count();
     usr_dlg.Prog_many("", "", "fetched pages: ~{0}", len);
     for (int i = 0; i < len; ++i) {
       Xodb_tbl_oimg_xfer_itm fsdb = (Xodb_tbl_oimg_xfer_itm) list.Get_at(i);
       Download_itm(fsdb);
       if (exit_now
           || exec_count >= exec_count_max
           || exec_fail >= exec_fail_max
           || page_id_val >= page_id_end) {
         this.Txn_sav();
         return;
       }
     }
   }
   exec_done = true;
 }
 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);
 }
示例#13
0
 public Xol_interval_itm[] Get_duration_intervals(long seconds, Xol_duration_itm[] intervals) {
   if (intervals == null) intervals = Xol_duration_itm_.Ary_default;
   Array_.Sort(intervals, Xol_duration_itm_sorter.Instance);
   int intervals_len = intervals.length;
   long val = seconds;
   List_adp rv = List_adp_.New();
   for (int i = 0; i < intervals_len; i++) {
     Xol_duration_itm itm = intervals[i];
     long itm_seconds = itm.Seconds();
     val = seconds / itm_seconds;
     if (val > 0
         || (i == intervals_len - 1
             && rv.Count()
                 == 0) // always add one seg; EX: 40 seconds, but minutes requested -> 0 minutes;
                       // DATE:2014-05-10
     ) {
       seconds -= val * itm_seconds;
       rv.Add(new Xol_interval_itm(itm, val));
     }
   }
   return (Xol_interval_itm[]) rv.To_ary(Xol_interval_itm.class);
 }
示例#14
0
 public static int[] Ary_get(Xow_domain_itm domain_itm, boolean wmf) {
   if (wmf && domain_itm != null && domain_itm.Domain_type().Tid() != Xow_domain_tid_.Tid__home)
     return Ary_wmf;
   if (Ary_nonwmf == null) {
     List_adp list = List_adp_.New();
     int len = Ary_wmf.length;
     for (int i = 0; i < len; ++i) {
       list.Add(Ary_wmf[i]);
     }
     list.Add_many(
         Xol_kwd_grp_.Id_strx_len,
         Xol_kwd_grp_.Id_strx_pos,
         Xol_kwd_grp_.Id_strx_rpos,
         Xol_kwd_grp_.Id_strx_sub,
         Xol_kwd_grp_.Id_strx_count,
         Xol_kwd_grp_.Id_strx_replace,
         Xol_kwd_grp_.Id_strx_explode,
         Xol_kwd_grp_.Id_strx_urldecode,
         Xol_kwd_grp_.Id_new_window_link);
     Ary_nonwmf = (int[]) list.To_ary_and_clear(int.class);
   }
   return Ary_nonwmf;
 }
示例#15
0
public class Mem_tbl {
  private final List_adp where_rows = List_adp_.New();
  private final Hash_adp autonum_hash = Hash_adp_.New();

  public Mem_tbl(Dbmeta_tbl_itm meta) {
    this.meta = meta;
  }

  public Dbmeta_tbl_itm Meta() {
    return meta;
  }

  private final Dbmeta_tbl_itm meta;
  public final List_adp rows = List_adp_.New();

  public int Insert(Mem_stmt stmt) {
    Mem_row itm = new Mem_row();
    Dbmeta_fld_mgr flds = meta.Flds();
    int len = flds.Len();
    for (int i = 0; i < len; ++i) {
      Dbmeta_fld_itm fld = flds.Get_at(i);
      String fld_name = fld.Name();
      Object val = fld.Autonum() ? Autonum_calc(fld_name) : stmt.Args_get_by(fld_name);
      if (val == null) continue; // NOTE: allow Bulk_insert from test to skip filds
      itm.Set_by(fld_name, val);
    }
    rows.Add(itm);
    return 1;
  }

  private int Autonum_calc(String name) {
    Int_obj_ref autonum_itm = (Int_obj_ref) autonum_hash.Get_by(name);
    if (autonum_itm == null) {
      autonum_itm = Int_obj_ref.New(0);
      autonum_hash.Add(name, autonum_itm);
    }
    return autonum_itm.Val_add();
  }

  public int Update(Mem_stmt stmt) {
    Db_qry_update qry = (Db_qry_update) stmt.Qry();
    Criteria where_crt = qry.Where();
    if (where_crt == null) where_crt = Criteria_.All;
    Mem_stmt_args_.Fill(stmt.Stmt_args(), where_crt);
    Select_rows_where(where_rows, stmt, where_crt);
    int where_rows_len = where_rows.Count();
    String[] update_cols = qry.Cols_for_update();
    int update_cols_len = update_cols.length;
    for (int i = 0; i < where_rows_len; ++i) {
      Mem_row itm = (Mem_row) where_rows.Get_at(i);
      for (int j = 0; j < update_cols_len; ++j) itm.Set_by(update_cols[j], stmt.Args_get_at(j));
    }
    return where_rows_len;
  }

  public int Delete(Mem_stmt stmt) {
    Db_qry_delete qry = (Db_qry_delete) stmt.Qry();
    Mem_stmt_args_.Fill(stmt.Stmt_args(), qry.Where());
    Select_rows_where(where_rows, stmt, qry.Where());
    int where_rows_len = where_rows.Count();
    for (int i = 0; i < where_rows_len; ++i) {
      Mem_row itm = (Mem_row) where_rows.Get_at(i);
      rows.Del(itm);
    }
    return where_rows_len;
  }

  public Db_rdr Select(Mem_stmt stmt) {
    String[] select = null;
    Criteria where = null;
    Db_qry__select_in_tbl qry = Db_qry__select_in_tbl.as_(stmt.Qry());
    if (qry == null) {
      Db_qry__select_cmd qry2 = (Db_qry__select_cmd) stmt.Qry();
      select = To_str_ary(qry2.Cols().Flds);
      where = qry2.Where_itm().Root;
    } else {
      select = qry.Select_flds();
      where = qry.Where();
    }
    Mem_stmt_args_.Fill(stmt.Stmt_args(), where);
    Select_rows_where(where_rows, stmt, where);
    return new Mem_rdr(select, (Mem_row[]) where_rows.To_ary_and_clear(Mem_row.class));
  }

  private String[] To_str_ary(Sql_select_fld_list flds) {
    int len = flds.Len();
    String[] rv = new String[len];
    for (int i = 0; i < len; ++i) rv[i] = flds.Get_at(i).Fld;
    return rv;
  }

  private void Select_rows_where(List_adp rv, Mem_stmt stmt, Criteria crt) {
    rv.Clear();
    int rows_len = rows.Count();
    for (int i = 0; i < rows_len; ++i) {
      Mem_row itm = (Mem_row) rows.Get_at(i);
      if (crt.Matches(itm)) rv.Add(itm);
    }
  }
}
示例#16
0
class Xow_search_scanner {
  private final List_adp tkns = List_adp_.new_();
  private byte[] src;
  private int src_len, pos, txt_bgn;
  private final Ordered_hash tmp_list = Ordered_hash_.new_();
  private final Bry_bfr tmp_bfr = Bry_bfr.new_();

  public Xow_search_tkn[] Scan(byte[] src) {
    this.src = src;
    this.src_len = src.length;
    tkns.Clear();
    pos = 0;
    txt_bgn = -1;
    while (pos < src_len) {
      byte cur_b = src[pos];
      Object cur_obj = trie.Match_bgn_w_byte(cur_b, src, pos, src_len);
      if (cur_obj == null) { // text character
        if (txt_bgn == -1) txt_bgn = pos; // 1st character not set; set it
        ++pos;
      } else { // AND, OR, (, ), -, \s, "
        int pos_end = trie.Match_pos();
        byte cur_tid = ((Byte_obj_val) cur_obj).Val();
        if (Cur_join_is_word(cur_tid, pos_end))
          continue; // ignore words containing "and", "or"; EX: "random"; "for"
        if (txt_bgn != -1) { // pending word; create
          Tkns_add_word(Xow_search_tkn.Tid_word, txt_bgn, pos);
          txt_bgn = -1;
        }
        switch (cur_tid) {
          case Xow_search_tkn.Tid_space: // discard spaces
            pos = Bry_finder.Find_fwd_while(src, pos, src_len, Byte_ascii.Space);
            break;
          case Xow_search_tkn.Tid_quote: // find end quote and add as word
            int quote_bgn = pos + 1;
            int quote_end = Bry_finder.Find_fwd(src, Byte_ascii.Quote, quote_bgn, src_len);
            if (quote_end == Bry_.NotFound)
              throw Err_.new_fmt_("could not find end quote: {0}", String_.new_u8(src));
            Tkns_add_word(Xow_search_tkn.Tid_word_quoted, quote_bgn, quote_end);
            pos = quote_end + 1; // +1 to place after quote
            break;
          case Xow_search_tkn.Tid_not:
            Tkns_add_word(Xow_search_tkn.Tid_not, pos, pos_end);
            pos = pos_end;
            break;
          case Xow_search_tkn.Tid_paren_bgn:
          case Xow_search_tkn.Tid_paren_end:
          case Xow_search_tkn.Tid_and:
          case Xow_search_tkn.Tid_or:
            tkns.Add(new_tkn(cur_tid, pos, pos_end));
            pos = pos_end;
            break;
          default:
            throw Err_.unhandled(cur_tid);
        }
      }
    }
    if (txt_bgn != -1) { // pending word; create
      Tkns_add_word(Xow_search_tkn.Tid_word, txt_bgn, pos);
      txt_bgn = -1;
    }
    return (Xow_search_tkn[]) tkns.To_ary_and_clear(Xow_search_tkn.class);
  }

  private boolean Cur_join_is_word(
      byte cur_tid,
      int
          pos_end) { // extra logic to handle and / or occuring in unquoted strings; EX: "random";
                     // "for"
    switch (cur_tid) {
      default:
        return false; // only look at AND, OR, -
      case Xow_search_tkn.Tid_and:
      case Xow_search_tkn.Tid_or:
      case Xow_search_tkn.Tid_not:
        break;
    }
    boolean join_is_word = true;
    if (txt_bgn == -1) { // no pending word;
      if (cur_tid == Xow_search_tkn.Tid_not)
        return false; // NOT is only operator if no pending tkn; EX: -abc -> NOT abc; a-b -> a-b
      byte nxt_b = pos_end < src_len ? src[pos_end] : Byte_ascii.Nil;
      Object nxt_obj = trie.Match_bgn_w_byte(nxt_b, src, pos_end, src_len);
      if (nxt_obj == null) // next tkn is text; join must be word
      join_is_word = true;
      else { // next tkn is tkn
        byte nxt_tid = ((Byte_obj_val) nxt_obj).Val();
        switch (nxt_tid) {
          case Xow_search_tkn.Tid_space:
          case Xow_search_tkn.Tid_quote:
          case Xow_search_tkn.Tid_paren_bgn:
          case Xow_search_tkn.Tid_paren_end:
            join_is_word =
                false; // next tkn is sym; and/or is not word; EX: a AND ; a AND"b"; a AND(b)
            break;
          case Xow_search_tkn.Tid_not:
          case Xow_search_tkn.Tid_and:
          case Xow_search_tkn.Tid_or:
            join_is_word = true; // next tkn is and or not; and/or is word; EX: andor; oror; or-abc;
            break;
          default:
            throw Err_.unhandled(cur_tid);
        }
      }
    } else { // pending word; cur join must be word; EX: "grand": "and" invoked and "gr" pending
      join_is_word = true;
    }
    if (join_is_word) {
      if (txt_bgn == -1) txt_bgn = pos; // 1st character not set; set it
      pos = pos_end;
      return true;
    }
    if (txt_bgn != -1) {
      Tkns_add_word(Xow_search_tkn.Tid_word, txt_bgn, pos); // create word
      txt_bgn = -1;
    }
    return false;
  }

  private void Tkns_add_word(byte tid, int src_bgn, int src_end) {
    if (tkns.Count() > 0) { // at least 1 tkn; check for "auto-and"
      Xow_search_tkn last_tkn = (Xow_search_tkn) tkns.Get_at_last();
      if (last_tkn.Tid()
          == Xow_search_tkn.Tid_word) // previous tkn is word; auto "AND" words; EX: A B -> A AND B
      tkns.Add(Xow_search_tkn.new_bry(Xow_search_tkn.Tid_and, Bry_and));
    }
    if (tid
        == Xow_search_tkn
            .Tid_word) { // if word has symbol, convert to quoted; EX: a-b should become "a-b";
                         // otherwise searcher would search for a single word a-b
      byte[] cur_word = Bry_.Mid(src, src_bgn, src_end);
      byte[][] words =
          gplx.xowa.bldrs.cmds.texts.Xob_search_base.Split_ttl_into_words(
              null, tmp_list, tmp_bfr, cur_word);
      int words_len = words.length;
      if (words_len == 1 // only one word
          && !Bry_.Eq(words[0], cur_word) // split word not same as raw
          && Bry_finder.Find_fwd(cur_word, Byte_ascii.Star) == -1 // no asterisk
      ) {
        tkns.Add(Xow_search_tkn.new_bry(tid, words[0]));
        return;
      }
      if (words.length > 1) // multiple words; add as quoted-term; EX: "a-b"
      tid = Xow_search_tkn.Tid_word_quoted;
    }
    tkns.Add(new_tkn(tid, src_bgn, src_end));
  }

  private Xow_search_tkn new_tkn(byte tid, int val_bgn, int val_end) {
    return Xow_search_tkn.new_pos(tid, val_bgn, val_end);
  }

  private static final byte[] Bry_and = Bry_.new_a7("AND");
  private static final Btrie_slim_mgr trie =
      Btrie_slim_mgr.ci_ascii_() // NOTE:ci.ascii:OR / AND only
          .Add_str_byte(" ", Xow_search_tkn.Tid_space)
          .Add_str_byte("\"", Xow_search_tkn.Tid_quote)
          .Add_str_byte("-", Xow_search_tkn.Tid_not)
          .Add_str_byte("(", Xow_search_tkn.Tid_paren_bgn)
          .Add_str_byte(")", Xow_search_tkn.Tid_paren_end)
          .Add_str_byte("or", Xow_search_tkn.Tid_or)
          .Add_str_byte("and", Xow_search_tkn.Tid_and);
}
示例#17
0
class Io_line_rdr_fxt {
  Io_line_rdr rdr;
  List_adp lines = List_adp_.new_();
  Bry_bfr tmp = Bry_bfr.new_();

  public Io_line_rdr_fxt(Io_url... urls) {
    rdr = new Io_line_rdr(Gfo_usr_dlg_.Test(), urls);
  }

  public Io_line_rdr_fxt Load_len_lines_(int v) {
    return Load_len_(v * 3);
  } // 3: 2=##, 1=\n

  public Io_line_rdr_fxt Load_len_(int v) {
    rdr.Load_len_(v);
    return this;
  }

  public Io_line_rdr_fxt File_lines_(int count) {
    for (int i = 0; i < count; i++) tmp.Add_int_fixed(i, 2).Add_byte_nl();
    Io_mgr.I.SaveFilBry(rdr.Urls()[0], tmp.Xto_bry_and_clear());
    return this;
  }
  //	public Io_url[] Src_fils() {return src_fils;} public Io_line_rdr_fxt Src_fils_(Io_url[] v)
  // {src_fils = v; return this;} Io_url[] src_fils;
  public Io_line_rdr_fxt tst_Match(String match, String expd) {
    rdr.Key_gen_(Io_line_rdr_key_gen_.first_pipe);
    boolean match_v = rdr.Match(Bry_.new_u8(match));
    String actl = match_v ? String_.new_u8(rdr.Bfr(), rdr.Key_pos_bgn(), rdr.Key_pos_end()) : "";
    Tfds.Eq(expd, actl);
    return this;
  }

  public Io_line_rdr_fxt File_lines_pipe_(int count) {
    for (int i = 0; i < count; i++) tmp.Add_int_fixed(i, 2).Add_byte(Byte_ascii.Pipe).Add_byte_nl();
    Io_mgr.I.SaveFilBry(rdr.Urls()[0], tmp.Xto_bry_and_clear());
    return this;
  }

  public Io_line_rdr_fxt File_lines_(int fil_idx, int bgn, int end) {
    for (int i = bgn; i < end; i++) tmp.Add_int_fixed(i, 2).Add_byte_nl();
    Io_mgr.I.SaveFilBry(rdr.Urls()[fil_idx], tmp.Xto_bry_and_clear());
    return this;
  }

  public Io_line_rdr_fxt Clear() {
    rdr.Clear();
    return this;
  }

  public Io_line_rdr_fxt tst_Read_til_lines(int count, String... expd) {
    lines.Clear();
    for (int i = 0; i < expd.length; i++) expd[i] = expd[i] + Op_sys.Lnx.Nl_str();
    for (int i = 0; i < count; i++) {
      if (rdr.Read_next())
        lines.Add(String_.new_u8(rdr.Bfr(), rdr.Itm_pos_bgn(), rdr.Itm_pos_end()));
      else break;
    }
    Tfds.Eq_ary_str(expd, lines.To_str_ary());
    return this;
  }
}
示例#18
0
public class Dpl_xnde implements Xox_xnde {
  private Dpl_itm itm = new Dpl_itm();
  private List_adp pages = List_adp_.New();

  public void Xatr__set(
      Xowe_wiki wiki,
      byte[] src,
      Mwh_atr_itm xatr,
      Object xatr_id_obj) {} // NOTE: <dynamicPageList> has no attributes

  public void Xtn_parse(
      Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
    itm.Parse(wiki, ctx, ctx.Page().Ttl().Full_txt_w_ttl_case(), src, xnde);
    Dpl_page_finder.Find_pages(pages, wiki, itm);
    if (itm.Sort_ascending() != Bool_.__byte) pages.Sort_by(new Dpl_page_sorter(itm));
  }

  public void Xtn_write(
      Bry_bfr bfr,
      Xoae_app app,
      Xop_ctx ctx,
      Xoh_html_wtr html_wtr,
      Xoh_wtr_ctx hctx,
      Xoae_page wpg,
      Xop_xnde_tkn xnde,
      byte[] src) {
    Xowe_wiki wiki = ctx.Wiki();
    Dpl_html_data html_mode = Dpl_html_data.new_(Dpl_itm_keys.Key_unordered);
    int itms_len = pages.Count();
    if (itms_len == 0) {
      if (!itm.Suppress_errors()) bfr.Add_str_a7("No pages meet these criteria.");
      return;
    }
    int itms_bgn = 0;
    if (itm.Offset() != Int_.Min_value) {
      itms_bgn = itm.Offset();
    }
    if (itm.Count() != Int_.Min_value && itms_bgn + itm.Count() < itms_len) {
      itms_len = itms_bgn + itm.Count();
    }
    boolean show_ns = itm.Show_ns();
    Bry_bfr tmp_bfr = Bry_bfr_.Get();
    Xop_amp_mgr amp_mgr = wiki.Appe().Parser_amp_mgr();
    try {
      bfr.Add(html_mode.Grp_bgn()).Add_byte_nl();
      for (int i = itms_bgn; i < itms_len; i++) {
        Xowd_page_itm page = (Xowd_page_itm) pages.Get_at(i);
        Xoa_ttl ttl = Xoa_ttl.Parse(wiki, page.Ns_id(), page.Ttl_page_db());
        byte[] ttl_page_txt = show_ns ? ttl.Full_txt_w_ttl_case() : ttl.Page_txt();
        if (ttl_page_txt == null)
          continue; // NOTE: apparently DynamicPageList allows null pages; DATE:2013-07-22
        switch (html_mode.Tid()) {
          case Dpl_html_data.Tid_list_ul:
          case Dpl_html_data.Tid_list_ol:
            bfr.Add(Xoh_consts.Space_2).Add(html_mode.Itm_bgn()).Add(Gfh_bldr_.Bry__a_lhs_w_href);
            bfr.Add_str_a7("/wiki/")
                .Add(Gfo_url_encoder_.Href.Encode(ttl.Full_db()))
                .Add_byte_quote(); // NOTE: Full_db to encode spaces as underscores;
                                   // PAGE:en.q:Wikiquote:Speedy_deletions DATE:2016-01-19
            Gfh_atr_.Add(
                bfr,
                Gfh_atr_.Bry__title,
                Xoh_html_wtr_escaper.Escape(
                    amp_mgr,
                    tmp_bfr,
                    ttl
                        .Full_txt_w_ttl_case())); // NOTE: Full_txt b/c title always includes ns,
                                                  // even if show_ns is off;
                                                  // PAGE:en.b:Wikibooks:WikiProject DATE:2016-01-20
            if (itm.No_follow()) bfr.Add(Bry_nofollow);
            bfr.Add_byte(Byte_ascii.Gt);
            Xoh_html_wtr_escaper.Escape(
                amp_mgr, bfr, ttl_page_txt, 0, ttl_page_txt.length, false, false);
            bfr.Add(Gfh_bldr_.Bry__a_rhs).Add(html_mode.Itm_end()).Add_byte_nl();
            // TODO_OLD:
            // lnki_wtr.Clear().Href_wiki_(ttl).Title_(ttl).Nofollow_().Write_head(bfr).Write_text(bfr).Write_tail(bfr)
            break;
          default:
            break;
        }
      }
      bfr.Add(html_mode.Grp_end()).Add_byte_nl();
    } finally {
      tmp_bfr.Mkr_rls();
    }
  }

  private static byte[] Bry_nofollow = Bry_.new_a7(" rel=\"nofollow\"");
}