mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Wiki: Support renamed folders (fix)
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xow_abrv_wm {
|
||||
public Xow_abrv_wm(byte[] raw, byte[] lang_domain, Xol_lang_stub lang_actl, int domain_type) {
|
||||
this.raw = raw;
|
||||
this.lang_domain = lang_domain;
|
||||
this.lang_actl = lang_actl;
|
||||
this.domain_type = domain_type;
|
||||
}
|
||||
public byte[] Raw() {return raw;} private final byte[] raw;
|
||||
public byte[] Lang_domain() {return lang_domain;} private final byte[] lang_domain;
|
||||
public Xol_lang_stub Lang_actl() {return lang_actl;} private final Xol_lang_stub lang_actl;
|
||||
public int Domain_type() {return domain_type;} private final int domain_type;
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xow_abrv_wm_ {
|
||||
public static Xow_abrv_wm Parse_to_abrv_or_null(byte[] src) { // EX: parse "enwiki" to abrv_itm
|
||||
if (src == null) return null;
|
||||
int src_len = src.length; if (src_len == 0) return null; // empty bry
|
||||
Btrie_rv trv = new Btrie_rv();
|
||||
Object o = bry_trie.Match_at(trv, src, src_len - 1, -1); if (o == null) return null;
|
||||
Xow_abrv_wm rv = Xow_abrv_wm_override.To_abrv_itm_or_null(src); if (rv != null) return rv;
|
||||
int domain_type = ((Int_obj_ref)o).Val();
|
||||
Xol_lang_stub lang_itm = Xol_lang_stub_.Get_by_key_or_intl(src, 0, trv.Pos() + 1);
|
||||
return new Xow_abrv_wm(src, lang_itm.Key(), lang_itm, domain_type);
|
||||
}
|
||||
public static Xow_domain_itm Parse_to_domain_itm(byte[] src) { // EX: parse "enwiki" to "en.wikipedia.org" itm
|
||||
if (Bry_.Has(src, Byte_ascii.Underline)) // convert "_" to "-"; note that wmf_keys have a strict format of langtype; EX: "zh_yuewiki"; DATE:2014-10-06
|
||||
src = Bry_.Replace_create(src, Byte_ascii.Underline, Byte_ascii.Dash);
|
||||
return Xow_domain_itm_.parse(Xow_abrv_wm_.Parse_to_domain_bry(src));
|
||||
}
|
||||
public static byte[] Parse_to_domain_bry(byte[] src) { // EX: parse "enwiki" to en.wikipedia.org
|
||||
if (src == null) return null;
|
||||
int src_len = src.length; if (src_len == 0) return null; // empty bry
|
||||
Btrie_rv trv = new Btrie_rv();
|
||||
Object o = bry_trie.Match_at(trv, src, src_len - 1, - 1); if (o == null) return null;
|
||||
int domain_type = -1;
|
||||
byte[] lang = null;
|
||||
Xow_abrv_wm rv = Xow_abrv_wm_override.To_abrv_itm_or_null(src);
|
||||
if (rv != null) {
|
||||
lang = rv.Lang_domain();
|
||||
domain_type = rv.Domain_type();
|
||||
}
|
||||
else {
|
||||
domain_type = ((Int_obj_ref)o).Val();
|
||||
}
|
||||
switch (domain_type) {
|
||||
case Xow_domain_tid_.Tid__wmfblog: return Xow_domain_itm_.Bry__wmforg;
|
||||
case Xow_domain_tid_.Tid__wikidata: return Xow_domain_itm_.Bry__wikidata;
|
||||
case Xow_domain_tid_.Tid__mediawiki: return Xow_domain_itm_.Bry__mediawiki;
|
||||
case Xow_domain_tid_.Tid__commons: return Xow_domain_itm_.Bry__commons;
|
||||
case Xow_domain_tid_.Tid__species: return Xow_domain_itm_.Bry__species;
|
||||
case Xow_domain_tid_.Tid__meta: return Xow_domain_itm_.Bry__meta;
|
||||
case Xow_domain_tid_.Tid__incubator: return Xow_domain_itm_.Bry__incubator;
|
||||
case Xow_domain_tid_.Tid__wikipedia:
|
||||
case Xow_domain_tid_.Tid__wiktionary:
|
||||
case Xow_domain_tid_.Tid__wikisource:
|
||||
case Xow_domain_tid_.Tid__wikibooks:
|
||||
case Xow_domain_tid_.Tid__wikiversity:
|
||||
case Xow_domain_tid_.Tid__wikiquote:
|
||||
case Xow_domain_tid_.Tid__wikinews:
|
||||
case Xow_domain_tid_.Tid__wikivoyage:
|
||||
case Xow_domain_tid_.Tid__wikimedia:
|
||||
if (lang == null) {
|
||||
lang = Bry_.Mid(src, 0, trv.Pos() + 1); // en
|
||||
if (Bry_.Has(lang, Byte_ascii.Underline)) // convert "_" to "-"; note that wmf_keys have a strict format of langtype; EX: "zh_yuewiki"; DATE:2014-10-06
|
||||
lang = Bry_.Replace_create(lang, Byte_ascii.Underline, Byte_ascii.Dash);
|
||||
}
|
||||
return Bry_.Add
|
||||
( lang
|
||||
, Byte_ascii.Dot_bry // .
|
||||
, Xow_domain_tid_.Get_type_as_bry(domain_type) // wikipedia
|
||||
, Byte_ascii.Dot_bry // .
|
||||
, Xow_domain_itm_.Seg__org // org
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static void To_abrv(Bry_bfr bfr, byte[] lang_key, Int_obj_ref domain_type) {
|
||||
byte[] suffix_bry = (byte[])int_hash.Get_by(domain_type); if (suffix_bry == null) return;
|
||||
switch (domain_type.Val()) {
|
||||
case Xow_domain_tid_.Tid__commons:
|
||||
case Xow_domain_tid_.Tid__species:
|
||||
case Xow_domain_tid_.Tid__meta:
|
||||
case Xow_domain_tid_.Tid__incubator:
|
||||
case Xow_domain_tid_.Tid__wikidata:
|
||||
case Xow_domain_tid_.Tid__mediawiki:
|
||||
case Xow_domain_tid_.Tid__wmfblog: bfr.Add(suffix_bry); break;
|
||||
case Xow_domain_tid_.Tid__other: break;
|
||||
default: bfr.Add(lang_key).Add(suffix_bry); break;
|
||||
}
|
||||
}
|
||||
public static byte[] To_abrv(Xow_domain_itm domain_itm) {
|
||||
int tid = domain_itm.Domain_type_id();
|
||||
byte[] suffix = (byte[])int_hash.Get_by(Int_obj_ref.New(tid)); if (suffix == null) return null;
|
||||
switch (tid) {
|
||||
case Xow_domain_tid_.Tid__commons:
|
||||
case Xow_domain_tid_.Tid__species:
|
||||
case Xow_domain_tid_.Tid__meta:
|
||||
case Xow_domain_tid_.Tid__incubator:
|
||||
case Xow_domain_tid_.Tid__wikidata:
|
||||
case Xow_domain_tid_.Tid__mediawiki:
|
||||
case Xow_domain_tid_.Tid__wmfblog: return suffix;
|
||||
case Xow_domain_tid_.Tid__wikipedia:
|
||||
case Xow_domain_tid_.Tid__wiktionary:
|
||||
case Xow_domain_tid_.Tid__wikisource:
|
||||
case Xow_domain_tid_.Tid__wikibooks:
|
||||
case Xow_domain_tid_.Tid__wikiversity:
|
||||
case Xow_domain_tid_.Tid__wikiquote:
|
||||
case Xow_domain_tid_.Tid__wikinews:
|
||||
case Xow_domain_tid_.Tid__wikivoyage:
|
||||
case Xow_domain_tid_.Tid__wikimedia: return Bry_.Add(domain_itm.Lang_orig_key(), suffix);
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
}
|
||||
private static final Btrie_bwd_mgr bry_trie = Init_trie();
|
||||
private static Hash_adp int_hash;
|
||||
private static Btrie_bwd_mgr Init_trie() {
|
||||
int_hash = Hash_adp_.New();
|
||||
Btrie_bwd_mgr rv = new Btrie_bwd_mgr(false);
|
||||
Init_trie_itm(rv, int_hash, "wiki" , Xow_domain_tid_.Tid__wikipedia);
|
||||
Init_trie_itm(rv, int_hash, "wiktionary" , Xow_domain_tid_.Tid__wiktionary);
|
||||
Init_trie_itm(rv, int_hash, "wikisource" , Xow_domain_tid_.Tid__wikisource);
|
||||
Init_trie_itm(rv, int_hash, "wikibooks" , Xow_domain_tid_.Tid__wikibooks);
|
||||
Init_trie_itm(rv, int_hash, "wikiversity" , Xow_domain_tid_.Tid__wikiversity);
|
||||
Init_trie_itm(rv, int_hash, "wikiquote" , Xow_domain_tid_.Tid__wikiquote);
|
||||
Init_trie_itm(rv, int_hash, "wikinews" , Xow_domain_tid_.Tid__wikinews);
|
||||
Init_trie_itm(rv, int_hash, "wikivoyage" , Xow_domain_tid_.Tid__wikivoyage);
|
||||
Init_trie_itm(rv, int_hash, "wikimedia" , Xow_domain_tid_.Tid__wikimedia);
|
||||
Init_trie_itm(rv, int_hash, "commonswiki" , Xow_domain_tid_.Tid__commons);
|
||||
Init_trie_itm(rv, int_hash, "specieswiki" , Xow_domain_tid_.Tid__species);
|
||||
Init_trie_itm(rv, int_hash, "metawiki" , Xow_domain_tid_.Tid__meta);
|
||||
Init_trie_itm(rv, int_hash, "incubatorwiki" , Xow_domain_tid_.Tid__incubator);
|
||||
Init_trie_itm(rv, int_hash, "wikidatawiki" , Xow_domain_tid_.Tid__wikidata);
|
||||
Init_trie_itm(rv, int_hash, "mediawikiwiki" , Xow_domain_tid_.Tid__mediawiki);
|
||||
Init_trie_itm(rv, int_hash, "foundationwiki" , Xow_domain_tid_.Tid__wmfblog);
|
||||
return rv;
|
||||
}
|
||||
private static void Init_trie_itm(Btrie_bwd_mgr trie, Hash_adp hash, String str, int tid) {
|
||||
Int_obj_ref itm = Int_obj_ref.New(tid);
|
||||
trie.Add(str, itm);
|
||||
hash.Add(itm, Bry_.new_u8(str));
|
||||
}
|
||||
}
|
||||
class Xow_abrv_wm_override {
|
||||
public static Xow_abrv_wm To_abrv_itm_or_null(byte[] abrv) {
|
||||
Object o = itm_hash.Get_by_bry(abrv);
|
||||
return o == null ? null : (Xow_abrv_wm)o;
|
||||
}
|
||||
public static byte[] To_lang_key_or_null(byte[] domain_bry) {
|
||||
Object o = lang_hash.Get_by_bry(domain_bry);
|
||||
return o == null ? null : (byte[])o;
|
||||
}
|
||||
private static final Hash_adp_bry itm_hash = itm_hash__make();
|
||||
private static Hash_adp_bry lang_hash;
|
||||
private static Hash_adp_bry itm_hash__make() {
|
||||
Hash_adp_bry rv = Hash_adp_bry.cs();
|
||||
lang_hash = Hash_adp_bry.cs();
|
||||
itm_hash__add(rv, lang_hash, "ar.wikimedia.org", "arwikimedia", "ar", Xol_lang_stub_.Id_es, Xow_domain_tid_.Tid__wikimedia); // NOTE: ar means Argentina not Arabic
|
||||
itm_hash__add(rv, lang_hash, "br.wikimedia.org", "brwikimedia", "br", Xol_lang_stub_.Id_es, Xow_domain_tid_.Tid__wikimedia); // NOTE: br means Brazil not Breto
|
||||
itm_hash__add(rv, lang_hash, "co.wikimedia.org", "cowikimedia", "co", Xol_lang_stub_.Id_es, Xow_domain_tid_.Tid__wikimedia); // NOTE: co means Columbia not Corsican
|
||||
itm_hash__add(rv, lang_hash, "ua.wikimedia.org", "ukwikimedia", "ua", Xol_lang_stub_.Id_uk, Xow_domain_tid_.Tid__wikimedia); // NOTE: ua means Ukrainian; NOTE: uk does not means United Kingdom (which redirects to https://wikimedia.org.uk)
|
||||
itm_hash__add(rv, lang_hash, "ca.wikimedia.org", "cawikimedia", "ca", Xol_lang_stub_.Id_en, Xow_domain_tid_.Tid__wikimedia); // NOTE: ca means Canada not Catalan
|
||||
itm_hash__add(rv, lang_hash, "be.wikimedia.org", "bewikimedia", "be", Xol_lang_stub_.Id_en, Xow_domain_tid_.Tid__wikimedia); // NOTE: be means Belgium not Belarusian
|
||||
itm_hash__add(rv, lang_hash, "se.wikimedia.org", "sewikimedia", "se", Xol_lang_stub_.Id_sv, Xow_domain_tid_.Tid__wikimedia); // NOTE: se means Swedish not Northern Sami
|
||||
return rv;
|
||||
}
|
||||
private static void itm_hash__add(Hash_adp_bry hash, Hash_adp_bry lang_hash, String domain, String raw, String lang_domain, int lang_actl, int domain_type) {
|
||||
byte[] abrv_bry = Bry_.new_u8(raw);
|
||||
Xol_lang_stub lang_actl_itm = Xol_lang_stub_.Get_by_id(lang_actl);
|
||||
Xow_abrv_wm itm = new Xow_abrv_wm(abrv_bry, Bry_.new_a7(lang_domain), lang_actl_itm, domain_type);
|
||||
hash.Add_bry_obj(abrv_bry, itm);
|
||||
lang_hash.Add_str_obj(domain, lang_actl_itm.Key());
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.xowa.langs.*;
|
||||
public class Xow_abrv_wm_tst {
|
||||
private Xow_abrv_wm_fxt fxt = new Xow_abrv_wm_fxt();
|
||||
@Test public void Parse() {
|
||||
fxt.Test_parse("foundationwiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__wmfblog);
|
||||
fxt.Test_parse("wikidatawiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__wikidata);
|
||||
fxt.Test_parse("mediawikiwiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__mediawiki);
|
||||
fxt.Test_parse("commonswiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__commons);
|
||||
fxt.Test_parse("specieswiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__species);
|
||||
fxt.Test_parse("metawiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__meta);
|
||||
fxt.Test_parse("incubatorwiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__incubator);
|
||||
fxt.Test_parse("enwiki" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikipedia);
|
||||
fxt.Test_parse("enwiktionary" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wiktionary);
|
||||
fxt.Test_parse("enwikisource" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikisource);
|
||||
fxt.Test_parse("enwikibooks" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikibooks);
|
||||
fxt.Test_parse("enwikiversity" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikiversity);
|
||||
fxt.Test_parse("enwikiquote" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikiquote);
|
||||
fxt.Test_parse("enwikinews" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikinews);
|
||||
fxt.Test_parse("enwikivoyage" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikivoyage);
|
||||
fxt.Test_parse("frwiki" , Xol_lang_stub_.Id_fr , Xow_domain_tid_.Tid__wikipedia);
|
||||
fxt.Test_parse_null("unknown");
|
||||
fxt.Test_parse("plwikimedia" , Xol_lang_stub_.Id_pl , Xow_domain_tid_.Tid__wikimedia);
|
||||
}
|
||||
@Test public void Parse_override() {
|
||||
fxt.Test_parse("arwikimedia" , Xol_lang_stub_.Id_es , Xow_domain_tid_.Tid__wikimedia);
|
||||
fxt.Test_parse("ukwikimedia" , Xol_lang_stub_.Id_uk , Xow_domain_tid_.Tid__wikimedia);
|
||||
}
|
||||
@Test public void To_domain_itm() {
|
||||
fxt.Test_to_domain_itm("enwiki" , "en" , "en.wikipedia.org");
|
||||
fxt.Test_to_domain_itm("zh_yuewiki" , "zh-yue" , "zh-yue.wikipedia.org");
|
||||
}
|
||||
@Test public void To_domain_bry() {
|
||||
fxt.Test_to_domain_bry("enwiki" , "en.wikipedia.org");
|
||||
fxt.Test_to_domain_bry("zh_yuewiki" , "zh-yue.wikipedia.org");
|
||||
fxt.Test_to_domain_bry("arwikimedia", "ar.wikimedia.org");
|
||||
fxt.Test_to_domain_bry("ukwikimedia", "ua.wikimedia.org");
|
||||
}
|
||||
@Test public void To_abrv() {
|
||||
fxt.Test_to_abrv("simple.wikipedia.org" , "simplewiki");
|
||||
fxt.Test_to_abrv("en.wikipedia.org" , "enwiki");
|
||||
fxt.Test_to_abrv("commons.wikimedia.org" , "commonswiki");
|
||||
}
|
||||
@Test public void To_abrv_by_lang() {
|
||||
fxt.Test_to_abrv_by_lang("en", Xow_domain_tid_.Tid__wikipedia, "enwiki");
|
||||
}
|
||||
}
|
||||
class Xow_abrv_wm_fxt {
|
||||
public void Test_parse(String raw, int expd_lang_id, int expd_domain_tid) {
|
||||
byte[] raw_bry = Bry_.new_a7(raw);
|
||||
Xow_abrv_wm abrv = Xow_abrv_wm_.Parse_to_abrv_or_null(raw_bry);
|
||||
Xol_lang_stub actl_lang_itm = abrv.Lang_actl();
|
||||
Tfds.Eq(expd_lang_id , actl_lang_itm == null ? Xol_lang_stub_.Id__unknown : actl_lang_itm.Id());
|
||||
Tfds.Eq(expd_domain_tid , abrv.Domain_type());
|
||||
}
|
||||
public void Test_parse_null(String raw) {
|
||||
byte[] raw_bry = Bry_.new_a7(raw);
|
||||
Xow_abrv_wm abrv = Xow_abrv_wm_.Parse_to_abrv_or_null(raw_bry);
|
||||
Tfds.Eq_true(abrv == null);
|
||||
}
|
||||
public void Test_to_abrv(String domain_str, String expd) {
|
||||
Xow_domain_itm domain = Xow_domain_itm_.parse(Bry_.new_a7(domain_str));
|
||||
byte[] actl = Xow_abrv_wm_.To_abrv(domain);
|
||||
Tfds.Eq(expd, String_.new_a7(actl));
|
||||
}
|
||||
public void Test_to_abrv_by_lang(String lang_key, int wiki_tid, String expd) {
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.Reset(255);
|
||||
Xow_abrv_wm_.To_abrv(tmp_bfr, Bry_.new_a7(lang_key), gplx.core.primitives.Int_obj_ref.New(wiki_tid));
|
||||
Tfds.Eq_str(expd, tmp_bfr.To_str_and_clear(), "to_abrv");
|
||||
}
|
||||
public void Test_to_domain_bry(String wmf_key, String expd_domain) {
|
||||
Tfds.Eq(expd_domain , String_.new_a7(Xow_abrv_wm_.Parse_to_domain_bry(Bry_.new_a7(wmf_key))));
|
||||
}
|
||||
public void Test_to_domain_itm(String wmf_key, String expd_lang_key, String expd_domain) {
|
||||
Xow_domain_itm domain = Xow_abrv_wm_.Parse_to_domain_itm(Bry_.new_a7(wmf_key));
|
||||
Tfds.Eq(expd_lang_key , String_.new_a7(domain.Lang_actl_key()));
|
||||
Tfds.Eq(expd_domain , String_.new_a7(domain.Domain_bry()));
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xow_abrv_xo_ {
|
||||
public static byte[] To_bry(byte[] domain_bry) {
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(domain_bry);
|
||||
return Xow_abrv_xo_.To_bry(domain_itm.Domain_bry(), domain_itm.Lang_orig_key(), domain_itm.Domain_type());
|
||||
}
|
||||
public static byte[] To_bry(byte[] domain_bry, byte[] lang_key, Xow_domain_tid type) { // en.wikipedia.org -> en.w
|
||||
byte[] type_abrv = type.Abrv();
|
||||
if (type.Multi_lang()) // wikipedia,wiktionary,etc..
|
||||
return Bry_.Add(lang_key, Byte_ascii.Dot_bry, type_abrv);
|
||||
else if (type_abrv.length > 0) // commons,wbase,species,etc..
|
||||
return type_abrv;
|
||||
else // home;wikia;others
|
||||
return domain_bry;
|
||||
}
|
||||
public static Xow_domain_itm To_itm(byte[] src) {
|
||||
int src_len = src.length;
|
||||
byte[] domain_bry = src; // default to src; handles unknown abrv like "a.wikia.com";"xowa";others
|
||||
Xow_domain_tid type = null;
|
||||
int dot_pos = Bry_find_.Find_fwd(src, Byte_ascii.Dot);
|
||||
if (dot_pos != Bry_find_.Not_found) { // dot found; EX: "en.w"
|
||||
type = Xow_domain_tid_.Get_abrv_as_itm(src, dot_pos + 1, src_len);
|
||||
if (type != null) { // type found; EX: ".w"
|
||||
Xol_lang_stub lang = Xol_lang_stub_.Get_by_key_or_null(src, 0, dot_pos);
|
||||
if (lang != null) // lang found; EX: "en."
|
||||
domain_bry = Bry_.Add(lang.Key(), type.Domain_bry());
|
||||
}
|
||||
}
|
||||
else { // dot missing; EX: "c"
|
||||
type = Xow_domain_tid_.Get_abrv_as_itm(src, 0, src_len);
|
||||
if (type != null) { // type found; EX: "c"
|
||||
domain_bry = type.Domain_bry();
|
||||
}
|
||||
}
|
||||
return Xow_domain_itm_.parse(domain_bry); // for consolidation's sake, parse abrv to domain_bry and pass to Xow_domain_itm_.parse()
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*;
|
||||
public class Xow_abrv_xo__tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xow_abrv_xo__fxt fxt = new Xow_abrv_xo__fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test("en.wikipedia.org" , "en.w"); // multi.enwiki
|
||||
fxt.Test("fr.wiktionary.org" , "fr.d"); // multi.frwiktionary
|
||||
fxt.Test("commons.wikimedia.org" , "c"); // important.unique.commons
|
||||
fxt.Test("species.wikimedia.org" , "species"); // important.unique.species
|
||||
fxt.Test("www.wikidata.org" , "wd"); // important.unique.wikidata
|
||||
fxt.Test("home" , "home"); // important.unique.xowa
|
||||
fxt.Test("meta.wikimedia.org" , "meta"); // wikimedia.unique
|
||||
fxt.Test("pl.wikimedia.org" , "pl.m"); // wikimedia.multi
|
||||
fxt.Test("a.b.c" , "a.b.c"); // unkonwn
|
||||
}
|
||||
}
|
||||
class Xow_abrv_xo__fxt {
|
||||
public void Clear() {}
|
||||
public void Test(String domain_str, String expd_abrv) {
|
||||
Xow_domain_itm domain = Xow_domain_itm_.parse(Bry_.new_u8(domain_str));
|
||||
byte[] actl_abrv = Xow_abrv_xo_.To_bry(domain.Domain_bry(), domain.Lang_actl_key(), domain.Domain_type());
|
||||
Tfds.Eq(expd_abrv, String_.new_u8(actl_abrv), "To_bry");
|
||||
domain = Xow_abrv_xo_.To_itm(actl_abrv);
|
||||
Tfds.Eq(domain_str, domain.Domain_str(), "To_itm");
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xow_domain_itm {
|
||||
Xow_domain_itm(byte[] domain_bry, Xow_domain_tid domain_type, Xol_lang_stub lang_actl_itm, byte[] lang_orig_key) {
|
||||
this.domain_bry = domain_bry; this.domain_type = domain_type; this.lang_actl_itm = lang_actl_itm; this.lang_orig_key = lang_orig_key;
|
||||
this.domain_str = String_.new_u8(domain_bry);
|
||||
this.abrv_wm = Xow_abrv_wm_.To_abrv(this);
|
||||
this.abrv_xo = Xow_abrv_xo_.To_bry(domain_bry, lang_orig_key, domain_type);
|
||||
this.abrv_xo_str = String_.new_u8(abrv_xo);
|
||||
}
|
||||
public byte[] Domain_bry() {return domain_bry;} private final byte[] domain_bry;
|
||||
public String Domain_str() {return domain_str;} private final String domain_str;
|
||||
public Xow_domain_tid Domain_type() {return domain_type;} private final Xow_domain_tid domain_type;
|
||||
public int Domain_type_id() {return domain_type.Tid();}
|
||||
public byte[] Abrv_wm() {return abrv_wm;} private final byte[] abrv_wm; // EX: enwiki
|
||||
public byte[] Abrv_xo() {return abrv_xo;} private final byte[] abrv_xo; // EX: en.w
|
||||
public String Abrv_xo_str() {return abrv_xo_str;} private final String abrv_xo_str; // EX: en.w
|
||||
public Xol_lang_stub Lang_actl_itm() {return lang_actl_itm;} private final Xol_lang_stub lang_actl_itm; // EX: zh
|
||||
public int Lang_actl_uid() {return lang_actl_itm.Id();}
|
||||
public byte[] Lang_actl_key() {return lang_actl_itm.Key();}
|
||||
public byte[] Lang_orig_key() {return lang_orig_key;} private final byte[] lang_orig_key; // EX: lzh
|
||||
public int Sort_idx() {return sort_idx;} public void Sort_idx_(int v) {sort_idx = v;} private int sort_idx = -1; // used for Search
|
||||
public static Xow_domain_itm new_(byte[] domain_bry, int domain_tid, byte[] lang_key) {
|
||||
Xol_lang_stub lang_actl_itm = Xol_lang_stub_.Get_by_key_or_intl(lang_key);
|
||||
return new Xow_domain_itm(domain_bry, Xow_domain_tid_.Get_type_as_itm(domain_tid), lang_actl_itm, lang_actl_itm.Key());
|
||||
}
|
||||
public static Xow_domain_itm new_(byte[] domain_bry, int domain_tid, Xol_lang_stub lang_actl, byte[] lang_orig) {
|
||||
return new Xow_domain_itm(domain_bry, Xow_domain_tid_.Get_type_as_itm(domain_tid), lang_actl, lang_orig);
|
||||
}
|
||||
public static Xow_domain_itm new_(byte[] domain_bry, int domain_tid, byte[] lang_actl_key, byte[] lang_orig_key) {
|
||||
return new Xow_domain_itm(domain_bry, Xow_domain_tid_.Get_type_as_itm(domain_tid), Xol_lang_stub_.Get_by_key_or_intl(lang_actl_key), lang_orig_key);
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xow_domain_itm_ {
|
||||
public static final Xow_domain_itm[] Ary_empty = new Xow_domain_itm[0];
|
||||
public static Xow_domain_itm parse(byte[] raw) {
|
||||
/*
|
||||
~{type}.org EX: wikimediafoundation
|
||||
~{type}.wikimedia.org EX: commons; species; meta; incubator
|
||||
~{lang}.~{type}.org EX: en.wikipedia, etc;
|
||||
~www.~{type}.org EX: mediawiki; wikidata;
|
||||
*/
|
||||
int raw_len = raw.length;
|
||||
int dot_0 = Bry_find_.Find_fwd(raw, Byte_ascii.Dot, 0, raw_len);
|
||||
if (dot_0 == Bry_find_.Not_found) { // 0 dots; check for "home"
|
||||
return Bry_.Eq(raw, Xow_domain_tid_.Bry__home)
|
||||
? Xow_domain_uid_.To_domain(Xow_domain_uid_.Tid_xowa)
|
||||
: new_other(raw);
|
||||
}
|
||||
int dot_1 = Bry_find_.Find_fwd(raw, Byte_ascii.Dot, dot_0 + 1, raw_len);
|
||||
if (dot_1 == Bry_find_.Not_found) { // 1 dot; check for "wikimediafoundation.org"
|
||||
return Bry_.Match(raw, 0, dot_0, Xow_domain_tid_.Bry__wmforg)
|
||||
? Xow_domain_itm.new_(raw, Xow_domain_tid_.Tid__wmfblog, Xol_lang_stub_.Key__unknown)
|
||||
: new_other(raw);
|
||||
}
|
||||
// 2 dots
|
||||
int seg_1_tid = Xow_domain_tid_.Get_type_as_tid(raw, dot_0 + 1, dot_1); // parse middle; EX: ".wikipedia."
|
||||
if (seg_1_tid == Xow_domain_tid_.Tid__null) return new_other(raw); // seg_1 is unknown; return other;
|
||||
switch (seg_1_tid) {
|
||||
case Xow_domain_tid_.Tid__wikipedia: case Xow_domain_tid_.Tid__wiktionary: case Xow_domain_tid_.Tid__wikisource: case Xow_domain_tid_.Tid__wikibooks:
|
||||
case Xow_domain_tid_.Tid__wikiversity: case Xow_domain_tid_.Tid__wikiquote: case Xow_domain_tid_.Tid__wikinews: case Xow_domain_tid_.Tid__wikivoyage: // ~{lang}.~{type}.org
|
||||
byte[] lang_orig = Bry_.Mid(raw, 0, dot_0);
|
||||
byte[] lang_actl = Get_lang_code_for_mw_messages_file(lang_orig);
|
||||
return Xow_domain_itm.new_(raw, seg_1_tid, lang_actl, lang_orig); // NOTE: seg_tids must match wiki_tids
|
||||
case Xow_domain_tid_.Tid__wikidata: case Xow_domain_tid_.Tid__mediawiki:// ~www.~{type}.org
|
||||
return Xow_domain_itm.new_(raw, seg_1_tid, Xol_lang_stub_.Key__unknown);
|
||||
case Xow_domain_tid_.Tid__wikimedia: // ~{type}.wikimedia.org;
|
||||
int seg_0_tid = Xow_domain_tid_.Get_type_as_tid(raw, 0, dot_0); // try to get "incubator", "meta", etc..
|
||||
if (seg_0_tid == Xow_domain_tid_.Tid__null) { // not a known name; try language
|
||||
byte[] lang_override = Xow_abrv_wm_override.To_lang_key_or_null(raw); // handle "lang-like" wikimedia domains like "ar.wikimedia.org" which is actually to "Argentina Wikimedia"
|
||||
if (lang_override == null) {
|
||||
Xol_lang_stub wikimedia_lang = Xol_lang_stub_.Get_by_key_or_null(raw, 0, dot_0);
|
||||
return wikimedia_lang == null ? new_other(raw) : Xow_domain_itm.new_(raw, Xow_domain_tid_.Tid__wikimedia, wikimedia_lang.Key());
|
||||
}
|
||||
else
|
||||
return Xow_domain_itm.new_(raw, Xow_domain_tid_.Tid__wikimedia, lang_override, Bry_.Mid(raw, 0, dot_0));
|
||||
}
|
||||
switch (seg_0_tid) {
|
||||
case Xow_domain_tid_.Tid__commons: case Xow_domain_tid_.Tid__species: case Xow_domain_tid_.Tid__meta: case Xow_domain_tid_.Tid__incubator:
|
||||
return Xow_domain_itm.new_(raw, seg_0_tid, Xol_lang_stub_.Key__unknown); // NOTE: seg_tids must match wiki_tids; NOTE: lang_key is "en" (really, "multi" but making things easier)
|
||||
default:
|
||||
return new_other(raw);
|
||||
}
|
||||
case Xow_domain_tid_.Tid__other:
|
||||
default:
|
||||
return new_other(raw);
|
||||
}
|
||||
}
|
||||
public static boolean Match_lang(Xow_domain_itm domain, String match) {
|
||||
// exit early if "*"
|
||||
if (String_.Eq(match, Lang_key__all)) return true;
|
||||
|
||||
// get lang
|
||||
String cur = String_.new_u8(domain.Lang_actl_key());
|
||||
|
||||
// return true if direct match; EX: "en" <-> "en"; "de" <-> "de"
|
||||
if (String_.Eq(cur, match)) return true;
|
||||
|
||||
// handle special cases
|
||||
if (String_.Eq(match, "en"))
|
||||
return String_.In(domain.Domain_str(), "simple.wikipedia.org", "species.wikimedia.org", "www.wikidata.org", "commons.wikimedia.org");
|
||||
else if (String_.Eq(match, "zh"))
|
||||
return String_.Eq(cur, "lzh");
|
||||
return false;
|
||||
}
|
||||
public static boolean Match_type(Xow_domain_itm domain, String match) {
|
||||
// exit early if "*"
|
||||
if (String_.Eq(match, Type_key__all)) return true;
|
||||
|
||||
// get lang
|
||||
String cur = domain.Domain_type().Key_str();
|
||||
|
||||
// return true if direct match; EX: "wiki" <-> "wiki"; "wiktionary" <-> "wiktionary"
|
||||
if (String_.Eq(cur, match)) return true;
|
||||
|
||||
// handle special cases
|
||||
if (String_.Eq(match, "wikimisc"))
|
||||
return String_.In(domain.Domain_str(), "species.wikimedia.org", "www.wikidata.org", "commons.wikimedia.org");
|
||||
return false;
|
||||
}
|
||||
public static final String Lang_key__all = "*", Type_key__all = "*";
|
||||
|
||||
private static Xow_domain_itm new_other(byte[] raw) {return Xow_domain_itm.new_(raw, Xow_domain_tid_.Tid__other, Xol_lang_stub_.Key__unknown);}
|
||||
private static byte[] Get_lang_code_for_mw_messages_file(byte[] v) {
|
||||
Object o = alt_domain__lang_by_subdomain.Get_by_bry(v);
|
||||
return o == null ? v : (byte[])o;
|
||||
}
|
||||
public static byte[] Alt_domain__get_subdomain_by_lang(byte[] lang) {
|
||||
Object o = alt_domain__subdomain_by_lang.Get_by_bry(lang);
|
||||
return o == null ? lang : (byte[])o;
|
||||
}
|
||||
private static final Hash_adp_bry alt_domain__lang_by_subdomain = Hash_adp_bry.ci_a7() // ASCII:lang_code
|
||||
.Add_str_obj("simple" , Bry_.new_a7("en"))
|
||||
.Add_str_obj("zh-classical" , Bry_.new_a7("lzh"))
|
||||
.Add_str_obj("no" , Bry_.new_a7("nb"))
|
||||
;
|
||||
private static final Hash_adp_bry alt_domain__subdomain_by_lang = Hash_adp_bry.ci_a7() // ASCII:lang_code
|
||||
.Add_str_obj("lzh" , Bry_.new_a7("zh-classical"))
|
||||
.Add_str_obj("nb" , Bry_.new_a7("no"))
|
||||
;
|
||||
public static final String
|
||||
Str__enwiki = "en.wikipedia.org"
|
||||
, Str__species = "species.wikimedia.org"
|
||||
, Str__commons = "commons.wikimedia.org"
|
||||
, Str__wikidata = "www.wikidata.org"
|
||||
, Str__mediawiki = "www.mediawiki.org"
|
||||
, Str__meta = "meta.wikimedia.org"
|
||||
, Str__incubator = "incubator.wikimedia.org"
|
||||
, Str__wmforg = "wikimediafoundation.org"
|
||||
, Str__home = "home"
|
||||
;
|
||||
public static final byte[]
|
||||
Bry__enwiki = Bry_.new_a7(Str__enwiki)
|
||||
, Bry__species = Bry_.new_a7(Str__species)
|
||||
, Bry__commons = Bry_.new_a7(Str__commons)
|
||||
, Bry__wikidata = Bry_.new_a7(Str__wikidata)
|
||||
, Bry__mediawiki = Bry_.new_a7(Str__mediawiki)
|
||||
, Bry__meta = Bry_.new_a7(Str__meta)
|
||||
, Bry__incubator = Bry_.new_a7(Str__incubator)
|
||||
, Bry__wmforg = Bry_.new_a7(Str__wmforg)
|
||||
, Bry__home = Bry_.new_a7(Str__home)
|
||||
, Bry__simplewiki = Bry_.new_a7("simple.wikipedia.org")
|
||||
;
|
||||
public static final byte[] Seg__org = Bry_.new_a7("org"), Seg__www = Bry_.new_a7("www");
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Xow_domain_itm_tst {
|
||||
private final Xow_domain_fxt fxt = new Xow_domain_fxt();
|
||||
@Test public void Parse_en_wikipedia() {fxt.Test_parse("en.wikipedia.org" , "en" , "en" , Xow_domain_tid_.Tid__wikipedia);}
|
||||
@Test public void Parse_fr_wikipedia() {fxt.Test_parse("fr.wikipedia.org" , "fr" , "fr" , Xow_domain_tid_.Tid__wikipedia);}
|
||||
@Test public void Parse_en_wiktionary() {fxt.Test_parse("en.wiktionary.org" , "en" , "en" , Xow_domain_tid_.Tid__wiktionary);}
|
||||
@Test public void Parse_zh_classical_wikipedia() {fxt.Test_parse("zh-classical.wikipedia.org" , "zh-classical" , "lzh" , Xow_domain_tid_.Tid__wikipedia);}
|
||||
@Test public void Parse_commons() {fxt.Test_parse("commons.wikimedia.org" , "" , "" , Xow_domain_tid_.Tid__commons);}
|
||||
@Test public void Parse_species() {fxt.Test_parse("species.wikimedia.org" , "" , "" , Xow_domain_tid_.Tid__species);}
|
||||
@Test public void Parse_ru_wikimedia_org() {fxt.Test_parse("ru.wikimedia.org" , "ru" , "ru" , Xow_domain_tid_.Tid__wikimedia);}
|
||||
@Test public void Parse_home() {fxt.Test_parse("home" , "" , "" , Xow_domain_tid_.Tid__home);}
|
||||
@Test public void Parse_other() {fxt.Test_parse("other.wiki" , "" , "" , Xow_domain_tid_.Tid__other);}
|
||||
@Test public void Parse_ua_wikimedia_org() {fxt.Test_parse("ua.wikimedia.org" , "ua" , "uk" , Xow_domain_tid_.Tid__wikimedia);}
|
||||
@Test public void Parse_ar_wikimedia_org() {fxt.Test_parse("ar.wikimedia.org" , "ar" , "es" , Xow_domain_tid_.Tid__wikimedia);}
|
||||
@Test public void Parse_blank() {fxt.Test_parse("" , "" , "" , Xow_domain_tid_.Tid__other);}
|
||||
@Test public void Match_lang() {
|
||||
fxt.Test__match_lang_y("en", "en.wikipedia.org", "en.wiktionary.org", "simple.wikipedia.org", "species.wikimedia.org", "www.wikidata.org", "commons.wikimedia.org");
|
||||
fxt.Test__match_lang_y("fr", "fr.wikipedia.org", "fr.wiktionary.org");
|
||||
fxt.Test__match_lang_y("zh", "zh-classical.wikipedia.org");
|
||||
}
|
||||
}
|
||||
class Xow_domain_fxt {
|
||||
public void Test_parse(String domain, String expd_orig_lang, String expd_actl_lang, int expd_tid) {
|
||||
Xow_domain_itm actl = Xow_domain_itm_.parse(Bry_.new_a7(domain));
|
||||
Tfds.Eq_str(expd_orig_lang, String_.new_a7((actl.Lang_orig_key())));
|
||||
Tfds.Eq_str(expd_actl_lang, String_.new_a7((actl.Lang_actl_key())));
|
||||
Tfds.Eq_int(expd_tid, actl.Domain_type_id());
|
||||
}
|
||||
public void Test__match_lang_y(String lang_code, String... domains) {Test__match_lang(Bool_.Y, lang_code, domains);}
|
||||
public void Test__match_lang(boolean expd, String lang_key_str, String[] domains) {
|
||||
int len = domains.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xow_domain_itm domain = Xow_domain_itm_.parse(Bry_.new_u8(domains[i]));
|
||||
Gftest.Eq__bool(expd, Xow_domain_itm_.Match_lang(domain, lang_key_str), lang_key_str + "|" + domains[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,858 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xow_domain_regy {
|
||||
public static String[] All = new String[]
|
||||
{ "commons.wikimedia.org"
|
||||
, "species.wikimedia.org"
|
||||
, "meta.wikimedia.org"
|
||||
, "incubator.wikimedia.org"
|
||||
, "www.wikidata.org"
|
||||
, "www.mediawiki.org"
|
||||
, "wikimediafoundation.org"
|
||||
, "en.wikipedia.org"
|
||||
, "en.wiktionary.org"
|
||||
, "en.wikisource.org"
|
||||
, "en.wikibooks.org"
|
||||
, "en.wikiversity.org"
|
||||
, "en.wikiquote.org"
|
||||
, "en.wikinews.org"
|
||||
, "en.wikivoyage.org"
|
||||
, "de.wikipedia.org"
|
||||
, "de.wiktionary.org"
|
||||
, "de.wikisource.org"
|
||||
, "de.wikibooks.org"
|
||||
, "de.wikiversity.org"
|
||||
, "de.wikiquote.org"
|
||||
, "de.wikinews.org"
|
||||
, "de.wikivoyage.org"
|
||||
, "es.wikipedia.org"
|
||||
, "es.wiktionary.org"
|
||||
, "es.wikisource.org"
|
||||
, "es.wikibooks.org"
|
||||
, "es.wikiversity.org"
|
||||
, "es.wikiquote.org"
|
||||
, "es.wikinews.org"
|
||||
, "es.wikivoyage.org"
|
||||
, "fr.wikipedia.org"
|
||||
, "fr.wiktionary.org"
|
||||
, "fr.wikisource.org"
|
||||
, "fr.wikibooks.org"
|
||||
, "fr.wikiversity.org"
|
||||
, "fr.wikiquote.org"
|
||||
, "fr.wikinews.org"
|
||||
, "fr.wikivoyage.org"
|
||||
, "it.wikipedia.org"
|
||||
, "it.wiktionary.org"
|
||||
, "it.wikisource.org"
|
||||
, "it.wikibooks.org"
|
||||
, "it.wikiversity.org"
|
||||
, "it.wikiquote.org"
|
||||
, "it.wikinews.org"
|
||||
, "it.wikivoyage.org"
|
||||
, "ja.wikipedia.org"
|
||||
, "ja.wiktionary.org"
|
||||
, "ja.wikisource.org"
|
||||
, "ja.wikibooks.org"
|
||||
, "ja.wikiversity.org"
|
||||
, "ja.wikiquote.org"
|
||||
, "ja.wikinews.org"
|
||||
, "nl.wikipedia.org"
|
||||
, "nl.wiktionary.org"
|
||||
, "nl.wikisource.org"
|
||||
, "nl.wikibooks.org"
|
||||
, "nl.wikiquote.org"
|
||||
, "nl.wikinews.org"
|
||||
, "nl.wikivoyage.org"
|
||||
, "nl.wikimedia.org"
|
||||
, "pl.wikipedia.org"
|
||||
, "pl.wiktionary.org"
|
||||
, "pl.wikisource.org"
|
||||
, "pl.wikibooks.org"
|
||||
, "pl.wikiquote.org"
|
||||
, "pl.wikinews.org"
|
||||
, "pl.wikivoyage.org"
|
||||
, "pl.wikimedia.org"
|
||||
, "pt.wikipedia.org"
|
||||
, "pt.wiktionary.org"
|
||||
, "pt.wikisource.org"
|
||||
, "pt.wikibooks.org"
|
||||
, "pt.wikiversity.org"
|
||||
, "pt.wikiquote.org"
|
||||
, "pt.wikinews.org"
|
||||
, "pt.wikivoyage.org"
|
||||
, "ru.wikipedia.org"
|
||||
, "ru.wiktionary.org"
|
||||
, "ru.wikisource.org"
|
||||
, "ru.wikibooks.org"
|
||||
, "ru.wikiversity.org"
|
||||
, "ru.wikiquote.org"
|
||||
, "ru.wikinews.org"
|
||||
, "ru.wikivoyage.org"
|
||||
, "ru.wikimedia.org"
|
||||
, "ar.wikipedia.org"
|
||||
, "ar.wiktionary.org"
|
||||
, "ar.wikisource.org"
|
||||
, "ar.wikibooks.org"
|
||||
, "ar.wikiversity.org"
|
||||
, "ar.wikiquote.org"
|
||||
, "ar.wikinews.org"
|
||||
, "ar.wikimedia.org"
|
||||
, "ca.wikipedia.org"
|
||||
, "ca.wiktionary.org"
|
||||
, "ca.wikisource.org"
|
||||
, "ca.wikibooks.org"
|
||||
, "ca.wikiquote.org"
|
||||
, "ca.wikinews.org"
|
||||
, "ca.wikimedia.org"
|
||||
, "cs.wikipedia.org"
|
||||
, "cs.wiktionary.org"
|
||||
, "cs.wikisource.org"
|
||||
, "cs.wikibooks.org"
|
||||
, "cs.wikiversity.org"
|
||||
, "cs.wikiquote.org"
|
||||
, "cs.wikinews.org"
|
||||
, "da.wikipedia.org"
|
||||
, "da.wiktionary.org"
|
||||
, "da.wikisource.org"
|
||||
, "da.wikibooks.org"
|
||||
, "da.wikiquote.org"
|
||||
, "eo.wikipedia.org"
|
||||
, "eo.wiktionary.org"
|
||||
, "eo.wikisource.org"
|
||||
, "eo.wikibooks.org"
|
||||
, "eo.wikiquote.org"
|
||||
, "eo.wikinews.org"
|
||||
, "fa.wikipedia.org"
|
||||
, "fa.wiktionary.org"
|
||||
, "fa.wikisource.org"
|
||||
, "fa.wikibooks.org"
|
||||
, "fa.wikiquote.org"
|
||||
, "fa.wikinews.org"
|
||||
, "fa.wikivoyage.org"
|
||||
, "fi.wikipedia.org"
|
||||
, "fi.wiktionary.org"
|
||||
, "fi.wikisource.org"
|
||||
, "fi.wikivoyage.org"
|
||||
, "fi.wikibooks.org"
|
||||
, "fi.wikiversity.org"
|
||||
, "fi.wikiquote.org"
|
||||
, "fi.wikinews.org"
|
||||
, "fi.wikimedia.org"
|
||||
, "hu.wikipedia.org"
|
||||
, "hu.wiktionary.org"
|
||||
, "hu.wikisource.org"
|
||||
, "hu.wikibooks.org"
|
||||
, "hu.wikiquote.org"
|
||||
, "hu.wikinews.org"
|
||||
, "id.wikipedia.org"
|
||||
, "id.wiktionary.org"
|
||||
, "id.wikisource.org"
|
||||
, "id.wikibooks.org"
|
||||
, "id.wikiquote.org"
|
||||
, "kk.wikipedia.org"
|
||||
, "kk.wiktionary.org"
|
||||
, "kk.wikibooks.org"
|
||||
, "kk.wikiquote.org"
|
||||
, "ko.wikipedia.org"
|
||||
, "ko.wiktionary.org"
|
||||
, "ko.wikisource.org"
|
||||
, "ko.wikibooks.org"
|
||||
, "ko.wikiversity.org"
|
||||
, "ko.wikiquote.org"
|
||||
, "ko.wikinews.org"
|
||||
, "lt.wikipedia.org"
|
||||
, "lt.wiktionary.org"
|
||||
, "lt.wikisource.org"
|
||||
, "lt.wikibooks.org"
|
||||
, "lt.wikiquote.org"
|
||||
, "no.wikipedia.org"
|
||||
, "no.wiktionary.org"
|
||||
, "no.wikisource.org"
|
||||
, "no.wikibooks.org"
|
||||
, "no.wikiquote.org"
|
||||
, "no.wikinews.org"
|
||||
, "no.wikimedia.org"
|
||||
, "ro.wikipedia.org"
|
||||
, "ro.wiktionary.org"
|
||||
, "ro.wikisource.org"
|
||||
, "ro.wikibooks.org"
|
||||
, "ro.wikiquote.org"
|
||||
, "ro.wikinews.org"
|
||||
, "ro.wikivoyage.org"
|
||||
, "sk.wikipedia.org"
|
||||
, "sk.wiktionary.org"
|
||||
, "sk.wikisource.org"
|
||||
, "sk.wikibooks.org"
|
||||
, "sk.wikiquote.org"
|
||||
, "sr.wikipedia.org"
|
||||
, "sr.wiktionary.org"
|
||||
, "sr.wikisource.org"
|
||||
, "sr.wikibooks.org"
|
||||
, "sr.wikiquote.org"
|
||||
, "sr.wikinews.org"
|
||||
, "sv.wikipedia.org"
|
||||
, "sv.wiktionary.org"
|
||||
, "sv.wikisource.org"
|
||||
, "sv.wikibooks.org"
|
||||
, "sv.wikiversity.org"
|
||||
, "sv.wikiquote.org"
|
||||
, "sv.wikinews.org"
|
||||
, "sv.wikivoyage.org"
|
||||
, "tr.wikipedia.org"
|
||||
, "tr.wiktionary.org"
|
||||
, "tr.wikisource.org"
|
||||
, "tr.wikibooks.org"
|
||||
, "tr.wikiquote.org"
|
||||
, "tr.wikinews.org"
|
||||
, "tr.wikimedia.org"
|
||||
, "uk.wikipedia.org"
|
||||
, "uk.wiktionary.org"
|
||||
, "uk.wikisource.org"
|
||||
, "uk.wikibooks.org"
|
||||
, "uk.wikiquote.org"
|
||||
, "uk.wikinews.org"
|
||||
, "uk.wikivoyage.org"
|
||||
, "ua.wikimedia.org"
|
||||
, "vi.wikipedia.org"
|
||||
, "vi.wiktionary.org"
|
||||
, "vi.wikisource.org"
|
||||
, "vi.wikibooks.org"
|
||||
, "vi.wikiquote.org"
|
||||
, "vi.wikivoyage.org"
|
||||
, "zh.wikipedia.org"
|
||||
, "zh.wiktionary.org"
|
||||
, "zh.wikisource.org"
|
||||
, "zh.wikibooks.org"
|
||||
, "zh.wikiquote.org"
|
||||
, "zh.wikinews.org"
|
||||
, "zh.wikivoyage.org"
|
||||
, "bg.wikipedia.org"
|
||||
, "bg.wiktionary.org"
|
||||
, "bg.wikisource.org"
|
||||
, "bg.wikibooks.org"
|
||||
, "bg.wikiquote.org"
|
||||
, "bg.wikinews.org"
|
||||
, "el.wikipedia.org"
|
||||
, "el.wiktionary.org"
|
||||
, "el.wikisource.org"
|
||||
, "el.wikibooks.org"
|
||||
, "el.wikiversity.org"
|
||||
, "el.wikiquote.org"
|
||||
, "el.wikinews.org"
|
||||
, "el.wikivoyage.org"
|
||||
, "et.wikipedia.org"
|
||||
, "et.wiktionary.org"
|
||||
, "et.wikisource.org"
|
||||
, "et.wikibooks.org"
|
||||
, "et.wikiquote.org"
|
||||
, "et.wikimedia.org"
|
||||
, "eu.wikipedia.org"
|
||||
, "eu.wiktionary.org"
|
||||
, "eu.wikibooks.org"
|
||||
, "eu.wikiquote.org"
|
||||
, "gl.wikipedia.org"
|
||||
, "gl.wiktionary.org"
|
||||
, "gl.wikisource.org"
|
||||
, "gl.wikibooks.org"
|
||||
, "gl.wikiquote.org"
|
||||
, "he.wikipedia.org"
|
||||
, "he.wiktionary.org"
|
||||
, "he.wikisource.org"
|
||||
, "he.wikibooks.org"
|
||||
, "he.wikiquote.org"
|
||||
, "he.wikinews.org"
|
||||
, "he.wikivoyage.org"
|
||||
, "hr.wikipedia.org"
|
||||
, "hr.wiktionary.org"
|
||||
, "hr.wikisource.org"
|
||||
, "hr.wikibooks.org"
|
||||
, "hr.wikiquote.org"
|
||||
, "ms.wikipedia.org"
|
||||
, "ms.wiktionary.org"
|
||||
, "ms.wikibooks.org"
|
||||
, "nn.wikipedia.org"
|
||||
, "nn.wiktionary.org"
|
||||
, "nn.wikiquote.org"
|
||||
, "sh.wikipedia.org"
|
||||
, "sh.wiktionary.org"
|
||||
, "simple.wikipedia.org"
|
||||
, "simple.wiktionary.org"
|
||||
, "simple.wikibooks.org"
|
||||
, "simple.wikiquote.org"
|
||||
, "sl.wikipedia.org"
|
||||
, "sl.wiktionary.org"
|
||||
, "sl.wikisource.org"
|
||||
, "sl.wikibooks.org"
|
||||
, "sl.wikiversity.org"
|
||||
, "sl.wikiquote.org"
|
||||
, "th.wikipedia.org"
|
||||
, "th.wiktionary.org"
|
||||
, "th.wikisource.org"
|
||||
, "th.wikibooks.org"
|
||||
, "th.wikiquote.org"
|
||||
, "th.wikinews.org"
|
||||
, "vo.wikipedia.org"
|
||||
, "vo.wiktionary.org"
|
||||
, "vo.wikibooks.org"
|
||||
, "vo.wikiquote.org"
|
||||
, "hi.wikipedia.org"
|
||||
, "hi.wiktionary.org"
|
||||
, "hi.wikibooks.org"
|
||||
, "hi.wikiquote.org"
|
||||
, "ia.wikipedia.org"
|
||||
, "ia.wiktionary.org"
|
||||
, "ia.wikibooks.org"
|
||||
, "la.wikipedia.org"
|
||||
, "la.wiktionary.org"
|
||||
, "la.wikisource.org"
|
||||
, "la.wikibooks.org"
|
||||
, "la.wikiquote.org"
|
||||
, "aa.wikipedia.org"
|
||||
, "aa.wiktionary.org"
|
||||
, "aa.wikibooks.org"
|
||||
, "ab.wikipedia.org"
|
||||
, "ab.wiktionary.org"
|
||||
, "ace.wikipedia.org"
|
||||
, "af.wikipedia.org"
|
||||
, "af.wiktionary.org"
|
||||
, "af.wikibooks.org"
|
||||
, "af.wikiquote.org"
|
||||
, "ak.wikipedia.org"
|
||||
, "ak.wiktionary.org"
|
||||
, "ak.wikibooks.org"
|
||||
, "als.wikipedia.org"
|
||||
, "als.wiktionary.org"
|
||||
, "als.wikibooks.org"
|
||||
, "als.wikiquote.org"
|
||||
, "am.wikipedia.org"
|
||||
, "am.wiktionary.org"
|
||||
, "am.wikiquote.org"
|
||||
, "an.wikipedia.org"
|
||||
, "an.wiktionary.org"
|
||||
, "ang.wikipedia.org"
|
||||
, "ang.wiktionary.org"
|
||||
, "ang.wikisource.org"
|
||||
, "ang.wikibooks.org"
|
||||
, "ang.wikiquote.org"
|
||||
, "arc.wikipedia.org"
|
||||
, "arz.wikipedia.org"
|
||||
, "as.wikipedia.org"
|
||||
, "as.wiktionary.org"
|
||||
, "as.wikisource.org"
|
||||
, "as.wikibooks.org"
|
||||
, "ast.wikipedia.org"
|
||||
, "ast.wiktionary.org"
|
||||
, "ast.wikibooks.org"
|
||||
, "ast.wikiquote.org"
|
||||
, "av.wikipedia.org"
|
||||
, "av.wiktionary.org"
|
||||
, "ay.wikipedia.org"
|
||||
, "ay.wiktionary.org"
|
||||
, "ay.wikibooks.org"
|
||||
, "az.wikipedia.org"
|
||||
, "az.wiktionary.org"
|
||||
, "az.wikisource.org"
|
||||
, "az.wikibooks.org"
|
||||
, "az.wikiquote.org"
|
||||
, "ba.wikipedia.org"
|
||||
, "ba.wikibooks.org"
|
||||
, "bar.wikipedia.org"
|
||||
, "bat-smg.wikipedia.org"
|
||||
, "bcl.wikipedia.org"
|
||||
, "be.wikipedia.org"
|
||||
, "be.wiktionary.org"
|
||||
, "be.wikisource.org"
|
||||
, "be.wikibooks.org"
|
||||
, "be.wikiquote.org"
|
||||
, "be.wikimedia.org"
|
||||
, "be-x-old.wikipedia.org"
|
||||
, "bh.wikipedia.org"
|
||||
, "bh.wiktionary.org"
|
||||
, "bi.wikipedia.org"
|
||||
, "bi.wiktionary.org"
|
||||
, "bi.wikibooks.org"
|
||||
, "bjn.wikipedia.org"
|
||||
, "bm.wikipedia.org"
|
||||
, "bm.wiktionary.org"
|
||||
, "bm.wikibooks.org"
|
||||
, "bm.wikiquote.org"
|
||||
, "bn.wikipedia.org"
|
||||
, "bn.wiktionary.org"
|
||||
, "bn.wikisource.org"
|
||||
, "bn.wikibooks.org"
|
||||
, "bo.wikipedia.org"
|
||||
, "bo.wiktionary.org"
|
||||
, "bo.wikibooks.org"
|
||||
, "bpy.wikipedia.org"
|
||||
, "br.wikipedia.org"
|
||||
, "br.wiktionary.org"
|
||||
, "br.wikisource.org"
|
||||
, "br.wikiquote.org"
|
||||
, "br.wikimedia.org"
|
||||
, "bs.wikipedia.org"
|
||||
, "bs.wiktionary.org"
|
||||
, "bs.wikisource.org"
|
||||
, "bs.wikibooks.org"
|
||||
, "bs.wikiquote.org"
|
||||
, "bs.wikinews.org"
|
||||
, "bug.wikipedia.org"
|
||||
, "bxr.wikipedia.org"
|
||||
, "cbk-zam.wikipedia.org"
|
||||
, "cdo.wikipedia.org"
|
||||
, "ce.wikipedia.org"
|
||||
, "ceb.wikipedia.org"
|
||||
, "ch.wikipedia.org"
|
||||
, "ch.wiktionary.org"
|
||||
, "ch.wikibooks.org"
|
||||
, "cho.wikipedia.org"
|
||||
, "chr.wikipedia.org"
|
||||
, "chr.wiktionary.org"
|
||||
, "chy.wikipedia.org"
|
||||
, "ckb.wikipedia.org"
|
||||
, "co.wikipedia.org"
|
||||
, "co.wiktionary.org"
|
||||
, "co.wikibooks.org"
|
||||
, "co.wikiquote.org"
|
||||
, "co.wikimedia.org"
|
||||
, "cr.wikipedia.org"
|
||||
, "cr.wiktionary.org"
|
||||
, "cr.wikiquote.org"
|
||||
, "crh.wikipedia.org"
|
||||
, "csb.wikipedia.org"
|
||||
, "csb.wiktionary.org"
|
||||
, "cu.wikipedia.org"
|
||||
, "cv.wikipedia.org"
|
||||
, "cv.wikibooks.org"
|
||||
, "cy.wikipedia.org"
|
||||
, "cy.wiktionary.org"
|
||||
, "cy.wikisource.org"
|
||||
, "cy.wikibooks.org"
|
||||
, "cy.wikiquote.org"
|
||||
, "diq.wikipedia.org"
|
||||
, "dsb.wikipedia.org"
|
||||
, "dv.wikipedia.org"
|
||||
, "dv.wiktionary.org"
|
||||
, "dz.wikipedia.org"
|
||||
, "dz.wiktionary.org"
|
||||
, "ee.wikipedia.org"
|
||||
, "eml.wikipedia.org"
|
||||
, "ext.wikipedia.org"
|
||||
, "ff.wikipedia.org"
|
||||
, "fiu-vro.wikipedia.org"
|
||||
, "fj.wikipedia.org"
|
||||
, "fj.wiktionary.org"
|
||||
, "fo.wikipedia.org"
|
||||
, "fo.wiktionary.org"
|
||||
, "fo.wikisource.org"
|
||||
, "frp.wikipedia.org"
|
||||
, "frr.wikipedia.org"
|
||||
, "fur.wikipedia.org"
|
||||
, "fy.wikipedia.org"
|
||||
, "fy.wiktionary.org"
|
||||
, "fy.wikibooks.org"
|
||||
, "ga.wikipedia.org"
|
||||
, "ga.wiktionary.org"
|
||||
, "ga.wikibooks.org"
|
||||
, "ga.wikiquote.org"
|
||||
, "gag.wikipedia.org"
|
||||
, "gan.wikipedia.org"
|
||||
, "gd.wikipedia.org"
|
||||
, "gd.wiktionary.org"
|
||||
, "glk.wikipedia.org"
|
||||
, "gn.wikipedia.org"
|
||||
, "gn.wiktionary.org"
|
||||
, "gn.wikibooks.org"
|
||||
, "got.wikipedia.org"
|
||||
, "got.wikibooks.org"
|
||||
, "gu.wikipedia.org"
|
||||
, "gu.wiktionary.org"
|
||||
, "gu.wikisource.org"
|
||||
, "gu.wikibooks.org"
|
||||
, "gu.wikiquote.org"
|
||||
, "gv.wikipedia.org"
|
||||
, "gv.wiktionary.org"
|
||||
, "ha.wikipedia.org"
|
||||
, "ha.wiktionary.org"
|
||||
, "hak.wikipedia.org"
|
||||
, "haw.wikipedia.org"
|
||||
, "hif.wikipedia.org"
|
||||
, "ho.wikipedia.org"
|
||||
, "hsb.wikipedia.org"
|
||||
, "hsb.wiktionary.org"
|
||||
, "ht.wikipedia.org"
|
||||
, "ht.wikisource.org"
|
||||
, "hy.wikipedia.org"
|
||||
, "hy.wiktionary.org"
|
||||
, "hy.wikisource.org"
|
||||
, "hy.wikibooks.org"
|
||||
, "hy.wikiquote.org"
|
||||
, "hz.wikipedia.org"
|
||||
, "ie.wikipedia.org"
|
||||
, "ie.wiktionary.org"
|
||||
, "ie.wikibooks.org"
|
||||
, "ig.wikipedia.org"
|
||||
, "ii.wikipedia.org"
|
||||
, "ik.wikipedia.org"
|
||||
, "ik.wiktionary.org"
|
||||
, "ilo.wikipedia.org"
|
||||
, "io.wikipedia.org"
|
||||
, "io.wiktionary.org"
|
||||
, "is.wikipedia.org"
|
||||
, "is.wiktionary.org"
|
||||
, "is.wikisource.org"
|
||||
, "is.wikibooks.org"
|
||||
, "is.wikiquote.org"
|
||||
, "iu.wikipedia.org"
|
||||
, "iu.wiktionary.org"
|
||||
, "jbo.wikipedia.org"
|
||||
, "jbo.wiktionary.org"
|
||||
, "jv.wikipedia.org"
|
||||
, "jv.wiktionary.org"
|
||||
, "ka.wikipedia.org"
|
||||
, "ka.wiktionary.org"
|
||||
, "ka.wikibooks.org"
|
||||
, "ka.wikiquote.org"
|
||||
, "kaa.wikipedia.org"
|
||||
, "kab.wikipedia.org"
|
||||
, "kbd.wikipedia.org"
|
||||
, "kg.wikipedia.org"
|
||||
, "ki.wikipedia.org"
|
||||
, "kj.wikipedia.org"
|
||||
, "kl.wikipedia.org"
|
||||
, "kl.wiktionary.org"
|
||||
, "km.wikipedia.org"
|
||||
, "km.wiktionary.org"
|
||||
, "km.wikibooks.org"
|
||||
, "kn.wikipedia.org"
|
||||
, "kn.wiktionary.org"
|
||||
, "kn.wikisource.org"
|
||||
, "kn.wikibooks.org"
|
||||
, "kn.wikiquote.org"
|
||||
, "koi.wikipedia.org"
|
||||
, "kr.wikipedia.org"
|
||||
, "kr.wikiquote.org"
|
||||
, "krc.wikipedia.org"
|
||||
, "ks.wikipedia.org"
|
||||
, "ks.wiktionary.org"
|
||||
, "ks.wikibooks.org"
|
||||
, "ks.wikiquote.org"
|
||||
, "ksh.wikipedia.org"
|
||||
, "ku.wikipedia.org"
|
||||
, "ku.wiktionary.org"
|
||||
, "ku.wikibooks.org"
|
||||
, "ku.wikiquote.org"
|
||||
, "kv.wikipedia.org"
|
||||
, "kw.wikipedia.org"
|
||||
, "kw.wiktionary.org"
|
||||
, "kw.wikiquote.org"
|
||||
, "ky.wikipedia.org"
|
||||
, "ky.wiktionary.org"
|
||||
, "ky.wikibooks.org"
|
||||
, "ky.wikiquote.org"
|
||||
, "lad.wikipedia.org"
|
||||
, "lb.wikipedia.org"
|
||||
, "lb.wiktionary.org"
|
||||
, "lb.wikibooks.org"
|
||||
, "lb.wikiquote.org"
|
||||
, "lbe.wikipedia.org"
|
||||
, "lez.wikipedia.org"
|
||||
, "lg.wikipedia.org"
|
||||
, "li.wikipedia.org"
|
||||
, "li.wiktionary.org"
|
||||
, "li.wikisource.org"
|
||||
, "li.wikibooks.org"
|
||||
, "li.wikiquote.org"
|
||||
, "lij.wikipedia.org"
|
||||
, "lmo.wikipedia.org"
|
||||
, "ln.wikipedia.org"
|
||||
, "ln.wiktionary.org"
|
||||
, "ln.wikibooks.org"
|
||||
, "lo.wikipedia.org"
|
||||
, "lo.wiktionary.org"
|
||||
, "ltg.wikipedia.org"
|
||||
, "lv.wikipedia.org"
|
||||
, "lv.wiktionary.org"
|
||||
, "lv.wikibooks.org"
|
||||
, "mai.wikipedia.org"
|
||||
, "map-bms.wikipedia.org"
|
||||
, "mdf.wikipedia.org"
|
||||
, "mg.wikipedia.org"
|
||||
, "mg.wiktionary.org"
|
||||
, "mg.wikibooks.org"
|
||||
, "mh.wikipedia.org"
|
||||
, "mh.wiktionary.org"
|
||||
, "mhr.wikipedia.org"
|
||||
, "mi.wikipedia.org"
|
||||
, "mi.wiktionary.org"
|
||||
, "mi.wikibooks.org"
|
||||
, "min.wikipedia.org"
|
||||
, "mk.wikipedia.org"
|
||||
, "mk.wiktionary.org"
|
||||
, "mk.wikisource.org"
|
||||
, "mk.wikibooks.org"
|
||||
, "mk.wikimedia.org"
|
||||
, "ml.wikipedia.org"
|
||||
, "ml.wiktionary.org"
|
||||
, "ml.wikisource.org"
|
||||
, "ml.wikibooks.org"
|
||||
, "ml.wikiquote.org"
|
||||
, "mn.wikipedia.org"
|
||||
, "mn.wiktionary.org"
|
||||
, "mn.wikibooks.org"
|
||||
, "mo.wikipedia.org"
|
||||
, "mo.wiktionary.org"
|
||||
, "mr.wikipedia.org"
|
||||
, "mr.wiktionary.org"
|
||||
, "mr.wikisource.org"
|
||||
, "mr.wikibooks.org"
|
||||
, "mr.wikiquote.org"
|
||||
, "mrj.wikipedia.org"
|
||||
, "mt.wikipedia.org"
|
||||
, "mt.wiktionary.org"
|
||||
, "mus.wikipedia.org"
|
||||
, "mwl.wikipedia.org"
|
||||
, "my.wikipedia.org"
|
||||
, "my.wiktionary.org"
|
||||
, "my.wikibooks.org"
|
||||
, "myv.wikipedia.org"
|
||||
, "mzn.wikipedia.org"
|
||||
, "na.wikipedia.org"
|
||||
, "na.wiktionary.org"
|
||||
, "na.wikibooks.org"
|
||||
, "na.wikiquote.org"
|
||||
, "nah.wikipedia.org"
|
||||
, "nah.wiktionary.org"
|
||||
, "nah.wikibooks.org"
|
||||
, "nap.wikipedia.org"
|
||||
, "nds.wikipedia.org"
|
||||
, "nds.wiktionary.org"
|
||||
, "nds.wikibooks.org"
|
||||
, "nds.wikiquote.org"
|
||||
, "nds-nl.wikipedia.org"
|
||||
, "ne.wikipedia.org"
|
||||
, "ne.wiktionary.org"
|
||||
, "ne.wikibooks.org"
|
||||
, "new.wikipedia.org"
|
||||
, "ng.wikipedia.org"
|
||||
, "nov.wikipedia.org"
|
||||
, "nrm.wikipedia.org"
|
||||
, "nso.wikipedia.org"
|
||||
, "nv.wikipedia.org"
|
||||
, "ny.wikipedia.org"
|
||||
, "oc.wikipedia.org"
|
||||
, "oc.wiktionary.org"
|
||||
, "oc.wikibooks.org"
|
||||
, "om.wikipedia.org"
|
||||
, "om.wiktionary.org"
|
||||
, "or.wikipedia.org"
|
||||
, "or.wiktionary.org"
|
||||
, "or.wikisource.org"
|
||||
, "os.wikipedia.org"
|
||||
, "pa.wikipedia.org"
|
||||
, "pa.wiktionary.org"
|
||||
, "pa.wikibooks.org"
|
||||
, "pag.wikipedia.org"
|
||||
, "pam.wikipedia.org"
|
||||
, "pap.wikipedia.org"
|
||||
, "pcd.wikipedia.org"
|
||||
, "pdc.wikipedia.org"
|
||||
, "pfl.wikipedia.org"
|
||||
, "pi.wikipedia.org"
|
||||
, "pi.wiktionary.org"
|
||||
, "pih.wikipedia.org"
|
||||
, "pms.wikipedia.org"
|
||||
, "pnb.wikipedia.org"
|
||||
, "pnb.wiktionary.org"
|
||||
, "pnt.wikipedia.org"
|
||||
, "ps.wikipedia.org"
|
||||
, "ps.wiktionary.org"
|
||||
, "ps.wikibooks.org"
|
||||
, "qu.wikipedia.org"
|
||||
, "qu.wiktionary.org"
|
||||
, "qu.wikibooks.org"
|
||||
, "qu.wikiquote.org"
|
||||
, "rm.wikipedia.org"
|
||||
, "rm.wiktionary.org"
|
||||
, "rm.wikibooks.org"
|
||||
, "rmy.wikipedia.org"
|
||||
, "rn.wikipedia.org"
|
||||
, "rn.wiktionary.org"
|
||||
, "roa-rup.wikipedia.org"
|
||||
, "roa-rup.wiktionary.org"
|
||||
, "roa-tara.wikipedia.org"
|
||||
, "rue.wikipedia.org"
|
||||
, "rw.wikipedia.org"
|
||||
, "rw.wiktionary.org"
|
||||
, "sa.wikipedia.org"
|
||||
, "sa.wiktionary.org"
|
||||
, "sa.wikisource.org"
|
||||
, "sa.wikibooks.org"
|
||||
, "sa.wikiquote.org"
|
||||
, "sah.wikipedia.org"
|
||||
, "sah.wikisource.org"
|
||||
, "sc.wikipedia.org"
|
||||
, "sc.wiktionary.org"
|
||||
, "scn.wikipedia.org"
|
||||
, "scn.wiktionary.org"
|
||||
, "sco.wikipedia.org"
|
||||
, "sd.wikipedia.org"
|
||||
, "sd.wiktionary.org"
|
||||
, "sd.wikinews.org"
|
||||
, "se.wikipedia.org"
|
||||
, "se.wikibooks.org"
|
||||
, "se.wikimedia.org"
|
||||
, "sg.wikipedia.org"
|
||||
, "sg.wiktionary.org"
|
||||
, "si.wikipedia.org"
|
||||
, "si.wiktionary.org"
|
||||
, "si.wikibooks.org"
|
||||
, "sm.wikipedia.org"
|
||||
, "sm.wiktionary.org"
|
||||
, "sn.wikipedia.org"
|
||||
, "sn.wiktionary.org"
|
||||
, "so.wikipedia.org"
|
||||
, "so.wiktionary.org"
|
||||
, "sq.wikipedia.org"
|
||||
, "sq.wiktionary.org"
|
||||
, "sq.wikibooks.org"
|
||||
, "sq.wikiquote.org"
|
||||
, "sq.wikinews.org"
|
||||
, "srn.wikipedia.org"
|
||||
, "ss.wikipedia.org"
|
||||
, "ss.wiktionary.org"
|
||||
, "st.wikipedia.org"
|
||||
, "st.wiktionary.org"
|
||||
, "stq.wikipedia.org"
|
||||
, "su.wikipedia.org"
|
||||
, "su.wiktionary.org"
|
||||
, "su.wikibooks.org"
|
||||
, "su.wikiquote.org"
|
||||
, "sw.wikipedia.org"
|
||||
, "sw.wiktionary.org"
|
||||
, "sw.wikibooks.org"
|
||||
, "szl.wikipedia.org"
|
||||
, "ta.wikipedia.org"
|
||||
, "ta.wiktionary.org"
|
||||
, "ta.wikisource.org"
|
||||
, "ta.wikibooks.org"
|
||||
, "ta.wikiquote.org"
|
||||
, "ta.wikinews.org"
|
||||
, "te.wikipedia.org"
|
||||
, "te.wiktionary.org"
|
||||
, "te.wikisource.org"
|
||||
, "te.wikibooks.org"
|
||||
, "te.wikiquote.org"
|
||||
, "tet.wikipedia.org"
|
||||
, "tg.wikipedia.org"
|
||||
, "tg.wiktionary.org"
|
||||
, "tg.wikibooks.org"
|
||||
, "ti.wikipedia.org"
|
||||
, "ti.wiktionary.org"
|
||||
, "tk.wikipedia.org"
|
||||
, "tk.wiktionary.org"
|
||||
, "tk.wikibooks.org"
|
||||
, "tk.wikiquote.org"
|
||||
, "tl.wikipedia.org"
|
||||
, "tl.wiktionary.org"
|
||||
, "tl.wikibooks.org"
|
||||
, "tn.wikipedia.org"
|
||||
, "tn.wiktionary.org"
|
||||
, "to.wikipedia.org"
|
||||
, "to.wiktionary.org"
|
||||
, "tpi.wikipedia.org"
|
||||
, "tpi.wiktionary.org"
|
||||
, "ts.wikipedia.org"
|
||||
, "ts.wiktionary.org"
|
||||
, "tt.wikipedia.org"
|
||||
, "tt.wiktionary.org"
|
||||
, "tt.wikibooks.org"
|
||||
, "tt.wikiquote.org"
|
||||
, "tum.wikipedia.org"
|
||||
, "tw.wikipedia.org"
|
||||
, "tw.wiktionary.org"
|
||||
, "ty.wikipedia.org"
|
||||
, "tyv.wikipedia.org"
|
||||
, "udm.wikipedia.org"
|
||||
, "ug.wikipedia.org"
|
||||
, "ug.wiktionary.org"
|
||||
, "ug.wikibooks.org"
|
||||
, "ug.wikiquote.org"
|
||||
, "ur.wikipedia.org"
|
||||
, "ur.wiktionary.org"
|
||||
, "ur.wikibooks.org"
|
||||
, "ur.wikiquote.org"
|
||||
, "uz.wikipedia.org"
|
||||
, "uz.wiktionary.org"
|
||||
, "uz.wikibooks.org"
|
||||
, "uz.wikiquote.org"
|
||||
, "ve.wikipedia.org"
|
||||
, "vec.wikipedia.org"
|
||||
, "vec.wiktionary.org"
|
||||
, "vec.wikisource.org"
|
||||
, "vep.wikipedia.org"
|
||||
, "vls.wikipedia.org"
|
||||
, "wa.wikipedia.org"
|
||||
, "wa.wiktionary.org"
|
||||
, "wa.wikibooks.org"
|
||||
, "war.wikipedia.org"
|
||||
, "wo.wikipedia.org"
|
||||
, "wo.wiktionary.org"
|
||||
, "wo.wikiquote.org"
|
||||
, "wuu.wikipedia.org"
|
||||
, "xal.wikipedia.org"
|
||||
, "xh.wikipedia.org"
|
||||
, "xh.wiktionary.org"
|
||||
, "xh.wikibooks.org"
|
||||
, "xmf.wikipedia.org"
|
||||
, "yi.wikipedia.org"
|
||||
, "yi.wiktionary.org"
|
||||
, "yi.wikisource.org"
|
||||
, "yo.wikipedia.org"
|
||||
, "yo.wiktionary.org"
|
||||
, "yo.wikibooks.org"
|
||||
, "za.wikipedia.org"
|
||||
, "za.wiktionary.org"
|
||||
, "za.wikibooks.org"
|
||||
, "za.wikiquote.org"
|
||||
, "zea.wikipedia.org"
|
||||
, "zh-classical.wikipedia.org"
|
||||
, "zh-min-nan.wikipedia.org"
|
||||
, "zh-min-nan.wiktionary.org"
|
||||
, "zh-min-nan.wikisource.org"
|
||||
, "zh-min-nan.wikibooks.org"
|
||||
, "zh-min-nan.wikiquote.org"
|
||||
, "zh-yue.wikipedia.org"
|
||||
, "zu.wikipedia.org"
|
||||
, "zu.wiktionary.org"
|
||||
, "zu.wikibooks.org"
|
||||
, "gom.wikipedia.org"
|
||||
, "lrc.wikipedia.org"
|
||||
, "azb.wikipedia.org"
|
||||
, "ady.wikipedia.org"
|
||||
, "jam.wikipedia.org"
|
||||
, "tcy.wikipedia.org"
|
||||
, "olo.wikipedia.org"
|
||||
};
|
||||
//, "als.wikisource.org"
|
||||
//, "als.wikinews.org"
|
||||
//, "nds.wikinews.org"
|
||||
//, "ba.wiktionary.org"
|
||||
//, "tokipona.wikibooks.org"
|
||||
//, "ve.wikimedia.org" // NOTE: moved:DATE:2015-04-06
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xow_domain_tid {
|
||||
public Xow_domain_tid(boolean multi_lang, int src, int tid, byte[] key_bry, byte[] abrv, byte[] domain_bry) {
|
||||
this.multi_lang = multi_lang; this.src = src; this.tid = tid; this.key_bry = key_bry; this.abrv = abrv; this.domain_bry = domain_bry;
|
||||
this.key_str = String_.new_u8(key_bry);
|
||||
}
|
||||
public boolean Multi_lang() {return multi_lang;} private final boolean multi_lang; // EX: y
|
||||
public int Src() {return src;} private final int src; // EX: 1 (wm,mw,wk,xo)
|
||||
public int Tid() {return tid;} private final int tid; // EX: 1 (Tid_wikipedia)
|
||||
public String Key_str() {return key_str;} private final String key_str; // EX: wikipedia
|
||||
public byte[] Key_bry() {return key_bry;} private final byte[] key_bry; // EX: wikipedia
|
||||
public byte[] Abrv() {return abrv;} private final byte[] abrv; // EX: w
|
||||
public byte[] Domain_bry() {return domain_bry;} private byte[] domain_bry; // EX: .wikipedia.org
|
||||
public byte[] Display_bry() {return Bry_.Ucase__1st(key_bry);} // EX: Wikipedia
|
||||
|
||||
public static final int
|
||||
Src__wmf = 1 // administered by wmf; wikipedia, etc.
|
||||
, Src__wikia = 2 // *.wikia.com
|
||||
, Src__mw = 3 // mediawiki installations not part of wmf, wikia
|
||||
, Src__xowa = 4 // xowa
|
||||
;
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xow_domain_tid_ {
|
||||
public static final int
|
||||
Tid__null = 0
|
||||
, Tid__wikipedia = 1
|
||||
, Tid__wiktionary = 2
|
||||
, Tid__wikisource = 3
|
||||
, Tid__wikivoyage = 4
|
||||
, Tid__wikiquote = 5
|
||||
, Tid__wikibooks = 6
|
||||
, Tid__wikiversity = 7
|
||||
, Tid__wikinews = 8
|
||||
, Tid__wikimedia = 9
|
||||
, Tid__species = 10
|
||||
, Tid__commons = 11
|
||||
, Tid__wikidata = 12
|
||||
, Tid__mediawiki = 13
|
||||
, Tid__meta = 14
|
||||
, Tid__incubator = 15
|
||||
, Tid__wmfblog = 16
|
||||
, Tid__home = 17
|
||||
, Tid__other = 18
|
||||
, Tid___len = 19
|
||||
;
|
||||
public static final String // SERIALIZED:xowa.gfs
|
||||
Str__wikipedia = "wikipedia"
|
||||
, Str__wiktionary = "wiktionary"
|
||||
, Str__wikisource = "wikisource"
|
||||
, Str__wikivoyage = "wikivoyage"
|
||||
, Str__wikiquote = "wikiquote"
|
||||
, Str__wikibooks = "wikibooks"
|
||||
, Str__wikiversity = "wikiversity"
|
||||
, Str__wikinews = "wikinews"
|
||||
, Str__wikimedia = "wikimedia"
|
||||
, Str__species = "species"
|
||||
, Str__commons = "commons"
|
||||
, Str__wikidata = "wikidata"
|
||||
, Str__mediawiki = "mediawiki"
|
||||
, Str__meta = "meta"
|
||||
, Str__incubator = "incubator"
|
||||
, Str__wmforg = "wikimediafoundation"
|
||||
, Str__home = "home"
|
||||
, Str__other = "other"
|
||||
;
|
||||
public static final byte[]
|
||||
Bry__wikipedia = Bry_.new_a7(Str__wikipedia)
|
||||
, Bry__wiktionary = Bry_.new_a7(Str__wiktionary)
|
||||
, Bry__wikisource = Bry_.new_a7(Str__wikisource)
|
||||
, Bry__wikivoyage = Bry_.new_a7(Str__wikivoyage)
|
||||
, Bry__wikiquote = Bry_.new_a7(Str__wikiquote)
|
||||
, Bry__wikibooks = Bry_.new_a7(Str__wikibooks)
|
||||
, Bry__wikiversity = Bry_.new_a7(Str__wikiversity)
|
||||
, Bry__wikinews = Bry_.new_a7(Str__wikinews)
|
||||
, Bry__wikimedia = Bry_.new_a7(Str__wikimedia)
|
||||
, Bry__species = Bry_.new_a7(Str__species)
|
||||
, Bry__commons = Bry_.new_a7(Str__commons)
|
||||
, Bry__wikidata = Bry_.new_a7(Str__wikidata)
|
||||
, Bry__mediawiki = Bry_.new_a7(Str__mediawiki)
|
||||
, Bry__meta = Bry_.new_a7(Str__meta)
|
||||
, Bry__incubator = Bry_.new_a7(Str__incubator)
|
||||
, Bry__wmforg = Bry_.new_a7(Str__wmforg)
|
||||
, Bry__home = Bry_.new_a7(Str__home)
|
||||
, Bry__other = Bry_.new_a7(Str__other)
|
||||
;
|
||||
private static final Xow_domain_tid[] ary = new Xow_domain_tid[Tid___len];
|
||||
private static final Hash_adp_bry type_regy = Hash_adp_bry.ci_a7(); // LOC:must go before new_()
|
||||
private static final Hash_adp_bry abrv_regy = Hash_adp_bry.cs(); // LOC:must go before new_()
|
||||
public static final Xow_domain_tid
|
||||
Itm__wikipedia = new_(Bool_.Y , Xow_domain_tid.Src__wmf , Tid__wikipedia , Bry__wikipedia , "w" , ".wikipedia.org")
|
||||
, Itm__wiktionary = new_(Bool_.Y , Xow_domain_tid.Src__wmf , Tid__wiktionary , Bry__wiktionary , "d" , ".wiktionary.org")
|
||||
, Itm__wikisource = new_(Bool_.Y , Xow_domain_tid.Src__wmf , Tid__wikisource , Bry__wikisource , "s" , ".wikisource.org")
|
||||
, Itm__wikivoyage = new_(Bool_.Y , Xow_domain_tid.Src__wmf , Tid__wikivoyage , Bry__wikivoyage , "v" , ".wikivoyage.org")
|
||||
, Itm__wikiquote = new_(Bool_.Y , Xow_domain_tid.Src__wmf , Tid__wikiquote , Bry__wikiquote , "q" , ".wikiquote.org")
|
||||
, Itm__wikibooks = new_(Bool_.Y , Xow_domain_tid.Src__wmf , Tid__wikibooks , Bry__wikibooks , "b" , ".wikibooks.org")
|
||||
, Itm__wikiversity = new_(Bool_.Y , Xow_domain_tid.Src__wmf , Tid__wikiversity , Bry__wikiversity , "u" , ".wikiversity.org")
|
||||
, Itm__wikinews = new_(Bool_.Y , Xow_domain_tid.Src__wmf , Tid__wikinews , Bry__wikinews , "n" , ".wikinews.org")
|
||||
, Itm__wikimedia = new_(Bool_.Y , Xow_domain_tid.Src__wmf , Tid__wikimedia , Bry__wikimedia , "m" , ".wikimedia.org")
|
||||
, Itm__species = new_(Bool_.N , Xow_domain_tid.Src__wmf , Tid__species , Bry__species , "species" , Xow_domain_itm_.Str__species)
|
||||
, Itm__commons = new_(Bool_.N , Xow_domain_tid.Src__wmf , Tid__commons , Bry__commons , "c" , Xow_domain_itm_.Str__commons)
|
||||
, Itm__wikidata = new_(Bool_.N , Xow_domain_tid.Src__wmf , Tid__wikidata , Bry__wikidata , "wd" , Xow_domain_itm_.Str__wikidata)
|
||||
, Itm__mediawiki = new_(Bool_.N , Xow_domain_tid.Src__wmf , Tid__mediawiki , Bry__mediawiki , "mw" , Xow_domain_itm_.Str__mediawiki)
|
||||
, Itm__meta = new_(Bool_.N , Xow_domain_tid.Src__wmf , Tid__meta , Bry__meta , "meta" , Xow_domain_itm_.Str__meta)
|
||||
, Itm__incubator = new_(Bool_.N , Xow_domain_tid.Src__wmf , Tid__incubator , Bry__incubator , "qb" , Xow_domain_itm_.Str__incubator)
|
||||
, Itm__wmforg = new_(Bool_.N , Xow_domain_tid.Src__wmf , Tid__wmfblog , Bry__wmforg , "wmf" , Xow_domain_itm_.Str__wmforg)
|
||||
, Itm__home = new_(Bool_.N , Xow_domain_tid.Src__xowa, Tid__home , Bry__home , "home" , Xow_domain_itm_.Str__home)
|
||||
, Itm__other = new_(Bool_.N , Xow_domain_tid.Src__mw , Tid__other , Bry__other , "" , "")
|
||||
;
|
||||
private static Xow_domain_tid new_(boolean multi_lang, int src, int tid, byte[] key_bry, String abrv_xo_str, String domain_bry) {
|
||||
byte[] abrv_xo_bry = Bry_.new_u8(abrv_xo_str);
|
||||
Xow_domain_tid rv = new Xow_domain_tid(multi_lang, src, tid, key_bry, abrv_xo_bry, Bry_.new_u8(domain_bry));
|
||||
ary[tid] = rv;
|
||||
type_regy.Add(key_bry, rv);
|
||||
abrv_regy.Add(abrv_xo_bry, rv);
|
||||
return rv;
|
||||
}
|
||||
public static Xow_domain_tid Get_abrv_as_itm(byte[] src, int bgn, int end) {return (Xow_domain_tid)abrv_regy.Get_by_mid(src, bgn, end);}
|
||||
public static Xow_domain_tid Get_type_as_itm(int tid) {return ary[tid];}
|
||||
public static byte[] Get_type_as_bry(int tid) {return ary[tid].Key_bry();}
|
||||
public static int Get_type_as_tid(byte[] src) {return Get_type_as_tid(src, 0, src.length);}
|
||||
public static int Get_type_as_tid(byte[] src, int bgn, int end) {
|
||||
Object o = type_regy.Get_by_mid(src, bgn, end);
|
||||
return o == null ? Xow_domain_tid_.Tid__null : ((Xow_domain_tid)o).Tid();
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xow_domain_uid_ {
|
||||
public static final int
|
||||
Tid_null = 0
|
||||
, Tid_xowa = 1
|
||||
, Tid_commons = 2
|
||||
, Tid_wikidata = 3
|
||||
, Tid_mediawiki = 20
|
||||
, Tid_meta = 21
|
||||
, Tid_incubator = 22
|
||||
, Tid_wmfblog = 23
|
||||
, Tid_species = 24
|
||||
;
|
||||
private static final int
|
||||
Tid_sub_wikipedia = 0
|
||||
, Tid_sub_wiktionary = 1
|
||||
, Tid_sub_wikisource = 2
|
||||
, Tid_sub_wikivoyage = 3
|
||||
, Tid_sub_wikiquote = 4
|
||||
, Tid_sub_wikibooks = 5
|
||||
, Tid_sub_wikiversity = 6
|
||||
, Tid_sub_wikinews = 7
|
||||
, Tid_sub_wikimedia = 8
|
||||
;
|
||||
private static final int Const_system_reserved = 100, Const_lang_reserved = 20;
|
||||
public static int To_int(Xow_domain_itm domain) {
|
||||
int domain_tid = 0;
|
||||
switch (domain.Domain_type_id()) {
|
||||
case Xow_domain_tid_.Tid__home: return Tid_xowa;
|
||||
case Xow_domain_tid_.Tid__commons: return Tid_commons;
|
||||
case Xow_domain_tid_.Tid__wikidata: return Tid_wikidata;
|
||||
case Xow_domain_tid_.Tid__mediawiki: return Tid_mediawiki;
|
||||
case Xow_domain_tid_.Tid__meta: return Tid_meta;
|
||||
case Xow_domain_tid_.Tid__incubator: return Tid_incubator;
|
||||
case Xow_domain_tid_.Tid__wmfblog: return Tid_wmfblog;
|
||||
case Xow_domain_tid_.Tid__species: return Tid_species;
|
||||
case Xow_domain_tid_.Tid__wikipedia: domain_tid = Tid_sub_wikipedia; break;
|
||||
case Xow_domain_tid_.Tid__wiktionary: domain_tid = Tid_sub_wiktionary; break;
|
||||
case Xow_domain_tid_.Tid__wikisource: domain_tid = Tid_sub_wikisource; break;
|
||||
case Xow_domain_tid_.Tid__wikivoyage: domain_tid = Tid_sub_wikivoyage; break;
|
||||
case Xow_domain_tid_.Tid__wikiquote: domain_tid = Tid_sub_wikiquote; break;
|
||||
case Xow_domain_tid_.Tid__wikibooks: domain_tid = Tid_sub_wikibooks; break;
|
||||
case Xow_domain_tid_.Tid__wikiversity: domain_tid = Tid_sub_wikiversity; break;
|
||||
case Xow_domain_tid_.Tid__wikinews: domain_tid = Tid_sub_wikinews; break;
|
||||
case Xow_domain_tid_.Tid__wikimedia: domain_tid = Tid_sub_wikimedia; break;
|
||||
default: throw Err_.new_unhandled(domain.Domain_type_id());
|
||||
}
|
||||
return Const_system_reserved // reserve first 100 slots
|
||||
+ domain_tid // domain_tid assigned above
|
||||
+ (domain.Lang_actl_uid() * Const_lang_reserved) // reserve 20 wikis per lang
|
||||
;
|
||||
}
|
||||
public static Xow_domain_itm To_domain(int tid) {
|
||||
switch (tid) {
|
||||
case Tid_xowa: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__home, Xow_domain_tid_.Tid__home, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_commons: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__commons, Xow_domain_tid_.Tid__commons, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_wikidata: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__wikidata, Xow_domain_tid_.Tid__commons, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_mediawiki: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__mediawiki, Xow_domain_tid_.Tid__mediawiki, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_meta: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__meta, Xow_domain_tid_.Tid__meta, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_incubator: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__incubator, Xow_domain_tid_.Tid__incubator, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_wmfblog: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__wmforg, Xow_domain_tid_.Tid__wmfblog, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_species: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__species, Xow_domain_tid_.Tid__species, Xol_lang_stub_.Key__unknown);
|
||||
}
|
||||
int tmp = tid - Const_system_reserved;
|
||||
int lang_id = tmp / 20;
|
||||
int type_id = tmp % 20;
|
||||
int tid_int = 0; byte[] tid_bry = null;
|
||||
switch (type_id) {
|
||||
case Tid_sub_wikipedia: tid_int = Xow_domain_tid_.Tid__wikipedia; tid_bry = Xow_domain_tid_.Bry__wikipedia; break;
|
||||
case Tid_sub_wiktionary: tid_int = Xow_domain_tid_.Tid__wiktionary; tid_bry = Xow_domain_tid_.Bry__wiktionary; break;
|
||||
case Tid_sub_wikisource: tid_int = Xow_domain_tid_.Tid__wikisource; tid_bry = Xow_domain_tid_.Bry__wikisource; break;
|
||||
case Tid_sub_wikivoyage: tid_int = Xow_domain_tid_.Tid__wikivoyage; tid_bry = Xow_domain_tid_.Bry__wikivoyage; break;
|
||||
case Tid_sub_wikiquote: tid_int = Xow_domain_tid_.Tid__wikiquote; tid_bry = Xow_domain_tid_.Bry__wikiquote; break;
|
||||
case Tid_sub_wikibooks: tid_int = Xow_domain_tid_.Tid__wikibooks; tid_bry = Xow_domain_tid_.Bry__wikibooks; break;
|
||||
case Tid_sub_wikiversity: tid_int = Xow_domain_tid_.Tid__wikiversity; tid_bry = Xow_domain_tid_.Bry__wikiversity; break;
|
||||
case Tid_sub_wikinews: tid_int = Xow_domain_tid_.Tid__wikinews; tid_bry = Xow_domain_tid_.Bry__wikinews; break;
|
||||
case Tid_sub_wikimedia: tid_int = Xow_domain_tid_.Tid__wikimedia; tid_bry = Xow_domain_tid_.Bry__wikimedia; break;
|
||||
default: throw Err_.new_unhandled(type_id);
|
||||
}
|
||||
Xol_lang_stub lang = Xol_lang_stub_.Get_by_id(lang_id);
|
||||
byte[] domain_bry = Bry_.Add(lang.Key(), Byte_ascii.Dot_bry, tid_bry, Byte_ascii.Dot_bry, Xow_domain_itm_.Seg__org);
|
||||
return Xow_domain_itm.new_(domain_bry, tid_int, lang, lang.Key());
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*;
|
||||
public class Xow_domain_uid__tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xow_domain_uid__fxt fxt = new Xow_domain_uid__fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test(Xow_domain_uid_.Tid_commons , "commons.wikimedia.org" , "", Xow_domain_tid_.Tid__commons);
|
||||
fxt.Test(100 , "en.wikipedia.org" , "en", Xow_domain_tid_.Tid__wikipedia);
|
||||
}
|
||||
}
|
||||
class Xow_domain_uid__fxt {
|
||||
public void Clear() {}
|
||||
public void Test(int tid, String domain_str, String expd_lang, int expd_tid) {
|
||||
byte[] domain_bry = Bry_.new_a7(domain_str);
|
||||
Xow_domain_itm actl_domain = Xow_domain_uid_.To_domain(tid);
|
||||
Tfds.Eq_bry(domain_bry , actl_domain.Domain_bry());
|
||||
Tfds.Eq_bry(Bry_.new_a7(expd_lang) , actl_domain.Lang_actl_key());
|
||||
Tfds.Eq(expd_tid , actl_domain.Domain_type_id());
|
||||
Tfds.Eq(tid, Xow_domain_uid_.To_int(actl_domain));
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains.crts; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
|
||||
import gplx.core.primitives.*;
|
||||
public interface Xow_domain_crt_itm {
|
||||
boolean Matches(Xow_domain_itm cur, Xow_domain_itm comp);
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains.crts; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
|
||||
class Xow_domain_crt_itm_ {
|
||||
public static final Xow_domain_crt_itm Null = null;
|
||||
}
|
||||
class Xow_domain_crt_itm__in implements Xow_domain_crt_itm {
|
||||
private final Xow_domain_crt_itm[] ary;
|
||||
public Xow_domain_crt_itm__in(Xow_domain_crt_itm[] ary) {this.ary = ary;}
|
||||
public boolean Matches(Xow_domain_itm cur, Xow_domain_itm comp) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xow_domain_crt_itm itm = ary[i];
|
||||
if (itm.Matches(cur, comp)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
class Xow_domain_crt_itm__any_standard implements Xow_domain_crt_itm {
|
||||
public boolean Matches(Xow_domain_itm cur, Xow_domain_itm comp) {
|
||||
switch (comp.Domain_type_id()) {
|
||||
case Xow_domain_tid_.Tid__wikipedia:
|
||||
case Xow_domain_tid_.Tid__wiktionary:
|
||||
case Xow_domain_tid_.Tid__wikisource:
|
||||
case Xow_domain_tid_.Tid__wikivoyage:
|
||||
case Xow_domain_tid_.Tid__wikiquote:
|
||||
case Xow_domain_tid_.Tid__wikibooks:
|
||||
case Xow_domain_tid_.Tid__wikiversity:
|
||||
case Xow_domain_tid_.Tid__wikinews: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public static final Xow_domain_crt_itm__any_standard Instance = new Xow_domain_crt_itm__any_standard(); Xow_domain_crt_itm__any_standard() {}
|
||||
}
|
||||
class Xow_domain_crt_itm__lang implements Xow_domain_crt_itm {
|
||||
private final byte[] lang_key;
|
||||
public Xow_domain_crt_itm__lang(byte[] lang_key) {this.lang_key = lang_key;}
|
||||
public boolean Matches(Xow_domain_itm cur, Xow_domain_itm comp) {return Bry_.Eq(comp.Lang_orig_key(), lang_key);}
|
||||
}
|
||||
class Xow_domain_crt_itm__type implements Xow_domain_crt_itm {
|
||||
private final int wiki_tid;
|
||||
public Xow_domain_crt_itm__type(int wiki_tid) {this.wiki_tid = wiki_tid;}
|
||||
public boolean Matches(Xow_domain_itm cur, Xow_domain_itm comp) {return comp.Domain_type_id() == wiki_tid;}
|
||||
}
|
||||
class Xow_domain_crt_itm__wiki implements Xow_domain_crt_itm {
|
||||
private final byte[] domain;
|
||||
public Xow_domain_crt_itm__wiki(byte[] domain) {this.domain = domain;}
|
||||
public boolean Matches(Xow_domain_itm cur, Xow_domain_itm comp) {return Bry_.Eq(comp.Domain_bry(), domain);}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains.crts; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
|
||||
class Xow_domain_crt_itm__any_wiki implements Xow_domain_crt_itm {
|
||||
public boolean Matches(Xow_domain_itm cur, Xow_domain_itm comp) {return true;}
|
||||
public static final Xow_domain_crt_itm__any_wiki Instance = new Xow_domain_crt_itm__any_wiki(); Xow_domain_crt_itm__any_wiki() {}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains.crts; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
|
||||
class Xow_domain_crt_itm__none implements Xow_domain_crt_itm {
|
||||
public boolean Matches(Xow_domain_itm cur, Xow_domain_itm comp) {return false;}
|
||||
public static final Xow_domain_crt_itm__none Instance = new Xow_domain_crt_itm__none(); Xow_domain_crt_itm__none() {}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains.crts; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
|
||||
class Xow_domain_crt_itm__same_lang implements Xow_domain_crt_itm {
|
||||
public boolean Matches(Xow_domain_itm cur, Xow_domain_itm comp) {return Bry_.Eq(cur.Lang_orig_key(), comp.Lang_orig_key());}
|
||||
public static final Xow_domain_crt_itm__same_lang Instance = new Xow_domain_crt_itm__same_lang(); Xow_domain_crt_itm__same_lang() {}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains.crts; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
|
||||
class Xow_domain_crt_itm__same_type implements Xow_domain_crt_itm {
|
||||
public boolean Matches(Xow_domain_itm cur, Xow_domain_itm comp) {return cur.Domain_type_id() == comp.Domain_type_id();}
|
||||
public static final Xow_domain_crt_itm__same_type Instance = new Xow_domain_crt_itm__same_type(); Xow_domain_crt_itm__same_type() {}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains.crts; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
|
||||
class Xow_domain_crt_itm__self implements Xow_domain_crt_itm {
|
||||
public boolean Matches(Xow_domain_itm cur, Xow_domain_itm comp) {return Bry_.Eq(cur.Domain_bry(), comp.Domain_bry());}
|
||||
public static final Xow_domain_crt_itm__self Instance = new Xow_domain_crt_itm__self(); Xow_domain_crt_itm__self() {}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains.crts; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.langs.*;
|
||||
class Xow_domain_crt_itm_parser {
|
||||
public Xow_domain_crt_kv_itm[] Parse_as_kv_itms_or_null(byte[] raw) {
|
||||
List_adp rv = Parse_as_obj_or_null(raw, Bool_.N);
|
||||
return rv == null ? null : (Xow_domain_crt_kv_itm[])rv.To_ary_and_clear(Xow_domain_crt_kv_itm.class);
|
||||
}
|
||||
public Xow_domain_crt_kv_ary[] Parse_as_kv_arys_or_null(byte[] raw) {
|
||||
List_adp rv = Parse_as_obj_or_null(raw, Bool_.Y);
|
||||
return rv == null ? null : (Xow_domain_crt_kv_ary[])rv.To_ary_and_clear(Xow_domain_crt_kv_ary.class);
|
||||
}
|
||||
public List_adp Parse_as_obj_or_null(byte[] raw, boolean is_ary) {
|
||||
List_adp rv = List_adp_.New();
|
||||
byte[][] line_ary = Bry_split_.Split_lines(raw);
|
||||
int line_len = line_ary.length;
|
||||
for (int i = 0; i < line_len; ++i) {
|
||||
byte[] line = line_ary[i];
|
||||
if (line.length == 0) continue; // ignore blank lines
|
||||
byte[][] word_ary = Bry_split_.Split(line, Byte_ascii.Pipe);
|
||||
int word_len = word_ary.length;
|
||||
if (word_len != 2) return null; // not A|B; exit now;
|
||||
Xow_domain_crt_itm key_itm = Xow_domain_crt_itm_parser.Instance.Parse_as_in(word_ary[0]);
|
||||
if (key_itm == Xow_domain_crt_itm_.Null) return null; // invalid key; exit;
|
||||
if (is_ary) {
|
||||
Xow_domain_crt_itm[] ary_itm = Xow_domain_crt_itm_parser.Instance.Parse_as_ary(word_ary[1]);
|
||||
if (ary_itm == null) return null;
|
||||
rv.Add(new Xow_domain_crt_kv_ary(key_itm, ary_itm));
|
||||
}
|
||||
else {
|
||||
Xow_domain_crt_itm val_itm = Xow_domain_crt_itm_parser.Instance.Parse_as_in(word_ary[1]);
|
||||
if (val_itm == Xow_domain_crt_itm_.Null) return null; // invalid val; exit;
|
||||
rv.Add(new Xow_domain_crt_kv_itm(key_itm, val_itm));
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public Xow_domain_crt_itm Parse_as_in(byte[] raw) {
|
||||
Xow_domain_crt_itm[] in_ary = Parse_as_ary(raw);
|
||||
return in_ary == null ? Xow_domain_crt_itm_.Null : new Xow_domain_crt_itm__in(in_ary);
|
||||
}
|
||||
public Xow_domain_crt_itm[] Parse_as_ary(byte[] raw) {
|
||||
byte[][] terms = Bry_split_.Split(raw, Byte_ascii.Comma, Bool_.Y);
|
||||
int len = terms.length;
|
||||
Xow_domain_crt_itm[] rv_ary = new Xow_domain_crt_itm[len];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xow_domain_crt_itm itm = Parse_itm(terms[i]);
|
||||
if (itm == Xow_domain_crt_itm_.Null) return null; // invalid val; exit;
|
||||
rv_ary[i] = itm;
|
||||
}
|
||||
return rv_ary;
|
||||
}
|
||||
public Xow_domain_crt_itm Parse_itm(byte[] raw) {
|
||||
Xow_domain_crt_itm rv = (Xow_domain_crt_itm)itm_hash.Get_by_bry(raw); if (rv != null) return rv; // singleton; EX: <self>, <same_type>, etc..
|
||||
int raw_len = raw.length;
|
||||
if (Bry_.Has_at_bgn(raw, Wild_lang)) { // EX: *.wikipedia
|
||||
int wiki_tid = Xow_domain_tid_.Get_type_as_tid(raw, Wild_lang.length, raw_len);
|
||||
return wiki_tid == Xow_domain_tid_.Tid__null ? Xow_domain_crt_itm_.Null : new Xow_domain_crt_itm__type(wiki_tid);
|
||||
}
|
||||
else if (Bry_.Has_at_end(raw, Wild_type)) { // EX: en.*
|
||||
Xol_lang_stub lang_itm = Xol_lang_stub_.Get_by_key_or_null(raw, 0, raw_len - Wild_type.length);
|
||||
return lang_itm == null ? Xow_domain_crt_itm_.Null : new Xow_domain_crt_itm__lang(lang_itm.Key());
|
||||
}
|
||||
else
|
||||
return new Xow_domain_crt_itm__wiki(raw); // EX: en.wikipedia.org
|
||||
}
|
||||
private static final Hash_adp_bry itm_hash = Hash_adp_bry.cs()
|
||||
.Add_str_obj("<self>" , Xow_domain_crt_itm__self.Instance)
|
||||
.Add_str_obj("<same_type>" , Xow_domain_crt_itm__same_type.Instance)
|
||||
.Add_str_obj("<same_lang>" , Xow_domain_crt_itm__same_lang.Instance)
|
||||
.Add_str_obj("<any>" , Xow_domain_crt_itm__any_wiki.Instance)
|
||||
;
|
||||
private static final byte[] Wild_lang = Bry_.new_a7("*."), Wild_type = Bry_.new_a7(".*");
|
||||
public static final Xow_domain_crt_itm_parser Instance = new Xow_domain_crt_itm_parser(); Xow_domain_crt_itm_parser() {}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains.crts; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
|
||||
public class Xow_domain_crt_kv_itm_mgr {
|
||||
private final List_adp list = List_adp_.New();
|
||||
public void Clear() {list.Clear();}
|
||||
@gplx.Internal protected void Add(Xow_domain_crt_kv_itm itm) {list.Add(itm);}
|
||||
public boolean Parse_as_itms(byte[] raw) {
|
||||
this.Clear();
|
||||
Xow_domain_crt_kv_itm[] ary = Xow_domain_crt_itm_parser.Instance.Parse_as_kv_itms_or_null(raw);
|
||||
if (ary == null) return false; // invalid parse; leave current value as is and exit;
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i)
|
||||
this.Add(ary[i]);
|
||||
return true;
|
||||
}
|
||||
public boolean Parse_as_arys(byte[] raw) {
|
||||
this.Clear();
|
||||
Xow_domain_crt_kv_ary[] ary = Xow_domain_crt_itm_parser.Instance.Parse_as_kv_arys_or_null(raw);
|
||||
if (ary == null) return false; // invalid parse; leave current value as is and exit;
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i)
|
||||
list.Add(ary[i]);
|
||||
return true;
|
||||
}
|
||||
public Xow_domain_crt_itm Find_itm(Xow_domain_itm cur, Xow_domain_itm comp) {
|
||||
int len = list.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xow_domain_crt_kv_itm kv = (Xow_domain_crt_kv_itm)list.Get_at(i);
|
||||
if (kv.Key().Matches(cur, comp)) return kv.Val();
|
||||
}
|
||||
return Xow_domain_crt_itm__none.Instance;
|
||||
}
|
||||
public Xow_domain_crt_itm[] Find_ary(Xow_domain_itm cur, Xow_domain_itm comp) {
|
||||
int len = list.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xow_domain_crt_kv_ary kv = (Xow_domain_crt_kv_ary)list.Get_at(i);
|
||||
if (kv.Key().Matches(cur, comp)) return kv.Val();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
class Xow_domain_crt_kv_itm {
|
||||
public Xow_domain_crt_kv_itm(Xow_domain_crt_itm key, Xow_domain_crt_itm val) {this.key = key; this.val = val;}
|
||||
public Xow_domain_crt_itm Key() {return key;} private final Xow_domain_crt_itm key;
|
||||
public Xow_domain_crt_itm Val() {return val;} private final Xow_domain_crt_itm val;
|
||||
}
|
||||
class Xow_domain_crt_kv_ary {
|
||||
public Xow_domain_crt_kv_ary(Xow_domain_crt_itm key, Xow_domain_crt_itm[] val) {this.key = key; this.val = val;}
|
||||
public Xow_domain_crt_itm Key() {return key;} private final Xow_domain_crt_itm key;
|
||||
public Xow_domain_crt_itm[] Val() {return val;} private final Xow_domain_crt_itm[] val;
|
||||
}
|
||||
Reference in New Issue
Block a user