示例#1
0
 public boolean Chk(Xowe_wiki wiki) {
   if (!wiki.App().App_type().Uid_is_gui())
     return true; // NOTE: ignore during Server / Console modes; DATE:2015-04-01
   if (in_progress_hash.Has(wiki.Domain_bry()))
     return true; // NOTE: ignore if currently building; different bldr commands call
                  // wiki.Init_assert() which may lead to fals checks;
   Io_url url = url_(wiki);
   if (!Io_mgr.I.ExistsFil(url)) return true;
   Xoae_app app = wiki.Appe();
   app.Usr_dlg().Log_many("", "", "import.marker: marker found: url=~{0}", url.Raw());
   byte[] incompete_msg_bry =
       app.Usere()
           .Msg_mgr()
           .Val_by_key_args(Bry_.new_a7("api-xowa.import.core.incomplete"), wiki.Domain_str());
   int rslt = app.Gui_mgr().Kit().Ask_yes_no_cancel("", "", String_.new_u8(incompete_msg_bry));
   switch (rslt) {
     case Gfui_dlg_msg_.Btn_yes:
       Xob_cleanup_cmd.Delete_wiki_sql(wiki);
       End(wiki);
       return false; // delete wiki
     case Gfui_dlg_msg_.Btn_no:
       End(wiki);
       return true; // delete marker
     case Gfui_dlg_msg_.Btn_cancel:
       return true; // noop
     default:
       throw Err_.unhandled(rslt);
   }
 }
示例#2
0
 public static String Xto_name(byte tid) {
   switch (tid) {
     case Tid_unknown:
       return "unknown";
     case Tid_show:
       return "show";
     case Tid_all:
       return "all";
     case Tid_err:
       return "err";
     case Tid_add:
       return "add";
     case Tid_title:
       return "title";
     case Tid_raw:
       return "raw";
     case Tid_descrip:
       return "descrip";
     case Tid_del:
       return "del";
     case Tid_macro:
       return "macro";
     case Tid_name:
       return "name";
     case Tid_lang:
       return "lang";
     default:
       throw Err_.unhandled(tid);
   }
 }
示例#3
0
 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);
 }
示例#4
0
 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;
 }
示例#5
0
 public static byte[] XmlTag_itm(byte b) {
   switch (b) {
     case List_itmTyp_ul:
     case List_itmTyp_ol:
       return Byt_li;
     case List_itmTyp_dt:
       return Byt_dt;
     case List_itmTyp_dd:
       return Byt_dd;
     default:
       throw Err_.unhandled(b);
   }
 }
示例#6
0
 public static byte Char_lst(byte b) {
   switch (b) {
     case List_itmTyp_ul:
       return Byte_ascii.Star;
     case List_itmTyp_ol:
       return Byte_ascii.Hash;
     case List_itmTyp_dt:
       return Byte_ascii.Semic;
     case List_itmTyp_dd:
       return Byte_ascii.Colon;
     default:
       throw Err_.unhandled(b);
   }
 }
示例#7
0
 private void Ident_props(int apos_len) {
   typ = apos_len;
   switch (apos_len) {
     case Xop_apos_tkn_.Len_ital:
       {
         switch (state) {
           case Xop_apos_tkn_.State_i:
             cmd = Xop_apos_tkn_.Cmd_i_end;
             state = Xop_apos_tkn_.State_nil;
             break;
           case Xop_apos_tkn_.State_bi:
             cmd = Xop_apos_tkn_.Cmd_i_end;
             state = Xop_apos_tkn_.State_b;
             break;
           case Xop_apos_tkn_.State_ib:
             cmd = Xop_apos_tkn_.Cmd_bi_end__b_bgn;
             state = Xop_apos_tkn_.State_b;
             break;
           case Xop_apos_tkn_.State_dual:
             cmd = Xop_apos_tkn_.Cmd_i_end;
             state = Xop_apos_tkn_.State_b;
             dual_cmd = Xop_apos_tkn_.Cmd_bi_bgn;
             break;
           case Xop_apos_tkn_.State_b:
             cmd = Xop_apos_tkn_.Cmd_i_bgn;
             state = Xop_apos_tkn_.State_bi;
             break;
           case Xop_apos_tkn_.State_nil:
             cmd = Xop_apos_tkn_.Cmd_i_bgn;
             state = Xop_apos_tkn_.State_i;
             break;
           default:
             throw Err_.unhandled(state);
         }
         break;
       }
     case Xop_apos_tkn_.Len_bold:
       {
         switch (state) {
           case Xop_apos_tkn_.State_b:
             cmd = Xop_apos_tkn_.Cmd_b_end;
             state = Xop_apos_tkn_.State_nil;
             break;
           case Xop_apos_tkn_.State_bi:
             cmd = Xop_apos_tkn_.Cmd_ib_end__i_bgn;
             state = Xop_apos_tkn_.State_i;
             break;
           case Xop_apos_tkn_.State_ib:
             cmd = Xop_apos_tkn_.Cmd_b_end;
             state = Xop_apos_tkn_.State_i;
             break;
           case Xop_apos_tkn_.State_dual:
             cmd = Xop_apos_tkn_.Cmd_b_end;
             state = Xop_apos_tkn_.State_i;
             break; // NOTE: dual_cmd = Cmd_ib_bgn is implied
           case Xop_apos_tkn_.State_i:
             cmd = Xop_apos_tkn_.Cmd_b_bgn;
             state = Xop_apos_tkn_.State_ib;
             break;
           case Xop_apos_tkn_.State_nil:
             cmd = Xop_apos_tkn_.Cmd_b_bgn;
             state = Xop_apos_tkn_.State_b;
             break;
           default:
             throw Err_.unhandled(state);
         }
         break;
       }
     case Xop_apos_tkn_.Len_dual:
       {
         switch (state) {
           case Xop_apos_tkn_.State_b:
             cmd = Xop_apos_tkn_.Cmd_b_end__i_bgn;
             state = Xop_apos_tkn_.State_i;
             break;
           case Xop_apos_tkn_.State_i:
             cmd = Xop_apos_tkn_.Cmd_i_end__b_bgn;
             state = Xop_apos_tkn_.State_b;
             break;
           case Xop_apos_tkn_.State_bi:
             cmd = Xop_apos_tkn_.Cmd_ib_end;
             state = Xop_apos_tkn_.State_nil;
             break;
           case Xop_apos_tkn_.State_ib:
             cmd = Xop_apos_tkn_.Cmd_bi_end;
             state = Xop_apos_tkn_.State_nil;
             break;
           case Xop_apos_tkn_.State_dual:
             cmd = Xop_apos_tkn_.Cmd_bi_end;
             state = Xop_apos_tkn_.State_nil;
             break; // NOTE: dual_cmd = Cmd_ib_bgn is implied
           case Xop_apos_tkn_.State_nil:
             cmd = Xop_apos_tkn_.Cmd_ib_bgn;
             state = Xop_apos_tkn_.State_dual;
             break;
           default:
             throw Err_.unhandled(state);
         }
         break;
       }
     default:
       throw Err_.unhandled(apos_len);
   }
 }