mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.5.4.1
This commit is contained in:
12
400_xowa/src/gplx/cache/Gfo_cache_mgr_base.java
vendored
12
400_xowa/src/gplx/cache/Gfo_cache_mgr_base.java
vendored
@@ -17,11 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.cache; import gplx.*;
|
||||
public class Gfo_cache_mgr_base {
|
||||
private OrderedHash hash = OrderedHash_.new_bry_();
|
||||
private Ordered_hash hash = Ordered_hash_.new_bry_();
|
||||
public int Compress_max() {return compress_max;} public void Compress_max_(int v) {compress_max = v;} private int compress_max = 16;
|
||||
public int Compress_to() {return compress_to;} public void Compress_to_(int v) {compress_to = v;} private int compress_to = 8;
|
||||
protected Object Base_get_or_null(byte[] key) {
|
||||
Object rv_obj = hash.Fetch(key);
|
||||
Object rv_obj = hash.Get_by(key);
|
||||
return rv_obj == null ? null : ((Gfo_cache_itm)rv_obj).Val();
|
||||
}
|
||||
protected void Base_add(byte[] key, Object val) {
|
||||
@@ -33,15 +33,15 @@ public class Gfo_cache_mgr_base {
|
||||
hash.Del(key);
|
||||
}
|
||||
public void Compress() {
|
||||
hash.SortBy(Gfo_cache_itm_comparer.Touched_asc);
|
||||
hash.Sort_by(Gfo_cache_itm_comparer.Touched_asc);
|
||||
int del_len = hash.Count() - compress_to;
|
||||
ListAdp del_list = ListAdp_.new_();
|
||||
List_adp del_list = List_adp_.new_();
|
||||
for (int i = 0; i < del_len; i++) {
|
||||
Gfo_cache_itm itm = (Gfo_cache_itm)hash.FetchAt(i);
|
||||
Gfo_cache_itm itm = (Gfo_cache_itm)hash.Get_at(i);
|
||||
del_list.Add(itm);
|
||||
}
|
||||
for (int i = 0; i < del_len; i++) {
|
||||
Gfo_cache_itm itm = (Gfo_cache_itm)del_list.FetchAt(i);
|
||||
Gfo_cache_itm itm = (Gfo_cache_itm)del_list.Get_at(i);
|
||||
hash.Del(itm.Key());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class Io_url_exists_mgr {
|
||||
byte[] url_key = url.RawBry();
|
||||
Object rv_obj = cache_mgr.Get_or_null(url_key);
|
||||
if (rv_obj != null) return ((Bool_obj_ref)rv_obj).Val(); // cached val exists; use it
|
||||
boolean exists = Io_mgr._.ExistsFil(url);
|
||||
boolean exists = Io_mgr.I.ExistsFil(url);
|
||||
cache_mgr.Add(url_key, Bool_obj_ref.new_(exists));
|
||||
return exists;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Bit_ {
|
||||
byte[] rv = new byte[8];
|
||||
for (int i = 0; i < 8; i++)
|
||||
rv[i] = bits[i] ? Byte_ascii.Num_1 : Byte_ascii.Num_0;
|
||||
return String_.new_ascii_(rv);
|
||||
return String_.new_a7(rv);
|
||||
}
|
||||
public static int[] Bld_pow_ary(int... seg_ary) {
|
||||
int seg_ary_len = seg_ary.length;
|
||||
|
||||
@@ -85,6 +85,6 @@ public class Bry_rdr {
|
||||
public double Read_double_to_pipe() {return Read_double_to(Byte_ascii.Pipe);}
|
||||
public double Read_double_to(byte to_char) {
|
||||
byte[] double_bry = Read_bry_to(to_char);
|
||||
return Double_.parse_(String_.new_ascii_(double_bry)); // double will never have utf8
|
||||
return Double_.parse_(String_.new_a7(double_bry)); // double will never have utf8
|
||||
}
|
||||
}
|
||||
@@ -43,14 +43,14 @@ public class Bry_rdr_tst {
|
||||
class Bry_rdr_fxt {
|
||||
private Bry_rdr rdr;
|
||||
public void Clear() {rdr = new Bry_rdr();}
|
||||
public Bry_rdr_fxt Init_src(String v) {rdr.Src_(Bry_.new_utf8_(v)); return this;}
|
||||
public Bry_rdr_fxt Init_src(String v) {rdr.Src_(Bry_.new_u8(v)); return this;}
|
||||
public Bry_rdr_fxt Init_pos(int v) {rdr.Pos_(v); return this;}
|
||||
public void Test_read_int(int expd_val) {
|
||||
Tfds.Eq(expd_val, rdr.Read_int_to_pipe());
|
||||
}
|
||||
public void Test_read_bry(String expd_str) {
|
||||
byte[] actl_bry = rdr.Read_bry_to_pipe();
|
||||
String actl_str = actl_bry == null ? null : String_.new_utf8_(actl_bry);
|
||||
String actl_str = actl_bry == null ? null : String_.new_u8(actl_bry);
|
||||
Tfds.Eq(expd_str, actl_str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,19 +39,19 @@ public class Btrie_bwd_mgr {
|
||||
cur = nxt;
|
||||
}
|
||||
}
|
||||
public Btrie_bwd_mgr Add_str_byte(String key, byte val) {return Add(Bry_.new_utf8_(key), Byte_obj_val.new_(val));}
|
||||
public Btrie_bwd_mgr Add_str_byte(String key, byte val) {return Add(Bry_.new_u8(key), Byte_obj_val.new_(val));}
|
||||
public Btrie_bwd_mgr Add_byteVal_strAry(byte val, String... ary) {
|
||||
int ary_len = ary.length;
|
||||
Byte_obj_val byteVal = Byte_obj_val.new_(val);
|
||||
for (int i = 0; i < ary_len; i++) {
|
||||
String itm = ary[i];
|
||||
Add(Bry_.new_utf8_(itm), byteVal);
|
||||
Add(Bry_.new_u8(itm), byteVal);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Btrie_bwd_mgr Add(String key, Object val) {return Add(Bry_.new_utf8_(key), val);}
|
||||
public Btrie_bwd_mgr Add(String key, Object val) {return Add(Bry_.new_u8(key), val);}
|
||||
public Btrie_bwd_mgr Add(byte[] key, Object val) {
|
||||
if (val == null) throw Err_.new_("null objects cannot be registered").Add("key", String_.new_utf8_(key));
|
||||
if (val == null) throw Err_.new_("null objects cannot be registered").Add("key", String_.new_u8(key));
|
||||
int key_len = key.length;
|
||||
Btrie_slim_itm cur = root;
|
||||
for (int i = key_len - 1; i > -1; i--) {
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Btrie_bwd_mgr_tst {
|
||||
run_Add("c" , 1);
|
||||
run_Add("abc" , 123);
|
||||
}
|
||||
@Test public void Fetch() {
|
||||
@Test public void Get_by() {
|
||||
ini_setup1();
|
||||
tst_MatchAtCur("c" , 1);
|
||||
tst_MatchAtCur("abc" , 123);
|
||||
@@ -68,19 +68,19 @@ public class Btrie_bwd_mgr_tst {
|
||||
tst_MatchAtCur("a", 1);
|
||||
tst_MatchAtCur("A", 1);
|
||||
}
|
||||
private void run_Add(String k, int val) {trie.Add(Bry_.new_utf8_(k), val);}
|
||||
private void run_Add(String k, int val) {trie.Add(Bry_.new_u8(k), val);}
|
||||
private void tst_Match(String srcStr, byte b, int bgn_pos, int expd) {
|
||||
byte[] src = Bry_.new_utf8_(srcStr);
|
||||
byte[] src = Bry_.new_u8(srcStr);
|
||||
Object actl = trie.Match(b, src, bgn_pos, -1);
|
||||
Tfds.Eq(expd, actl);
|
||||
}
|
||||
private void tst_MatchAtCur(String srcStr, Object expd) {
|
||||
byte[] src = Bry_.new_utf8_(srcStr);
|
||||
byte[] src = Bry_.new_u8(srcStr);
|
||||
Object actl = trie.Match(src[src.length - 1], src, src.length - 1, -1);
|
||||
Tfds.Eq(expd, actl);
|
||||
}
|
||||
private void tst_MatchAtCurExact(String srcStr, Object expd) {
|
||||
byte[] src = Bry_.new_utf8_(srcStr);
|
||||
byte[] src = Bry_.new_u8(srcStr);
|
||||
Object actl = trie.Match_exact(src, src.length - 1, -1);
|
||||
Tfds.Eq(expd, actl);
|
||||
}
|
||||
|
||||
@@ -44,11 +44,11 @@ public class Btrie_fast_mgr {
|
||||
}
|
||||
public Btrie_fast_mgr Add_bry_bval(byte key, byte val) {return Add(new byte[] {key}, Byte_obj_val.new_(val));}
|
||||
public Btrie_fast_mgr Add_bry_bval(byte[] key, byte val) {return Add(key, Byte_obj_val.new_(val));}
|
||||
public Btrie_fast_mgr Add_str_byte(String key, byte val) {return Add(Bry_.new_utf8_(key), Byte_obj_val.new_(val));}
|
||||
public Btrie_fast_mgr Add_str_byte(String key, byte val) {return Add(Bry_.new_u8(key), Byte_obj_val.new_(val));}
|
||||
public Btrie_fast_mgr Add(byte key, Object val) {return Add(new byte[] {key}, val);}
|
||||
public Btrie_fast_mgr Add(String key, Object val) {return Add(Bry_.new_utf8_(key), val);}
|
||||
public Btrie_fast_mgr Add(String key, Object val) {return Add(Bry_.new_u8(key), val);}
|
||||
public Btrie_fast_mgr Add(byte[] key, Object val) {
|
||||
if (val == null) throw Err_.new_("null objects cannot be registered").Add("key", String_.new_utf8_(key));
|
||||
if (val == null) throw Err_.new_("null objects cannot be registered").Add("key", String_.new_u8(key));
|
||||
int key_len = key.length; int key_end = key_len - 1;
|
||||
ByteTrieItm_fast cur = root;
|
||||
for (int i = 0; i < key_len; i++) {
|
||||
@@ -63,7 +63,7 @@ public class Btrie_fast_mgr {
|
||||
return this;
|
||||
}
|
||||
public Btrie_fast_mgr Add_stub(byte tid, String s) {
|
||||
byte[] bry = Bry_.new_utf8_(s);
|
||||
byte[] bry = Bry_.new_u8(s);
|
||||
Btrie_itm_stub stub = new Btrie_itm_stub(tid, bry);
|
||||
return Add(bry, stub);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.junit.*;
|
||||
public class Btrie_fast_mgr_tst {
|
||||
private Btrie_fast_mgr_fxt fxt = new Btrie_fast_mgr_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Fetch() {
|
||||
@Test public void Get_by() {
|
||||
fxt.Test_matchAtCur("a" , 1);
|
||||
fxt.Test_matchAtCur("abc" , 123);
|
||||
fxt.Test_matchAtCur("ab" , 1);
|
||||
@@ -65,21 +65,21 @@ class Btrie_fast_mgr_fxt {
|
||||
}
|
||||
public void Init_add(int val, byte... ary) {trie.Add(ary, val);}
|
||||
public void Test_match(String src_str, byte b, int bgn_pos, int expd) {
|
||||
byte[] src = Bry_.new_ascii_(src_str);
|
||||
byte[] src = Bry_.new_a7(src_str);
|
||||
Object actl = trie.Match_bgn_w_byte(b, src, bgn_pos, src.length);
|
||||
Tfds.Eq(expd, actl);
|
||||
}
|
||||
public void Test_matchAtCur(String src_str, Object expd) {
|
||||
byte[] src = Bry_.new_ascii_(src_str);
|
||||
byte[] src = Bry_.new_a7(src_str);
|
||||
Object actl = trie.Match_bgn(src, 0, src.length);
|
||||
Tfds.Eq(expd, actl);
|
||||
}
|
||||
public void Test_matchAtCurExact(String src_str, Object expd) {
|
||||
byte[] src = Bry_.new_ascii_(src_str);
|
||||
byte[] src = Bry_.new_a7(src_str);
|
||||
Object actl = trie.Match_exact(src, 0, src.length);
|
||||
Tfds.Eq(expd, actl);
|
||||
}
|
||||
public void Exec_del(String src_str) {
|
||||
trie.Del(Bry_.new_utf8_(src_str));
|
||||
trie.Del(Bry_.new_u8(src_str));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,10 +41,10 @@ public class Btrie_slim_mgr implements Btrie_mgr {
|
||||
}
|
||||
}
|
||||
public Btrie_slim_mgr Add_bry_tid(byte[] bry, byte tid) {return (Btrie_slim_mgr)Add_obj(bry, Byte_obj_val.new_(tid));}
|
||||
public Btrie_slim_mgr Add_str_byte(String key, byte val) {return (Btrie_slim_mgr)Add_obj(Bry_.new_utf8_(key), Byte_obj_val.new_(val));}
|
||||
public Btrie_slim_mgr Add_str_int(String key, int val) {return (Btrie_slim_mgr)Add_obj(Bry_.new_utf8_(key), Int_obj_val.new_(val));}
|
||||
public Btrie_slim_mgr Add_bry(String key, String val) {return (Btrie_slim_mgr)Add_obj(Bry_.new_utf8_(key), Bry_.new_utf8_(val));}
|
||||
public Btrie_slim_mgr Add_bry(String key, byte[] val) {return (Btrie_slim_mgr)Add_obj(Bry_.new_utf8_(key), val);}
|
||||
public Btrie_slim_mgr Add_str_byte(String key, byte val) {return (Btrie_slim_mgr)Add_obj(Bry_.new_u8(key), Byte_obj_val.new_(val));}
|
||||
public Btrie_slim_mgr Add_str_int(String key, int val) {return (Btrie_slim_mgr)Add_obj(Bry_.new_u8(key), Int_obj_val.new_(val));}
|
||||
public Btrie_slim_mgr Add_bry(String key, String val) {return (Btrie_slim_mgr)Add_obj(Bry_.new_u8(key), Bry_.new_u8(val));}
|
||||
public Btrie_slim_mgr Add_bry(String key, byte[] val) {return (Btrie_slim_mgr)Add_obj(Bry_.new_u8(key), val);}
|
||||
public Btrie_slim_mgr Add_bry(byte[] v) {return (Btrie_slim_mgr)Add_obj(v, v);}
|
||||
public Btrie_slim_mgr Add_bry_bval(byte b, byte val) {return (Btrie_slim_mgr)Add_obj(new byte[] {b}, Byte_obj_val.new_(val));}
|
||||
public Btrie_slim_mgr Add_bry_bval(byte[] bry, byte val) {return (Btrie_slim_mgr)Add_obj(bry, Byte_obj_val.new_(val));}
|
||||
@@ -52,10 +52,10 @@ public class Btrie_slim_mgr implements Btrie_mgr {
|
||||
int ary_len = ary.length;
|
||||
Byte_obj_val bval = Byte_obj_val.new_(val);
|
||||
for (int i = 0; i < ary_len; i++)
|
||||
Add_obj(Bry_.new_utf8_(ary[i]), bval);
|
||||
Add_obj(Bry_.new_u8(ary[i]), bval);
|
||||
return this;
|
||||
}
|
||||
public Btrie_slim_mgr Add_stub(String key, byte val) {byte[] bry = Bry_.new_utf8_(key); return (Btrie_slim_mgr)Add_obj(bry, new Btrie_itm_stub(val, bry));}
|
||||
public Btrie_slim_mgr Add_stub(String key, byte val) {byte[] bry = Bry_.new_u8(key); return (Btrie_slim_mgr)Add_obj(bry, new Btrie_itm_stub(val, bry));}
|
||||
public Btrie_slim_mgr Add_stubs(byte[][] ary) {return Add_stubs(ary, ary.length);}
|
||||
public Btrie_slim_mgr Add_stubs(byte[][] ary, int ary_len) {
|
||||
for (byte i = 0; i < ary_len; i++) {
|
||||
@@ -64,9 +64,9 @@ public class Btrie_slim_mgr implements Btrie_mgr {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Btrie_mgr Add_obj(String key, Object val) {return Add_obj(Bry_.new_utf8_(key), val);}
|
||||
public Btrie_mgr Add_obj(String key, Object val) {return Add_obj(Bry_.new_u8(key), val);}
|
||||
public Btrie_mgr Add_obj(byte[] key, Object val) {
|
||||
if (val == null) throw Err_.new_("null objects cannot be registered").Add("key", String_.new_utf8_(key));
|
||||
if (val == null) throw Err_.new_("null objects cannot be registered").Add("key", String_.new_u8(key));
|
||||
int key_len = key.length; int key_end = key_len - 1;
|
||||
Btrie_slim_itm cur = root;
|
||||
for (int i = 0; i < key_len; i++) {
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Btrie_slim_mgr_tst {
|
||||
run_Add("a" , 1);
|
||||
run_Add("abc" , 123);
|
||||
}
|
||||
@Test public void Fetch() {
|
||||
@Test public void Get_by() {
|
||||
ini_setup1();
|
||||
tst_MatchAtCur("a" , 1);
|
||||
tst_MatchAtCur("abc" , 123);
|
||||
@@ -65,27 +65,27 @@ public class Btrie_slim_mgr_tst {
|
||||
}
|
||||
@Test public void Del() {
|
||||
ini_setup1();
|
||||
trie.Del(Bry_.new_ascii_("a")); // delete "a"; "abc" still remains;
|
||||
trie.Del(Bry_.new_a7("a")); // delete "a"; "abc" still remains;
|
||||
tst_MatchAtCur("a" , null);
|
||||
tst_MatchAtCur("abc" , 123);
|
||||
|
||||
trie.Del(Bry_.new_ascii_("abc"));
|
||||
trie.Del(Bry_.new_a7("abc"));
|
||||
tst_MatchAtCur("abc" , null);
|
||||
}
|
||||
|
||||
private void run_Add(String k, int val) {trie.Add_obj(Bry_.new_ascii_(k), val);}
|
||||
private void run_Add(String k, int val) {trie.Add_obj(Bry_.new_a7(k), val);}
|
||||
private void tst_Match(String srcStr, byte b, int bgn_pos, int expd) {
|
||||
byte[] src = Bry_.new_ascii_(srcStr);
|
||||
byte[] src = Bry_.new_a7(srcStr);
|
||||
Object actl = trie.Match_bgn_w_byte(b, src, bgn_pos, src.length);
|
||||
Tfds.Eq(expd, actl);
|
||||
}
|
||||
private void tst_MatchAtCur(String srcStr, Object expd) {
|
||||
byte[] src = Bry_.new_ascii_(srcStr);
|
||||
byte[] src = Bry_.new_a7(srcStr);
|
||||
Object actl = trie.Match_bgn_w_byte(src[0], src, 0, src.length);
|
||||
Tfds.Eq(expd, actl);
|
||||
}
|
||||
private void tst_MatchAtCurExact(String srcStr, Object expd) {
|
||||
byte[] src = Bry_.new_ascii_(srcStr);
|
||||
byte[] src = Bry_.new_a7(srcStr);
|
||||
Object actl = trie.Match_exact(src, 0, src.length);
|
||||
Tfds.Eq(expd, actl);
|
||||
}
|
||||
|
||||
@@ -43,9 +43,9 @@ public class Btrie_utf8_mgr implements Btrie_mgr {
|
||||
}
|
||||
}
|
||||
public void Clear() {root.Clear(); count = 0;}
|
||||
public Btrie_mgr Add_obj(String key, Object val) {return Add_obj(Bry_.new_utf8_(key), val);}
|
||||
public Btrie_mgr Add_obj(String key, Object val) {return Add_obj(Bry_.new_u8(key), val);}
|
||||
public Btrie_mgr Add_obj(byte[] key, Object val) {
|
||||
if (val == null) throw Err_.new_("null objects cannot be registered").Add("key", String_.new_utf8_(key));
|
||||
if (val == null) throw Err_.new_("null objects cannot be registered").Add("key", String_.new_u8(key));
|
||||
int key_len = key.length;
|
||||
Btrie_utf8_itm cur = root;
|
||||
int c_bgn = 0;
|
||||
|
||||
@@ -21,8 +21,8 @@ import gplx.xowa.langs.cases.*;
|
||||
public class Btrie_utf8_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Btrie_utf8_mgr_fxt fxt = new Btrie_utf8_mgr_fxt();
|
||||
@Test public void Ascii() {
|
||||
fxt.Init_add(Bry_.new_ascii_("a") , "1");
|
||||
fxt.Init_add(Bry_.new_ascii_("abc") , "123");
|
||||
fxt.Init_add(Bry_.new_a7("a") , "1");
|
||||
fxt.Init_add(Bry_.new_a7("abc") , "123");
|
||||
fxt.Test_match("a" , "1"); // single.exact
|
||||
fxt.Test_match("abc" , "123"); // many.exact
|
||||
fxt.Test_match("ab" , "1"); // single.more
|
||||
@@ -31,7 +31,7 @@ public class Btrie_utf8_mgr_tst {
|
||||
fxt.Test_match("aBC" , "123"); // upper
|
||||
}
|
||||
@Test public void Uft8() {
|
||||
fxt.Init_add(Bry_.new_utf8_("aéi") , "1");
|
||||
fxt.Init_add(Bry_.new_u8("aéi") , "1");
|
||||
fxt.Test_match("aéi" , "1"); // exact
|
||||
fxt.Test_match("aÉi" , "1"); // upper.utf8
|
||||
fxt.Test_match("AÉI" , "1"); // upper.all
|
||||
@@ -39,38 +39,38 @@ public class Btrie_utf8_mgr_tst {
|
||||
fxt.Test_match("aei" , null); // no_match
|
||||
}
|
||||
@Test public void Uft8_match_pos() {
|
||||
fxt.Init_add(Bry_.new_utf8_("aéi") , "1");
|
||||
fxt.Init_add(Bry_.new_u8("aéi") , "1");
|
||||
fxt.Test_match_pos("aAÉI" , 1, "1"); // match at 1
|
||||
fxt.Test_match_pos("aAÉI" , 0, null); // no_match at 0
|
||||
}
|
||||
@Test public void Uft8_asymmetric() {
|
||||
fxt.Init_add(Bry_.new_utf8_("İ") , "1");
|
||||
fxt.Init_add(Bry_.new_u8("İ") , "1");
|
||||
fxt.Test_match("İ" , "1"); // exact=y; İ = Bry_.ints_(196,176)
|
||||
fxt.Test_match("i" , "1"); // lower=y; i = Bry_.ints_(105)
|
||||
fxt.Test_match("I" , null); // upper=n; I = Bry_.ints_( 73); see Btrie_utf8_itm and rv.asymmetric_bry
|
||||
|
||||
fxt.Clear();
|
||||
fxt.Init_add(Bry_.new_utf8_("i") , "1");
|
||||
fxt.Init_add(Bry_.new_u8("i") , "1");
|
||||
fxt.Test_match("i" , "1"); // exact=y
|
||||
fxt.Test_match("I" , "1"); // upper=y
|
||||
fxt.Test_match("İ" , null); // utf_8=n; note that a trie with "i" doesn't match a src with "İ" even though "İ" lower-cases to "i"
|
||||
}
|
||||
@Test public void Utf8_asymmetric_multiple() { // PURPOSE: problems in original implementation of Hash_adp_bry and uneven source / target counts;
|
||||
fxt.Init_add(Bry_.new_utf8_("İİ") , "1");
|
||||
fxt.Init_add(Bry_.new_u8("İİ") , "1");
|
||||
fxt.Test_match("İİ" , "1"); // exact
|
||||
fxt.Test_match("ii" , "1"); // lower
|
||||
fxt.Test_match("İi" , "1"); // mixed
|
||||
fxt.Test_match("iİ" , "1"); // mixed
|
||||
}
|
||||
@Test public void Utf8_asymmetric_upper() { // PURPOSE: "İ" and "I" should co-exist; see Btrie_utf8_itm and called_by_match
|
||||
fxt.Init_add(Bry_.new_utf8_("İ") , "1");
|
||||
fxt.Init_add(Bry_.new_utf8_("I") , "1");
|
||||
fxt.Init_add(Bry_.new_u8("İ") , "1");
|
||||
fxt.Init_add(Bry_.new_u8("I") , "1");
|
||||
fxt.Test_match("İ" , "1"); // exact
|
||||
fxt.Test_match("I" , "1"); // exact
|
||||
fxt.Test_match("i" , "1"); // lower
|
||||
}
|
||||
@Test public void Utf8_asymmetric_symbols() { // PURPOSE: test Hash_adp_bry and multi-byte syms (chars that will never be cased)
|
||||
fxt.Init_add(Bry_.new_utf8_("a_b") , "1");
|
||||
fxt.Init_add(Bry_.new_u8("a_b") , "1");
|
||||
fxt.Test_match("a_b" , "1"); // exact: len=3
|
||||
fxt.Test_match("a†b" , null); // diff : len=3
|
||||
fxt.Test_match("a±b" , null); // diff : len=2
|
||||
@@ -84,12 +84,12 @@ class Btrie_utf8_mgr_fxt {
|
||||
}
|
||||
public void Init_add(byte[] key, Object val) {trie.Add_obj(key, val);}
|
||||
public void Test_match_pos(String src_str, int bgn_pos, String expd) {
|
||||
byte[] src = Bry_.new_utf8_(src_str);
|
||||
byte[] src = Bry_.new_u8(src_str);
|
||||
Object actl = trie.Match_bgn_w_byte(src[bgn_pos], src, bgn_pos, src.length);
|
||||
Tfds.Eq(expd, actl, src_str);
|
||||
}
|
||||
public void Test_match(String src_str, String expd) {
|
||||
byte[] src = Bry_.new_utf8_(src_str);
|
||||
byte[] src = Bry_.new_u8(src_str);
|
||||
Object actl = trie.Match_bgn_w_byte(src[0], src, 0, src.length);
|
||||
Tfds.Eq(expd, actl, src_str);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.enums; import gplx.*; import gplx.core.*;
|
||||
class Gfo_enum_grp {
|
||||
// private OrderedHash itms = OrderedHash_.new_();
|
||||
// private Ordered_hash itms = Ordered_hash_.new_();
|
||||
public Gfo_enum_grp(Guid_adp uid, String key, int id, String name, int sort, String xtn) {
|
||||
this.uid = uid; this.key = key; this.id = id; this.name = name; this.sort = sort; this.xtn = xtn;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,6 @@ public class Gfo_fld_base {
|
||||
protected Gfo_fld_base Ctor_sql_base() {
|
||||
return Escape_clear().Ini_common()
|
||||
.Fld_dlm_(Byte_ascii.Comma).Row_dlm_(Byte_ascii.Paren_end).Escape_dlm_(Byte_ascii.Backslash).Quote_dlm_(Byte_ascii.Apos)
|
||||
.Escape_reg(Byte_ascii.Backslash).Escape_reg(Byte_ascii.Quote).Escape_reg(Byte_ascii.Apos); // , Escape_eof = Bry_.new_utf8_("\\Z")
|
||||
.Escape_reg(Byte_ascii.Backslash).Escape_reg(Byte_ascii.Quote).Escape_reg(Byte_ascii.Apos); // , Escape_eof = Bry_.new_u8("\\Z")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.flds; import gplx.*; import gplx.core.*;
|
||||
public class Gfo_fld_rdr extends Gfo_fld_base {
|
||||
private Bry_bfr bfr = Bry_bfr.new_(); private static final byte[] Bry_nil = Bry_.new_ascii_("\\0");
|
||||
private Bry_bfr bfr = Bry_bfr.new_(); private static final byte[] Bry_nil = Bry_.new_a7("\\0");
|
||||
public byte[] Data() {return data;} public Gfo_fld_rdr Data_(byte[] v) {data = v; data_len = v.length; pos = 0; return this;} private byte[] data; int data_len;
|
||||
public int Pos() {return pos;} public Gfo_fld_rdr Pos_(int v) {pos = v; return this;} private int pos;
|
||||
public int Fld_bgn() {return fld_bgn;} public Gfo_fld_rdr Fld_bgn_(int v) {fld_bgn = v; return this;} private int fld_bgn;
|
||||
@@ -26,7 +26,7 @@ public class Gfo_fld_rdr extends Gfo_fld_base {
|
||||
public int Row_idx() {return row_idx;} private int row_idx;
|
||||
public void Ini(byte[] data, int pos) {this.data = data; this.data_len = data.length; this.pos = pos;}
|
||||
|
||||
public String Read_str_simple() {Move_next_simple(); return String_.new_utf8_(data, fld_bgn, fld_end);}
|
||||
public String Read_str_simple() {Move_next_simple(); return String_.new_u8(data, fld_bgn, fld_end);}
|
||||
public byte[] Read_bry_simple() {Move_next_simple(); return Bry_.Mid(data, fld_bgn, fld_end);} // was Mid_by_len???; 20120915
|
||||
public int Read_int_base85_lenN(int len) {fld_bgn = pos; fld_end = pos + len - 1 ; pos = pos + len + 1 ; return Base85_utl.XtoIntByAry(data, fld_bgn, fld_end);}
|
||||
public int Read_int_base85_len5() {fld_bgn = pos; fld_end = pos + 4 ; pos = pos + 6 ; return Base85_utl.XtoIntByAry(data, fld_bgn, fld_end);}
|
||||
@@ -54,7 +54,7 @@ public class Gfo_fld_rdr extends Gfo_fld_base {
|
||||
f += (data[fld_bgn + 16] - Byte_ascii.Num_0) * 100;
|
||||
f += (data[fld_bgn + 17] - Byte_ascii.Num_0) * 10;
|
||||
f += (data[fld_bgn + 18] - Byte_ascii.Num_0);
|
||||
if (data[fld_bgn + 19] != fld_dlm) throw Err_.new_("csv date is invalid").Add("txt", String_.new_utf8_len_safe_(data, fld_bgn, 20));
|
||||
if (data[fld_bgn + 19] != fld_dlm) throw Err_.new_("csv date is invalid").Add("txt", String_.new_u8_by_len(data, fld_bgn, 20));
|
||||
fld_end = pos + 20;
|
||||
pos = fld_end + 1; ++fld_idx;
|
||||
return DateAdp_.new_(y, M, d, H, m, s, f);
|
||||
@@ -80,7 +80,7 @@ public class Gfo_fld_rdr extends Gfo_fld_base {
|
||||
}
|
||||
throw Err_.new_("fld_dlm failed").Add("fld_dlm", (char)fld_dlm).Add("bgn", fld_bgn);
|
||||
}
|
||||
public String Read_str_escape() {Move_next_escaped(bfr); return String_.new_utf8_(bfr.Xto_bry_and_clear());}
|
||||
public String Read_str_escape() {Move_next_escaped(bfr); return String_.new_u8(bfr.Xto_bry_and_clear());}
|
||||
public byte[] Read_bry_escape() {Move_next_escaped(bfr); return bfr.Xto_bry_and_clear();}
|
||||
public void Move_1() {++pos;}
|
||||
public void Move_next_escaped() {Move_next_escaped(bfr); bfr.Clear();}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class Gfo_fld_rdr_tst {
|
||||
}
|
||||
class Gfo_fld_rdr_fxt {
|
||||
Gfo_fld_rdr rdr = new Gfo_fld_rdr(); Gfo_fld_wtr wtr = Gfo_fld_wtr.xowa_();
|
||||
public Gfo_fld_rdr_fxt Raw_(String v) {rdr.Data_(Bry_.new_utf8_(v)); return this;}
|
||||
public Gfo_fld_rdr_fxt Raw_(String v) {rdr.Data_(Bry_.new_u8(v)); return this;}
|
||||
public Gfo_fld_rdr_fxt ini_xdat() {rdr.Ctor_xdat(); return this;}
|
||||
public Gfo_fld_rdr_fxt ini_sql() {rdr.Ctor_sql(); return this;}
|
||||
public Gfo_fld_rdr_fxt tst_Read_int(int expd) {Tfds.Eq(expd, rdr.Read_int()); return this;}
|
||||
@@ -47,7 +47,7 @@ class Gfo_fld_rdr_fxt {
|
||||
public Gfo_fld_rdr_fxt tst_Read_str_simple(String expd) {Tfds.Eq(expd, rdr.Read_str_simple()); return this;}
|
||||
public Gfo_fld_rdr_fxt tst_Read_str_escape(String expd) {Tfds.Eq(expd, rdr.Read_str_escape()); return this;}
|
||||
public Gfo_fld_rdr_fxt tst_Write_str_escape(String val, String expd) {
|
||||
byte[] bry = Bry_.new_utf8_(val);
|
||||
byte[] bry = Bry_.new_u8(val);
|
||||
wtr.Bfr_(bfr);
|
||||
wtr.Write_bry_escape_fld(bry);
|
||||
Tfds.Eq(expd, bfr.Xto_str());
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Gfo_fld_wtr extends Gfo_fld_base {
|
||||
public boolean Flush_needed(int v) {return bfr.Len() + v > bfr_max;}
|
||||
public void Flush() {
|
||||
if (Fil_gen().Cur_url() == null) fil_gen.Nxt_url();
|
||||
Io_mgr._.AppendFilBfr(fil_gen.Cur_url(), bfr);
|
||||
Io_mgr.I.AppendFilBfr(fil_gen.Cur_url(), bfr);
|
||||
}
|
||||
public void Flush_nxt() {Flush(); fil_gen.Nxt_url();}
|
||||
public Gfo_fld_wtr Ctor_xdat() {return (Gfo_fld_wtr)super.Ctor_xdat_base();}
|
||||
|
||||
@@ -25,16 +25,16 @@ class Gfo_html_parser {
|
||||
// int src_len = src.length;
|
||||
// int prv_pos = 0;
|
||||
// int css_find_bgn_len = Css_find_bgn.length;
|
||||
// byte[] protocol_prefix_bry = Bry_.new_utf8_(protocol_prefix);
|
||||
// byte[] protocol_prefix_bry = Bry_.new_u8(protocol_prefix);
|
||||
// while (true) {
|
||||
// int url_bgn = Bry_finder.Find_fwd(src, Css_find_bgn, prv_pos); if (url_bgn == Bry_.NotFound) break; // nothing left; stop
|
||||
// url_bgn += css_find_bgn_len;
|
||||
// int url_end = Bry_finder.Find_fwd(src, Byte_ascii.Quote, url_bgn, src_len); if (url_end == Bry_.NotFound) {usr_dlg.Warn_many("", "main_page.css_parse", "could not find css; pos='~{0}' text='~{1}'", url_bgn, String_.new_utf8_len_safe_(src, url_bgn, url_bgn + 32)); break;}
|
||||
// int url_end = Bry_finder.Find_fwd(src, Byte_ascii.Quote, url_bgn, src_len); if (url_end == Bry_.NotFound) {usr_dlg.Warn_many("", "main_page.css_parse", "could not find css; pos='~{0}' text='~{1}'", url_bgn, String_.new_u8_by_len(src, url_bgn, url_bgn + 32)); break;}
|
||||
// byte[] css_url_bry = Bry_.Mid(src, url_bgn, url_end);
|
||||
// css_url_bry = Bry_.Replace(css_url_bry, Css_amp_find, Css_amp_repl); // & -> &
|
||||
// css_url_bry = url_encoder.Decode(css_url_bry); // %2C -> %7C -> |
|
||||
// css_url_bry = Bry_.Add(protocol_prefix_bry, css_url_bry);
|
||||
// rv.Add(String_.new_utf8_(css_url_bry));
|
||||
// rv.Add(String_.new_u8(css_url_bry));
|
||||
// prv_pos = url_end;
|
||||
// }
|
||||
// return rv.XtoStrAry();
|
||||
|
||||
@@ -24,7 +24,7 @@ interface Gfo_html_tkn {
|
||||
}
|
||||
class Gfo_html_tkn_ {
|
||||
public static final int Tid_link = 1;
|
||||
public static final byte[] Key_link = Bry_.new_ascii_("link");
|
||||
public static final byte[] Key_link = Bry_.new_a7("link");
|
||||
}
|
||||
class Gfo_html_tkn__link implements Gfo_html_tkn {
|
||||
public int Tid() {return Gfo_html_tkn_.Tid_link;}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class Binary_search_ {
|
||||
public static int Search(CompareAble[] ary, int ary_len, CompareAble val) {
|
||||
if (ary_len == 1) return 0;
|
||||
int interval = ary_len / 2;
|
||||
int pos = interval - ListAdp_.Base1;
|
||||
int pos = interval - List_adp_.Base1;
|
||||
int pos_last = ary_len - 1;
|
||||
int pos_prv = -1;
|
||||
int loop_count = 0;
|
||||
|
||||
@@ -27,7 +27,7 @@ class Gfo_pattern_itm_text implements Gfo_pattern_itm {
|
||||
public Gfo_pattern_itm_text() {}
|
||||
public byte Tid() {return Gfo_pattern_itm_.Tid_text;}
|
||||
public byte[] Text() {return text;} private byte[] text; private int text_len;
|
||||
public void Xto_str(String_bldr sb) {sb.Add(this.Tid()).Add("|" + String_.new_utf8_(text));}
|
||||
public void Xto_str(String_bldr sb) {sb.Add(this.Tid()).Add("|" + String_.new_u8(text));}
|
||||
public void Compile(byte[] src, int bgn, int end) {
|
||||
this.text = Bry_.Mid(src, bgn, end);
|
||||
this.text_len = end - bgn;
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.core.regxs; import gplx.*; import gplx.core.*;
|
||||
public class Gfo_pattern_itm_ {
|
||||
public static final byte Tid_text = 0, Tid_wild = 1;
|
||||
public static Gfo_pattern_itm[] Compile(byte[] raw) {
|
||||
ListAdp rv = ListAdp_.new_();
|
||||
List_adp rv = List_adp_.new_();
|
||||
int raw_len = raw.length;
|
||||
int itm_bgn = -1;
|
||||
Gfo_pattern_itm itm = null;
|
||||
@@ -46,6 +46,6 @@ public class Gfo_pattern_itm_ {
|
||||
++pos;
|
||||
if (last) break;
|
||||
}
|
||||
return (Gfo_pattern_itm[])rv.Xto_ary_and_clear(Gfo_pattern_itm.class);
|
||||
return (Gfo_pattern_itm[])rv.To_ary_and_clear(Gfo_pattern_itm.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,25 +59,25 @@ public class Gfo_pattern_tst {
|
||||
}
|
||||
class Gfo_pattern_itm_fxt {
|
||||
public void Clear() {}
|
||||
public Gfo_pattern pattern_(String raw) {return new Gfo_pattern(Bry_.new_utf8_(raw));}
|
||||
public Gfo_pattern pattern_(String raw) {return new Gfo_pattern(Bry_.new_u8(raw));}
|
||||
public void Test_Match_y(Gfo_pattern pattern, String... itms) {Test_Match(pattern, itms, Bool_.Y);}
|
||||
public void Test_Match_n(Gfo_pattern pattern, String... itms) {Test_Match(pattern, itms, Bool_.N);}
|
||||
private void Test_Match(Gfo_pattern pattern, String[] itms, boolean expd) {
|
||||
int len = itms.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
String itm = itms[i];
|
||||
Tfds.Eq(expd, pattern.Match(Bry_.new_utf8_(itm)), "pattern={0} itm={1} expd={2}", String_.new_utf8_(pattern.Raw()), itm, expd);
|
||||
Tfds.Eq(expd, pattern.Match(Bry_.new_u8(itm)), "pattern={0} itm={1} expd={2}", String_.new_u8(pattern.Raw()), itm, expd);
|
||||
}
|
||||
}
|
||||
public Gfo_pattern_itm_wild itm_wild_() {return Gfo_pattern_itm_wild._;}
|
||||
public Gfo_pattern_itm_text itm_text_(String raw) {
|
||||
Gfo_pattern_itm_text rv = new Gfo_pattern_itm_text();
|
||||
byte[] bry = Bry_.new_utf8_(raw);
|
||||
byte[] bry = Bry_.new_u8(raw);
|
||||
rv.Compile(bry, 0, bry.length);
|
||||
return rv;
|
||||
}
|
||||
public void Test_Compile(String raw, Gfo_pattern_itm... expd) {
|
||||
Gfo_pattern_itm[] actl = Gfo_pattern_itm_.Compile(Bry_.new_utf8_(raw));
|
||||
Gfo_pattern_itm[] actl = Gfo_pattern_itm_.Compile(Bry_.new_u8(raw));
|
||||
Tfds.Eq(Ary_xto_str(expd), Ary_xto_str(actl));
|
||||
}
|
||||
private static String Ary_xto_str(Gfo_pattern_itm[] ary) {
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.core.threads; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.primitives.*;
|
||||
public class Gfo_async_mgr implements GfoInvkAble {
|
||||
private ListAdp queue = ListAdp_.new_();
|
||||
private List_adp queue = List_adp_.new_();
|
||||
private Bool_obj_ref running = Bool_obj_ref.n_();
|
||||
private Gfo_async_cmd_mkr cmd_mkr = new Gfo_async_cmd_mkr();
|
||||
public void Queue(GfoInvkAble invk, String invk_key, Object... args) {
|
||||
@@ -39,7 +39,7 @@ public class Gfo_async_mgr implements GfoInvkAble {
|
||||
while (true) {
|
||||
synchronized (queue) {
|
||||
if (queue.Count() == 0) break;
|
||||
cmd = (Gfo_async_cmd_itm)ListAdp_.Pop(queue);
|
||||
cmd = (Gfo_async_cmd_itm)List_adp_.Pop(queue);
|
||||
cmd.Exec();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ public class Gfo_thread_cmd_download implements Gfo_thread_cmd {
|
||||
public int Async_sleep_interval() {return Gfo_thread_cmd_.Async_sleep_interval_1_second;}
|
||||
public boolean Async_prog_enabled() {return false;}
|
||||
@gplx.Virtual public byte Async_init() {
|
||||
if (Io_mgr._.ExistsFil(trg)) {
|
||||
if (Io_mgr.I.ExistsFil(trg)) {
|
||||
int rslt = kit.Ask_yes_no_cancel(GRP_KEY, "target_exists", "Target file already exists: '~{0}'.\nDo you want to delete it?", trg.Raw());
|
||||
switch (rslt) {
|
||||
case Gfui_dlg_msg_.Btn_yes: Io_mgr._.DeleteFil(trg); break;
|
||||
case Gfui_dlg_msg_.Btn_yes: Io_mgr.I.DeleteFil(trg); break;
|
||||
case Gfui_dlg_msg_.Btn_no: return Gfo_thread_cmd_.Init_cancel_step;
|
||||
case Gfui_dlg_msg_.Btn_cancel: return Gfo_thread_cmd_.Init_cancel_all;
|
||||
default: throw Err_mgr._.unhandled_(rslt);
|
||||
@@ -59,7 +59,7 @@ public class Gfo_thread_cmd_download implements Gfo_thread_cmd {
|
||||
kit.Ask_ok(GRP_KEY, "download.fail", "download failed. Please select 'read from file' if you've already downloaded a dump: url=~{0} error=~{1}", src, xrg.Rslt_err_str());
|
||||
}
|
||||
} boolean download_pass = true;
|
||||
protected gplx.ios.IoEngine_xrg_downloadFil xrg = Io_mgr._.DownloadFil_args("", Io_url_.Null);
|
||||
protected gplx.ios.IoEngine_xrg_downloadFil xrg = Io_mgr.I.DownloadFil_args("", Io_url_.Empty);
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_async_bgn)) Download();
|
||||
else if (ctx.Match(k, Invk_owner)) return owner;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Gfo_thread_cmd_replace implements Gfo_thread_cmd {
|
||||
public int Async_sleep_interval() {return Gfo_thread_cmd_.Async_sleep_interval_1_second;}
|
||||
public boolean Async_prog_enabled() {return false;}
|
||||
@gplx.Virtual public byte Async_init() {
|
||||
if (!Io_mgr._.ExistsFil(fil)) {kit.Ask_ok(GRP_KEY, "file_missing", "File does not exist: '~{0}'", fil.Raw()); return Gfo_thread_cmd_.Init_cancel_step;}
|
||||
if (!Io_mgr.I.ExistsFil(fil)) {kit.Ask_ok(GRP_KEY, "file_missing", "File does not exist: '~{0}'", fil.Raw()); return Gfo_thread_cmd_.Init_cancel_step;}
|
||||
return Gfo_thread_cmd_.Init_ok;
|
||||
}
|
||||
public boolean Async_term() {return true;}
|
||||
@@ -38,16 +38,16 @@ public class Gfo_thread_cmd_replace implements Gfo_thread_cmd {
|
||||
public boolean Async_running() {return false;}
|
||||
@gplx.Virtual public void Async_run() {Exec_find_replace();} // NOTE: do not run async; if multiple commands for same file then they will not always work
|
||||
public void Exec_find_replace() {
|
||||
String raw = Io_mgr._.LoadFilStr(fil);
|
||||
String raw = Io_mgr.I.LoadFilStr(fil);
|
||||
int pairs_len = pairs.Count();
|
||||
for (int i = 0; i < pairs_len; i++) {
|
||||
KeyVal kv = (KeyVal)pairs.FetchAt(i);
|
||||
KeyVal kv = (KeyVal)pairs.Get_at(i);
|
||||
raw = String_.Replace(raw, kv.Key(), kv.Val_to_str_or_null());
|
||||
}
|
||||
Io_mgr._.SaveFilStr(fil, raw);
|
||||
Io_mgr.I.SaveFilStr(fil, raw);
|
||||
usr_dlg.Prog_many(GRP_KEY, "done", "replace completed: ~{0} ~{1}", fil.Raw(), pairs_len);
|
||||
}
|
||||
public ListAdp pairs = ListAdp_.new_();
|
||||
public List_adp pairs = List_adp_.new_();
|
||||
@gplx.Virtual public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_async_bgn)) Exec_find_replace();
|
||||
else if (ctx.Match(k, Invk_owner)) return owner;
|
||||
|
||||
@@ -32,22 +32,22 @@ public class Gfo_thread_cmd_unzip implements Gfo_thread_cmd {
|
||||
public boolean Async_prog_enabled() {return true;}
|
||||
public void Async_prog_run(int async_sleep_sum) {
|
||||
String size_str = " please wait...";
|
||||
if (trg.Type_fil()) size_str = gplx.ios.Io_size_.Xto_str(Io_mgr._.QueryFil(trg).Size());
|
||||
if (trg.Type_fil()) size_str = gplx.ios.Io_size_.To_str(Io_mgr.I.QueryFil(trg).Size());
|
||||
usr_dlg.Prog_many(GRP_KEY, "unzip", "unzipping: ~{0}", size_str);
|
||||
}
|
||||
@gplx.Virtual public byte Async_init() {
|
||||
if (!Io_mgr._.ExistsFil(src)) {
|
||||
if (!Io_mgr.I.ExistsFil(src)) {
|
||||
kit.Ask_ok(GRP_KEY, "source_missing", "Source file does not exist: '~{0}'", src.Raw());
|
||||
return Gfo_thread_cmd_.Init_cancel_step;
|
||||
}
|
||||
trg_is_dir = trg.Type_dir();
|
||||
if (delete_trg_if_exists
|
||||
&& (( trg_is_dir && Io_mgr._.ExistsDir(trg))
|
||||
|| (!trg_is_dir && Io_mgr._.ExistsFil(trg)))
|
||||
&& (( trg_is_dir && Io_mgr.I.ExistsDir(trg))
|
||||
|| (!trg_is_dir && Io_mgr.I.ExistsFil(trg)))
|
||||
) {
|
||||
int rslt = kit.Ask_yes_no_cancel(GRP_KEY, "target_exists", "Target file already exists: '~{0}'.\nDo you want to delete it?", trg.Raw());
|
||||
switch (rslt) {
|
||||
case Gfui_dlg_msg_.Btn_yes: if (trg_is_dir) Io_mgr._.DeleteDirDeep(trg); else Io_mgr._.DeleteFil(trg); break;
|
||||
case Gfui_dlg_msg_.Btn_yes: if (trg_is_dir) Io_mgr.I.DeleteDirDeep(trg); else Io_mgr.I.DeleteFil(trg); break;
|
||||
case Gfui_dlg_msg_.Btn_no: return Gfo_thread_cmd_.Init_cancel_step;
|
||||
case Gfui_dlg_msg_.Btn_cancel: return Gfo_thread_cmd_.Init_cancel_all;
|
||||
}
|
||||
@@ -61,9 +61,9 @@ public class Gfo_thread_cmd_unzip implements Gfo_thread_cmd {
|
||||
}
|
||||
public boolean Async_term() {
|
||||
if (rename_dir) {
|
||||
Io_url[] dirs = Io_mgr._.QueryDir_args(trg.OwnerDir()).DirOnly_().Recur_(false).ExecAsUrlAry();
|
||||
Io_url[] dirs = Io_mgr.I.QueryDir_args(trg.OwnerDir()).DirOnly_().Recur_(false).ExecAsUrlAry();
|
||||
int dirs_len = dirs.length;
|
||||
Io_url zip_dir = Io_url_.Null;
|
||||
Io_url zip_dir = Io_url_.Empty;
|
||||
for (int i = 0; i < dirs_len; i++) {
|
||||
Io_url dir = dirs[i];
|
||||
if (String_.HasAtBgn(String_.Lower(dir.NameOnly()), String_.Lower(trg.NameOnly()))) { // HACK: check that directory starts with archive name; DATE:2013-12-22
|
||||
@@ -71,19 +71,19 @@ public class Gfo_thread_cmd_unzip implements Gfo_thread_cmd {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (zip_dir == Io_url_.Null) {
|
||||
if (zip_dir == Io_url_.Empty) {
|
||||
kit.Ask_ok(GRP_KEY, "rename.fail", "unable to find directory: trg=~{0}", trg.Raw());
|
||||
return false;
|
||||
}
|
||||
if (!String_.Eq(String_.Lower(zip_dir.Raw()), String_.Lower(trg.Raw()))) // HACK: inkscape is itself
|
||||
Io_mgr._.MoveDirDeep(zip_dir, trg);
|
||||
Io_mgr.I.MoveDirDeep(zip_dir, trg);
|
||||
}
|
||||
switch (term_cmd_for_src) {
|
||||
case Term_cmd_for_src_noop: break;
|
||||
case Term_cmd_for_src_delete: Io_mgr._.DeleteFil(src); break;
|
||||
case Term_cmd_for_src_delete: Io_mgr.I.DeleteFil(src); break;
|
||||
case Term_cmd_for_src_move:
|
||||
if (term_cmd_for_src_url == Io_url_.Null) throw Err_mgr._.fmt_(GRP_KEY, "url_missing", "move specified, but no url");
|
||||
Io_mgr._.MoveFil_args(src, term_cmd_for_src_url, true).Exec();
|
||||
if (term_cmd_for_src_url == Io_url_.Empty) throw Err_mgr._.fmt_(GRP_KEY, "url_missing", "move specified, but no url");
|
||||
Io_mgr.I.MoveFil_args(src, term_cmd_for_src_url, true).Exec();
|
||||
break;
|
||||
default: throw Err_mgr._.unhandled_(term_cmd_for_src);
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class Gfo_thread_cmd_unzip implements Gfo_thread_cmd {
|
||||
public static final byte Term_cmd_for_src_noop = 0, Term_cmd_for_src_delete = 1, Term_cmd_for_src_move = 2;
|
||||
boolean rename_dir = false, trg_is_dir = false, delete_trg_if_exists = true;
|
||||
public byte Term_cmd_for_src() {return term_cmd_for_src;} public void Term_cmd_for_src_(byte v) {term_cmd_for_src = v;} private byte term_cmd_for_src = Term_cmd_for_src_delete;
|
||||
public Io_url Term_cmd_for_src_url() {return term_cmd_for_src_url;} public void Term_cmd_for_src_url_(Io_url v) {this.term_cmd_for_src_url = v;} Io_url term_cmd_for_src_url = Io_url_.Null;
|
||||
public Io_url Term_cmd_for_src_url() {return term_cmd_for_src_url;} public void Term_cmd_for_src_url_(Io_url v) {this.term_cmd_for_src_url = v;} Io_url term_cmd_for_src_url = Io_url_.Empty;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_owner)) return owner;
|
||||
else if (ctx.Match(k, Invk_src_)) src = Bry_fmtr_eval_mgr_.Eval_url(url_eval_mgr, m.ReadBry("v"));
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.core.threads; import gplx.*; import gplx.core.*;
|
||||
public class Gfo_thread_pool implements GfoInvkAble {
|
||||
private Object thread_lock = new Object();
|
||||
private ListAdp queue = ListAdp_.new_();
|
||||
private List_adp queue = List_adp_.new_();
|
||||
private GfoMsg run_msg = GfoMsg_.new_cast_(Invk_run_wkr);
|
||||
private boolean running = false;
|
||||
public Gfo_usr_dlg Usr_dlg() {return usr_dlg;} public Gfo_thread_pool Usr_dlg_(Gfo_usr_dlg v) {usr_dlg = v; return this;} private Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Noop;
|
||||
@@ -39,7 +39,7 @@ public class Gfo_thread_pool implements GfoInvkAble {
|
||||
if (running) return; // already running; discard run request and rely on running-wkr to call Run when done
|
||||
int len = queue.Count(); if (len == 0) return; // nothing in list; occurs when last item calls Run when done
|
||||
running = true;
|
||||
wkr = (Gfo_thread_wkr)ListAdp_.Pop_first(queue);
|
||||
wkr = (Gfo_thread_wkr)List_adp_.Pop_first(queue);
|
||||
}
|
||||
Thread_adp_.Run_invk_msg(wkr.Name(), this, run_msg.Clear().Add("v", wkr));
|
||||
}
|
||||
|
||||
@@ -17,10 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.xmls; import gplx.*; import gplx.core.*;
|
||||
public class Gfo_xml_wtr {
|
||||
private final Bry_bfr bfr = Bry_bfr.reset_(255);
|
||||
private byte quote_byte = Byte_ascii.Quote;
|
||||
private byte[] quote_escape = Bry_quote_2_escape;
|
||||
private String nde_cur = null;
|
||||
private final Bry_bfr bfr = Bry_bfr.reset_(255), txt_bfr = Bry_bfr.reset_(32);
|
||||
private byte quote_byte = Byte_ascii.Apos;
|
||||
private byte[] quote_escape = Bry_quote_1_escape;
|
||||
private List_adp nde_stack = List_adp_.new_();
|
||||
private Gfo_xml_nde nde_cur = null;
|
||||
private int indent = 0;
|
||||
public void Quote_(boolean apos) {
|
||||
if (apos) {
|
||||
this.quote_byte = Byte_ascii.Apos;
|
||||
@@ -31,27 +33,59 @@ public class Gfo_xml_wtr {
|
||||
this.quote_escape = Bry_quote_2_escape;
|
||||
}
|
||||
}
|
||||
public Gfo_xml_wtr Nde_lhs_bgn(String v) {
|
||||
this.nde_cur = v;
|
||||
bfr.Add_byte(Byte_ascii.Angle_bgn).Add_str_utf8(nde_cur);
|
||||
public Gfo_xml_wtr Nde_lhs_bgn_grp(String v) {return Nde_lhs_bgn(Bool_.Y, v);}
|
||||
public Gfo_xml_wtr Nde_lhs_bgn_itm(String v) {return Nde_lhs_bgn(Bool_.N, v);}
|
||||
private Gfo_xml_wtr Nde_lhs_bgn(boolean grp, String v) {
|
||||
nde_cur = new Gfo_xml_nde(grp, v);
|
||||
nde_stack.Add(nde_cur);
|
||||
bfr.Add_byte_repeat(Byte_ascii.Space, indent);
|
||||
bfr.Add_byte(Byte_ascii.Angle_bgn).Add_str_u8(v);
|
||||
indent += 2;
|
||||
return this;
|
||||
}
|
||||
public Gfo_xml_wtr Nde_lhs_end() {
|
||||
bfr.Add_byte(Byte_ascii.Angle_end);
|
||||
if (nde_cur.Grp()) bfr.Add_byte_nl();
|
||||
return this;
|
||||
}
|
||||
public Gfo_xml_wtr Nde_lhs(String v) {return Nde_lhs(Bool_.Y, v);}
|
||||
private Gfo_xml_wtr Nde_lhs(boolean grp, String v) {
|
||||
this.Nde_lhs_bgn(grp, v);
|
||||
this.Nde_lhs_end();
|
||||
return this;
|
||||
}
|
||||
public Gfo_xml_wtr Nde_lhs(String v) {this.Nde_lhs_bgn(v); this.Nde_lhs_end(); return this;}
|
||||
public Gfo_xml_wtr Nde_rhs() {
|
||||
bfr.Add(Bry_nde_rhs_bgn).Add_str_utf8(nde_cur).Add_byte(Byte_ascii.Angle_end); // EX: </node>
|
||||
this.nde_cur = null;
|
||||
Gfo_xml_nde nde = (Gfo_xml_nde)List_adp_.Pop(nde_stack);
|
||||
indent -= 2;
|
||||
if (nde.Grp()) bfr.Add_byte_repeat(Byte_ascii.Space, indent);
|
||||
bfr.Add(Bry_nde_rhs_bgn).Add_str_u8(nde.Name()).Add_byte(Byte_ascii.Angle_end); // EX: </node>
|
||||
bfr.Add_byte_nl();
|
||||
return this;
|
||||
}
|
||||
public Gfo_xml_wtr Nde_txt_str(String name, String text) {
|
||||
this.Nde_lhs(Bool_.N, name);
|
||||
this.Txt_str_u8(text);
|
||||
this.Nde_rhs();
|
||||
return this;
|
||||
}
|
||||
public Gfo_xml_wtr Nde_txt_bry(String name, byte[] text) {
|
||||
this.Nde_lhs(Bool_.N, name);
|
||||
this.Txt_bry(text);
|
||||
this.Nde_rhs();
|
||||
return this;
|
||||
}
|
||||
public Gfo_xml_wtr Nde_txt_int(String name, int text) {
|
||||
this.Nde_lhs(Bool_.N, name);
|
||||
this.Txt_bry(Int_.Xto_bry(text));
|
||||
this.Nde_rhs();
|
||||
return this;
|
||||
}
|
||||
public Gfo_xml_wtr Atr_bgn(String key) {
|
||||
bfr.Add_byte_space().Add_str_utf8(key).Add_byte(Byte_ascii.Eq).Add_byte(quote_byte);
|
||||
bfr.Add_byte_space().Add_str_u8(key).Add_byte(Byte_ascii.Eq).Add_byte(quote_byte);
|
||||
return this;
|
||||
}
|
||||
public Gfo_xml_wtr Atr_val_str_a7(String v) {bfr.Add_str_ascii(v); return this;}
|
||||
public Gfo_xml_wtr Atr_val_str_u8(String v) {bfr.Add_str_utf8 (v); return this;}
|
||||
public Gfo_xml_wtr Atr_val_str_a7(String v) {bfr.Add_str_a7(v); return this;}
|
||||
public Gfo_xml_wtr Atr_val_str_u8(String v) {bfr.Add_str_u8 (v); return this;}
|
||||
public Gfo_xml_wtr Atr_val_bry (byte[] v) {bfr.Add(v); return this;}
|
||||
public Gfo_xml_wtr Atr_val_int (int v) {bfr.Add_int_variable(v); return this;}
|
||||
public Gfo_xml_wtr Atr_end() {
|
||||
@@ -59,27 +93,59 @@ public class Gfo_xml_wtr {
|
||||
return this;
|
||||
}
|
||||
public Gfo_xml_wtr Atr_kv_int(String key, int val) {return Atr_kv_bry(key, Int_.Xto_bry(val));}
|
||||
public Gfo_xml_wtr Atr_kv_str_a7(String key, String val) {return Atr_kv_bry(key, Bry_.new_ascii_(val));}
|
||||
public Gfo_xml_wtr Atr_kv_str_u8(String key, String val) {return Atr_kv_bry(key, Bry_.new_utf8_(val));}
|
||||
public Gfo_xml_wtr Atr_kv_str_a7(String key, String val) {return Atr_kv_bry(key, Bry_.new_a7(val));}
|
||||
public Gfo_xml_wtr Atr_kv_str_u8(String key, String val) {return Atr_kv_bry(key, Bry_.new_u8(val));}
|
||||
public Gfo_xml_wtr Atr_kv_bry(String key, byte[] val) {
|
||||
bfr.Add_byte_space().Add_str_utf8(key);
|
||||
bfr.Add_byte_space().Add_str_u8(key);
|
||||
bfr.Add_byte(Byte_ascii.Eq);
|
||||
Atr_val_quote(val);
|
||||
return this;
|
||||
}
|
||||
private void Atr_val_quote(byte[] val_bry) {
|
||||
private Gfo_xml_wtr Atr_val_quote(byte[] val_bry) {
|
||||
bfr.Add_byte(quote_byte);
|
||||
bfr.Add_bry_escape(quote_byte, quote_escape, val_bry, 0, val_bry.length);
|
||||
bfr.Add_byte(quote_byte);
|
||||
return this;
|
||||
}
|
||||
public void Txt_bry(byte[] txt) {
|
||||
bfr.Add(txt);
|
||||
public Gfo_xml_wtr Txt_bry(byte[] txt) {
|
||||
int len = txt.length;
|
||||
boolean dirty = false;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
byte[] escape = null;
|
||||
byte b = txt[i];
|
||||
switch (b) {
|
||||
case Byte_ascii.Lt: escape = Bry_escape_lt; break;
|
||||
case Byte_ascii.Gt: escape = Bry_escape_gt; break;
|
||||
case Byte_ascii.Amp: escape = Bry_escape_amp; break;
|
||||
default: break;
|
||||
}
|
||||
if (escape != null && !dirty) {
|
||||
bfr.Add_mid(txt, 0, i);
|
||||
dirty = true;
|
||||
}
|
||||
if (dirty) {
|
||||
if (escape == null) bfr.Add_byte(b);
|
||||
else bfr.Add(escape);
|
||||
}
|
||||
}
|
||||
if (dirty) bfr.Add_bfr_and_clear(txt_bfr);
|
||||
else bfr.Add(txt);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Gfo_xml_wtr Txt_str_u8(String txt) {return Txt_bry(Bry_.new_u8(txt));}
|
||||
public String Bld_str() {return bfr.Xto_str_and_clear();}
|
||||
private static final byte[]
|
||||
Bry_nde_rhs_bgn = Bry_.new_ascii_("</")
|
||||
// , Bry_nde_inline = Bry_.new_ascii_("/>")
|
||||
, Bry_quote_1_escape = Bry_.new_ascii_("'")
|
||||
, Bry_quote_2_escape = Bry_.new_ascii_(""")
|
||||
Bry_nde_rhs_bgn = Bry_.new_a7("</")
|
||||
// , Bry_nde_inline = Bry_.new_a7("/>")
|
||||
, Bry_quote_1_escape = Bry_.new_a7("'")
|
||||
, Bry_quote_2_escape = Bry_.new_a7(""")
|
||||
, Bry_escape_lt = Bry_.new_a7("<")
|
||||
, Bry_escape_gt = Bry_.new_a7(">")
|
||||
, Bry_escape_amp = Bry_.new_a7("&")
|
||||
;
|
||||
}
|
||||
class Gfo_xml_nde {
|
||||
public Gfo_xml_nde(boolean grp, String name) {this.grp = grp; this.name = name;}
|
||||
public boolean Grp() {return grp;} private final boolean grp;
|
||||
public String Name() {return name;} private final String name;
|
||||
}
|
||||
|
||||
81
400_xowa/src/gplx/core/xmls/Gfo_xml_wtr_tst.java
Normal file
81
400_xowa/src/gplx/core/xmls/Gfo_xml_wtr_tst.java
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
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.core.xmls; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class Gfo_xml_wtr_tst {
|
||||
private final Gfo_xml_wtr_fxt fxt = new Gfo_xml_wtr_fxt();
|
||||
@Before public void init() {}
|
||||
@Test public void Root() {
|
||||
fxt.Wtr().Nde_lhs("a").Nde_rhs();
|
||||
fxt.Test_bld("<a>", "</a>");
|
||||
}
|
||||
@Test public void Nest() {
|
||||
fxt.Wtr()
|
||||
.Nde_lhs("a")
|
||||
. Nde_lhs("a_a")
|
||||
. Nde_lhs("a_a_a")
|
||||
. Nde_rhs()
|
||||
. Nde_rhs()
|
||||
.Nde_rhs()
|
||||
;
|
||||
fxt.Test_bld
|
||||
( "<a>"
|
||||
, " <a_a>"
|
||||
, " <a_a_a>"
|
||||
, " </a_a_a>"
|
||||
, " </a_a>"
|
||||
, "</a>"
|
||||
);
|
||||
}
|
||||
@Test public void Atrs() {
|
||||
fxt.Wtr()
|
||||
.Nde_lhs_bgn_itm("a")
|
||||
.Atr_kv_str_a7("b", "b1")
|
||||
.Nde_lhs_end()
|
||||
.Nde_rhs()
|
||||
;
|
||||
fxt.Test_bld("<a b='b1'></a>");
|
||||
}
|
||||
@Test public void Atrs_escape() {
|
||||
fxt.Wtr()
|
||||
.Nde_lhs_bgn_itm("a")
|
||||
.Atr_kv_str_a7("b", "'\"<>&")
|
||||
.Nde_lhs_end()
|
||||
.Nde_rhs()
|
||||
;
|
||||
fxt.Test_bld("<a b=''\"<>&'></a>");
|
||||
}
|
||||
@Test public void Nde_txt() {
|
||||
fxt.Wtr()
|
||||
.Nde_txt_str("a", "a123")
|
||||
;
|
||||
fxt.Test_bld("<a>a123</a>");
|
||||
}
|
||||
@Test public void Nde_txt_escape() {
|
||||
fxt.Wtr()
|
||||
.Nde_txt_str("a", "'\"<>&x")
|
||||
;
|
||||
fxt.Test_bld("<a>'\"<>&x</a>");
|
||||
}
|
||||
}
|
||||
class Gfo_xml_wtr_fxt {
|
||||
public Gfo_xml_wtr Wtr() {return wtr;} private final Gfo_xml_wtr wtr = new Gfo_xml_wtr();
|
||||
public void Test_bld(String... lines) {
|
||||
Tfds.Eq_str_lines(String_.Concat_lines_nl_skip_last(lines), wtr.Bld_str());
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import gplx.dbs.engines.sqlite.*;
|
||||
public class Db_attach_cmd {
|
||||
private final boolean diff_db;
|
||||
private final Db_conn conn; private final String attach_name; private final Io_url attach_url;
|
||||
private final ListAdp sql_list = ListAdp_.new_();
|
||||
private final List_adp sql_list = List_adp_.new_();
|
||||
Db_attach_cmd(Db_conn conn, String attach_name, Io_url attach_url) {
|
||||
this.conn = conn; this.attach_name = attach_name; this.attach_url = attach_url;
|
||||
Sqlite_conn_info conn_info = (Sqlite_conn_info)conn.Conn_info();
|
||||
@@ -38,7 +38,7 @@ public class Db_attach_cmd {
|
||||
conn.Txn_bgn(attach_name); // NOTE: BEGIN TRAN must occur after ATTACH else sqlite will throw error
|
||||
int len = sql_list.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Db_exec_sql_by_attach_itm itm = (Db_exec_sql_by_attach_itm)sql_list.FetchAt(i);
|
||||
Db_exec_sql_by_attach_itm itm = (Db_exec_sql_by_attach_itm)sql_list.Get_at(i);
|
||||
usr_dlg.Plog_many("", "", itm.Msg());
|
||||
conn.Exec_sql(itm.Sql());
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.cfgs; import gplx.*; import gplx.dbs.*;
|
||||
public class Db_cfg_hash {
|
||||
private final String grp; private final OrderedHash hash = OrderedHash_.new_();
|
||||
private final String grp; private final Ordered_hash hash = Ordered_hash_.new_();
|
||||
public Db_cfg_hash(String grp) {this.grp = grp;}
|
||||
public int Len() {return hash.Count();}
|
||||
public Db_cfg_itm Get_at(int i) {return (Db_cfg_itm)hash.FetchAt(i);}
|
||||
public Db_cfg_itm Get_at(int i) {return (Db_cfg_itm)hash.Get_at(i);}
|
||||
public Db_cfg_itm Get(String key) {
|
||||
Db_cfg_itm rv = (Db_cfg_itm)hash.Fetch(key);
|
||||
Db_cfg_itm rv = (Db_cfg_itm)hash.Get_by(key);
|
||||
return rv == null ? Db_cfg_itm.Empty : rv;
|
||||
}
|
||||
public void Set(String key, String val) {hash.Del(key); Add(key, val);}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class Db_cfg_itm {
|
||||
public String Key() {return key;} private final String key;
|
||||
public String Val() {return val;} public Db_cfg_itm Val_(String v) {val = v; return this;} private String val;
|
||||
public String To_str_or(String or) {return val == null ? or : val;}
|
||||
public byte[] To_bry_or(byte[] or) {try {return val == null ? or : Bry_.new_utf8_(val) ;} catch (Exception e) {throw err_parse(e, Bry_.Cls_val_name);}}
|
||||
public byte[] To_bry_or(byte[] or) {try {return val == null ? or : Bry_.new_u8(val) ;} catch (Exception e) {throw err_parse(e, Bry_.Cls_val_name);}}
|
||||
public int To_int_or(int or) {try {return val == null ? or : Int_.parse_or_(val, or) ;} catch (Exception e) {throw err_parse(e, Int_.Cls_val_name);}}
|
||||
public long To_long_or(long or) {try {return val == null ? or : Long_.parse_or_(val, or) ;} catch (Exception e) {throw err_parse(e, Long_.Cls_val_name);}}
|
||||
public byte To_byte_or(byte or) {try {return val == null ? or : Byte_.parse_or_(val, or) ;} catch (Exception e) {throw err_parse(e, Byte_.Cls_val_name);}}
|
||||
@@ -40,8 +40,8 @@ public class Db_cfg_itm {
|
||||
private static final String Grp_none = "";
|
||||
public static Db_cfg_itm new_str (String key, String val) {return new Db_cfg_itm(Grp_none , key, val);}
|
||||
public static Db_cfg_itm new_str (String grp, String key, String val) {return new Db_cfg_itm(grp , key, val);}
|
||||
public static Db_cfg_itm new_bry (String key, byte[] val) {return new Db_cfg_itm(Grp_none , key, String_.new_utf8_(val));}
|
||||
public static Db_cfg_itm new_bry (String grp, String key, byte[] val) {return new Db_cfg_itm(grp , key, String_.new_utf8_(val));}
|
||||
public static Db_cfg_itm new_bry (String key, byte[] val) {return new Db_cfg_itm(Grp_none , key, String_.new_u8(val));}
|
||||
public static Db_cfg_itm new_bry (String grp, String key, byte[] val) {return new Db_cfg_itm(grp , key, String_.new_u8(val));}
|
||||
public static Db_cfg_itm new_int (String key, int val) {return new Db_cfg_itm(Grp_none , key, Int_.Xto_str(val));}
|
||||
public static Db_cfg_itm new_int (String grp, String key, int val) {return new Db_cfg_itm(grp , key, Int_.Xto_str(val));}
|
||||
public static Db_cfg_itm new_long (String key, long val) {return new Db_cfg_itm(Grp_none , key, Long_.Xto_str(val));}
|
||||
|
||||
@@ -44,10 +44,12 @@ public class Db_cfg_tbl implements RlsAble {
|
||||
public void Insert_long (String grp, String key, long val) {Insert_str(grp, key, Long_.Xto_str(val));}
|
||||
public void Insert_date (String grp, String key, DateAdp val) {Insert_str(grp, key, val.XtoStr_fmt_yyyyMMdd_HHmmss());}
|
||||
public void Insert_guid (String grp, String key, Guid_adp val) {Insert_str(grp, key, val.XtoStr());}
|
||||
public void Insert_bry (String grp, String key, byte[] val) {Insert_str(grp, key, String_.new_utf8_(val));}
|
||||
public void Insert_bry (String grp, String key, byte[] val) {Insert_str(grp, key, String_.new_u8(val));}
|
||||
public void Insert_str (String grp, String key, String val) {
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
stmt_insert.Clear().Val_str(fld_grp, grp).Val_str(fld_key, key).Val_str(fld_val, val).Exec_insert();
|
||||
try {
|
||||
stmt_insert.Clear().Val_str(fld_grp, grp).Val_str(fld_key, key).Val_str(fld_val, val).Exec_insert();
|
||||
} catch (Exception e) {throw Err_.new_("db_cfg.insert failed: grp={0} key={1} val={2} db={3} err={4}", grp, key, val, conn.Conn_info().Xto_api(), Err_.Message_lang(e));}
|
||||
}
|
||||
public void Update_yn (String grp, String key, boolean val) {Update_str(grp, key, val ? "y" : "n");}
|
||||
public void Update_byte (String grp, String key, byte val) {Update_str(grp, key, Byte_.Xto_str(val));}
|
||||
@@ -55,7 +57,7 @@ public class Db_cfg_tbl implements RlsAble {
|
||||
public void Update_long (String grp, String key, long val) {Update_str(grp, key, Long_.Xto_str(val));}
|
||||
public void Update_date (String grp, String key, DateAdp val) {Update_str(grp, key, val.XtoStr_fmt_yyyyMMdd_HHmmss());}
|
||||
public void Update_guid (String grp, String key, Guid_adp val) {Update_str(grp, key, val.XtoStr());}
|
||||
public void Update_bry (String grp, String key, byte[] val) {Update_str(grp, key, String_.new_utf8_(val));}
|
||||
public void Update_bry (String grp, String key, byte[] val) {Update_str(grp, key, String_.new_u8(val));}
|
||||
public void Update_str (String grp, String key, String val) {
|
||||
if (stmt_update == null) stmt_update = conn.Stmt_update_exclude(tbl_name, flds, fld_grp, fld_key);
|
||||
stmt_update.Clear().Val_str(fld_val, val).Crt_str(fld_grp, grp).Crt_str(fld_key, key).Exec_update();
|
||||
@@ -114,7 +116,7 @@ public class Db_cfg_tbl implements RlsAble {
|
||||
private byte Parse_byte (String grp, String key, String val) {try {return Byte_.parse_(val) ;} catch (Exception e) {throw err_parse(e, grp, key, val, Byte_.Cls_val_name);}}
|
||||
private int Parse_int (String grp, String key, String val) {try {return Int_.parse_(val) ;} catch (Exception e) {throw err_parse(e, grp, key, val, Int_.Cls_val_name);}}
|
||||
private long Parse_long (String grp, String key, String val) {try {return Long_.parse_(val) ;} catch (Exception e) {throw err_parse(e, grp, key, val, Long_.Cls_val_name);}}
|
||||
private byte[] Parse_bry (String grp, String key, String val) {try {return Bry_.new_utf8_(val) ;} catch (Exception e) {throw err_parse(e, grp, key, val, Bry_.Cls_val_name);}}
|
||||
private byte[] Parse_bry (String grp, String key, String val) {try {return Bry_.new_u8(val) ;} catch (Exception e) {throw err_parse(e, grp, key, val, Bry_.Cls_val_name);}}
|
||||
private DateAdp Parse_date (String grp, String key, String val) {try {return DateAdp_.parse_gplx(val) ;} catch (Exception e) {throw err_parse(e, grp, key, val, DateAdp_.Cls_ref_name);}}
|
||||
private Guid_adp Parse_guid (String grp, String key, String val) {try {return Guid_adp_.parse_(val) ;} catch (Exception e) {throw err_parse(e, grp, key, val, Guid_adp_.Cls_ref_name);}}
|
||||
private Err err_parse(Exception e, String grp, String key, String val, String type) {return Err_.new_("cfg.val is not parseable; grp={0} key={1} val={2} type={3}", grp, key, val, type);}
|
||||
|
||||
@@ -17,8 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.schemas; import gplx.*; import gplx.dbs.*;
|
||||
public class Schema_tbl_mgr {
|
||||
private OrderedHash hash = OrderedHash_.new_();
|
||||
private Ordered_hash hash = Ordered_hash_.new_();
|
||||
public void Add(Schema_tbl_itm itm) {hash.Add(itm.Name(), itm);}
|
||||
public boolean Has(String name) {return hash.Has(name);}
|
||||
public Schema_tbl_itm Get(String name) {return (Schema_tbl_itm)hash.Fetch(name);}
|
||||
public Schema_tbl_itm Get(String name) {return (Schema_tbl_itm)hash.Get_by(name);}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.schemas.updates; import gplx.*; import gplx.dbs.*; import gplx.dbs.schemas.*;
|
||||
public class Schema_update_mgr {
|
||||
private ListAdp cmds = ListAdp_.new_();
|
||||
private List_adp cmds = List_adp_.new_();
|
||||
public void Add(Schema_update_cmd cmd) {cmds.Add(cmd);}
|
||||
public void Update(Schema_db_mgr schema_mgr, Db_conn conn) {
|
||||
int cmds_len = cmds.Count();
|
||||
for (int i = 0; i < cmds_len; ++i) {
|
||||
Schema_update_cmd cmd = (Schema_update_cmd)cmds.FetchAt(i);
|
||||
Schema_update_cmd cmd = (Schema_update_cmd)cmds.Get_at(i);
|
||||
try {cmd.Exec(schema_mgr, conn);}
|
||||
catch (Exception e) {
|
||||
Gfo_usr_dlg_.I.Warn_many("", "", "failed to run update cmd; name=~{0} err=~{1}", cmd.Name(), Err_.Message_gplx_brief(e));
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.fsdb; import gplx.*;
|
||||
import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.fsdb.meta.*; import gplx.fsdb.data.*; import gplx.xowa.files.origs.*;
|
||||
import gplx.xowa.*; import gplx.xowa.wikis.data.*; import gplx.xowa.bldrs.infos.*;
|
||||
public class Fsdb_db_mgr__v2_bldr {
|
||||
public Fsdb_db_mgr__v2 Make(Xowe_wiki wiki, boolean delete_if_exists) {
|
||||
public Fsdb_db_mgr__v2 Get_or_make(Xow_wiki wiki, boolean delete_if_exists) { // NOTE: must check if file exists else imports with existing v2 dbs will fail; DATE:2015-05-23
|
||||
Xowd_db_layout layout = wiki.Data_mgr__core_mgr().Props().Layout_file();
|
||||
String domain_str = wiki.Domain_str();
|
||||
Io_url wiki_dir = wiki.Fsys_mgr().Root_dir();
|
||||
@@ -30,14 +30,15 @@ public class Fsdb_db_mgr__v2_bldr {
|
||||
if (delete_if_exists) {
|
||||
Db_conn_bldr.I.Get_or_noop(main_core_url).Rls_conn();
|
||||
Db_conn_bldr.I.Get_or_noop(user_core_url).Rls_conn();
|
||||
Io_mgr._.DeleteFil(main_core_url);
|
||||
Io_mgr._.DeleteFil(user_core_url);
|
||||
Io_mgr.I.DeleteFil(main_core_url);
|
||||
Io_mgr.I.DeleteFil(user_core_url);
|
||||
}
|
||||
Fsdb_db_file main_core_file = Make_core_file_main(wiki, main_core_url, main_core_name, layout);
|
||||
Fsdb_db_file user_core_file = Make_core_file_user(wiki, user_core_url, user_core_name, main_core_name);
|
||||
Fsdb_db_file main_core_file = Io_mgr.I.ExistsFil(main_core_url) ? Load_core_file(main_core_url) : Make_core_file_main(wiki, main_core_url, main_core_name, layout);
|
||||
Fsdb_db_file user_core_file = Io_mgr.I.ExistsFil(user_core_url) ? Load_core_file(user_core_url) : Make_core_file_user(wiki, user_core_url, user_core_name, main_core_name);
|
||||
return new Fsdb_db_mgr__v2(layout, wiki_dir, main_core_file, user_core_file);
|
||||
}
|
||||
private Fsdb_db_file Make_core_file_main(Xowe_wiki wiki, Io_url main_core_url, String main_core_name, Xowd_db_layout layout) {
|
||||
private Fsdb_db_file Load_core_file(Io_url url) {return new Fsdb_db_file(url, Db_conn_bldr.I.Get(url));}
|
||||
private Fsdb_db_file Make_core_file_main(Xow_wiki wiki, Io_url main_core_url, String main_core_name, Xowd_db_layout layout) {
|
||||
Db_conn conn = layout.Tid_is_all() ? Db_conn_bldr.I.Get(main_core_url) : Db_conn_bldr.I.New(main_core_url); // if all, use existing (assumes same file name); else, create new
|
||||
conn.Txn_bgn();
|
||||
Fsdb_db_file rv = Make_core_file(main_core_url, conn, schema_is_1, Fsm_mnt_mgr.Mnt_idx_main);
|
||||
|
||||
@@ -60,7 +60,7 @@ public class Fsd_bin_tbl implements RlsAble {
|
||||
public boolean Select_to_url(int owner_id, Io_url url) {
|
||||
byte[] rv = Select(owner_id);
|
||||
if (rv == null) return false;
|
||||
Io_mgr._.SaveFilBry(url, rv);
|
||||
Io_mgr.I.SaveFilBry(url, rv);
|
||||
return true;
|
||||
}
|
||||
private byte[] Select(int owner_id) {
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Fsd_thm_itm {
|
||||
public int Dir_id() {return dir_id;} private int dir_id;
|
||||
public int Fil_id() {return fil_id;} private int fil_id;
|
||||
public int Thm_id() {return thm_id;} private int thm_id;
|
||||
public int Db_bin_id() {return bin_db_id;} private int bin_db_id;
|
||||
public int Bin_db_id() {return bin_db_id;} private int bin_db_id;
|
||||
public int W() {return w;} private int w;
|
||||
public int H() {return h;} private int h;
|
||||
public double Time() {return time;} private double time;
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.dbs.*; import gplx.fsdb.meta.*; import gplx.xowa.files.*;
|
||||
public class Fsd_thm_tbl implements RlsAble {
|
||||
private final String tbl_name; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_id, fld_owner_id, fld_w, fld_h, fld_time, fld_page, fld_bin_db_id, fld_size, fld_modified, fld_hash;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert, stmt_select_by_fil_w; private int mnt_id; private boolean schema_thm_page;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert, stmt_select_by_fil_exact, stmt_select_by_fil_near; private int mnt_id; private boolean schema_thm_page;
|
||||
public Fsd_thm_tbl(Db_conn conn, boolean schema_is_1, int mnt_id, boolean schema_thm_page) {
|
||||
this.conn = conn; this.mnt_id = mnt_id; this.schema_thm_page = schema_thm_page;
|
||||
this.tbl_name = schema_is_1 ? "fsdb_xtn_thm" : "fsdb_thm";
|
||||
@@ -44,7 +44,8 @@ public class Fsd_thm_tbl implements RlsAble {
|
||||
}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
stmt_select_by_fil_w = Db_stmt_.Rls(stmt_select_by_fil_w);
|
||||
stmt_select_by_fil_exact = Db_stmt_.Rls(stmt_select_by_fil_exact);
|
||||
stmt_select_by_fil_near = Db_stmt_.Rls(stmt_select_by_fil_near);
|
||||
}
|
||||
public void Create_tbl() {
|
||||
conn.Ddl_create_tbl(Db_meta_tbl.new_(tbl_name, flds
|
||||
@@ -71,17 +72,17 @@ public class Fsd_thm_tbl implements RlsAble {
|
||||
.Val_str(fld_hash, Hash_null)
|
||||
.Exec_insert();
|
||||
}
|
||||
public boolean Select_itm_by_fil_width(int dir_id, int fil_id, Fsd_thm_itm thm) {
|
||||
if (stmt_select_by_fil_w == null) stmt_select_by_fil_w = conn.Stmt_select(tbl_name, flds, String_.Ary_wo_null(fld_owner_id, fld_w, fld_time, fld_page));
|
||||
stmt_select_by_fil_w.Clear().Crt_int(fld_owner_id, fil_id).Crt_int(fld_w, thm.W());
|
||||
public boolean Select_itm_by_w_exact(int dir_id, int fil_id, Fsd_thm_itm thm) {
|
||||
if (stmt_select_by_fil_exact == null) stmt_select_by_fil_exact = conn.Stmt_select(tbl_name, flds, String_.Ary_wo_null(fld_owner_id, fld_w, fld_time, fld_page));
|
||||
stmt_select_by_fil_exact.Clear().Crt_int(fld_owner_id, fil_id).Crt_int(fld_w, thm.W());
|
||||
if (schema_thm_page) {
|
||||
stmt_select_by_fil_w.Crt_double (fld_time, Xof_lnki_time.Db_save_double(thm.Time()));
|
||||
stmt_select_by_fil_w.Crt_int (fld_page, Xof_lnki_page.Db_save_int(thm.Page()));
|
||||
stmt_select_by_fil_exact.Crt_double (fld_time, Xof_lnki_time.Db_save_double(thm.Time()));
|
||||
stmt_select_by_fil_exact.Crt_int (fld_page, Xof_lnki_page.Db_save_int(thm.Page()));
|
||||
}
|
||||
else {
|
||||
stmt_select_by_fil_w.Crt_int (fld_time, Xof_lnki_time.Db_save_int(thm.Time()));
|
||||
stmt_select_by_fil_exact.Crt_int (fld_time, Xof_lnki_time.Db_save_int(thm.Time()));
|
||||
}
|
||||
Db_rdr rdr = stmt_select_by_fil_w.Exec_select__rls_manual();
|
||||
Db_rdr rdr = stmt_select_by_fil_exact.Exec_select__rls_manual();
|
||||
try {
|
||||
return rdr.Move_next()
|
||||
? Ctor_by_load(thm, rdr, dir_id)
|
||||
@@ -89,10 +90,10 @@ public class Fsd_thm_tbl implements RlsAble {
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public boolean Select_itm_by_fil_width2(int dir_id, int fil_id, Fsd_thm_itm thm) {
|
||||
if (stmt_select_by_fil_w == null) stmt_select_by_fil_w = conn.Stmt_select(tbl_name, flds, fld_owner_id);
|
||||
ListAdp list = ListAdp_.new_();
|
||||
Db_rdr rdr = stmt_select_by_fil_w.Clear().Crt_int(fld_owner_id, thm.Fil_id()).Exec_select__rls_manual();
|
||||
public boolean Select_itm_by_w_near(int dir_id, int fil_id, Fsd_thm_itm thm) {
|
||||
if (stmt_select_by_fil_near == null) stmt_select_by_fil_near = conn.Stmt_select(tbl_name, flds, fld_owner_id);
|
||||
List_adp list = List_adp_.new_();
|
||||
Db_rdr rdr = stmt_select_by_fil_near.Clear().Crt_int(fld_owner_id, fil_id).Exec_select__rls_manual();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
Fsd_thm_itm itm = Fsd_thm_itm.new_();
|
||||
@@ -127,13 +128,13 @@ public class Fsd_thm_tbl implements RlsAble {
|
||||
}
|
||||
public static final DateAdp Modified_null = null;
|
||||
public static final String Hash_null = "", Modified_null_str = "";
|
||||
public static boolean Match_nearest(ListAdp list, Fsd_thm_itm thm, boolean schema_thm_page) {
|
||||
public static boolean Match_nearest(List_adp list, Fsd_thm_itm thm, boolean schema_thm_page) {
|
||||
int len = list.Count(); if (len == 0) return Bool_.N;
|
||||
list.SortBy(Fsdb_thm_itm_sorter.I);
|
||||
list.Sort_by(Fsdb_thm_itm_sorter.I);
|
||||
int thm_w = thm.W(), thm_page = thm.Page(); double thm_time = thm.Time();
|
||||
Fsd_thm_itm max = null;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Fsd_thm_itm comp = (Fsd_thm_itm)list.FetchAt(i);
|
||||
Fsd_thm_itm comp = (Fsd_thm_itm)list.Get_at(i);
|
||||
int comp_w = comp.W();
|
||||
int comp_page = schema_thm_page ? comp.Page() : thm_page;
|
||||
if ( thm_w == comp_w
|
||||
@@ -143,7 +144,8 @@ public class Fsd_thm_tbl implements RlsAble {
|
||||
thm.Init_by_match(comp);
|
||||
return Bool_.Y;
|
||||
}
|
||||
if (comp_w > thm_w) max = comp;
|
||||
if (comp_w > thm_w) max = comp;
|
||||
else if (max == null) max = comp;
|
||||
else break;
|
||||
}
|
||||
if (max == null) return Bool_.N;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Fsd_thm_tbl_tst {
|
||||
fxt.Test_match_nearest_itm(fxt.Make(100), fxt.Make(100));
|
||||
fxt.Test_match_nearest_itm(fxt.Make(350), fxt.Make(400));
|
||||
fxt.Test_match_nearest_itm(fxt.Make(150), fxt.Make(200));
|
||||
fxt.Test_match_nearest_itm(fxt.Make(500), Fsd_thm_itm.Null);
|
||||
fxt.Test_match_nearest_itm(fxt.Make(999), fxt.Make(400));
|
||||
}
|
||||
@Test public void Empty() {
|
||||
fxt.Init_list(); // no items
|
||||
@@ -34,7 +34,7 @@ public class Fsd_thm_tbl_tst {
|
||||
}
|
||||
}
|
||||
class Fsd_thm_tbl_fxt {
|
||||
private final ListAdp list = ListAdp_.new_();
|
||||
private final List_adp list = List_adp_.new_();
|
||||
public void Clear() {list.Clear();}
|
||||
public Fsd_thm_itm Make(int w) {
|
||||
double time = gplx.xowa.files.Xof_lnki_time.Null;
|
||||
@@ -43,7 +43,7 @@ class Fsd_thm_tbl_fxt {
|
||||
rv.Init_by_req(w, time, page);
|
||||
return rv;
|
||||
}
|
||||
public void Init_list(Fsd_thm_itm... ary) {list.AddMany((Object[])ary);}
|
||||
public void Init_list(Fsd_thm_itm... ary) {list.Add_many((Object[])ary);}
|
||||
public void Test_match_nearest_itm(Fsd_thm_itm req, Fsd_thm_itm expd) {
|
||||
Fsd_thm_tbl.Match_nearest(list, req, Bool_.Y);
|
||||
if (expd == Fsd_thm_itm.Null) {
|
||||
|
||||
@@ -36,7 +36,9 @@ public class Fsm_atr_fil {
|
||||
int dir_id = Get_dir_id_or_neg1(dir);
|
||||
return dir_id == Int_.Neg1 ? Fsd_fil_itm.Null : tbl_fil.Select_or_null(dir_id, fil);
|
||||
}
|
||||
public boolean Select_thm(Fsd_thm_itm rv, int dir_id, int fil_id) {return tbl_thm.Select_itm_by_fil_width(dir_id, fil_id, rv);}
|
||||
public boolean Select_thm(boolean exact, Fsd_thm_itm rv, int dir_id, int fil_id) {
|
||||
return exact ? tbl_thm.Select_itm_by_w_exact(dir_id, fil_id, rv) : tbl_thm.Select_itm_by_w_near(dir_id, fil_id, rv);
|
||||
}
|
||||
public int Insert_fil(Fsd_fil_itm rv, byte[] dir, byte[] fil, int ext_id, int bin_db_id, long bin_len, Io_stream_rdr bin_rdr) {
|
||||
int dir_id = Get_dir_id_or_make(dir);
|
||||
int fil_id = Get_fil_id_or_make(Tid_none, dir_id, fil, ext_id, bin_db_id, bin_len);
|
||||
|
||||
@@ -27,8 +27,8 @@ public class Fsm_atr_mgr {
|
||||
this.db__core = tbl.Select_1st_or_fail(mnt_itm, core_mgr, mnt_itm.Id(), schema_thm_page);
|
||||
}
|
||||
public Fsm_atr_fil Db__core() {return db__core;}
|
||||
public Fsd_fil_itm Select_fil_or_null(byte[] dir, byte[] fil) {return db__core.Select_fil_or_null(dir, fil);}
|
||||
public boolean Select_thm(Fsd_thm_itm rv, int dir_id, int fil_id) {return db__core.Select_thm(rv, dir_id, fil_id);}
|
||||
public Fsd_fil_itm Select_fil_or_null(byte[] dir, byte[] fil) {return db__core.Select_fil_or_null(dir, fil);}
|
||||
public boolean Select_thm(boolean exact, Fsd_thm_itm rv, int dir_id, int fil_id) {return db__core.Select_thm(exact, rv, dir_id, fil_id);}
|
||||
public void Txn_bgn() {db__core.Conn().Txn_bgn();}
|
||||
public void Txn_end() {db__core.Conn().Txn_end();}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class Fsm_bin_tbl {
|
||||
conn.Stmt_insert(tbl_name, flds).Crt_int(fld_uid, id).Val_str(fld_url, url_rel).Exec_insert();
|
||||
}
|
||||
public Fsm_bin_fil[] Select_all(Fsdb_db_mgr db_conn_mgr) {
|
||||
ListAdp rv = ListAdp_.new_();
|
||||
List_adp rv = List_adp_.new_();
|
||||
Db_rdr rdr = conn.Stmt_select_order(tbl_name, flds, Db_meta_fld.Ary_empy, fld_uid).Clear().Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
@@ -45,6 +45,6 @@ public class Fsm_bin_tbl {
|
||||
rv.Add(itm);
|
||||
}
|
||||
} finally {rdr.Rls();}
|
||||
return (Fsm_bin_fil[])rv.Xto_ary(Fsm_bin_fil.class);
|
||||
return (Fsm_bin_fil[])rv.To_ary(Fsm_bin_fil.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.fsdb.meta; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.fsdb.meta.*;
|
||||
public class Fsm_cfg_mgr {
|
||||
private final Db_cfg_tbl tbl; private final HashAdp grp_hash = HashAdp_.new_();
|
||||
private final Db_cfg_tbl tbl; private final Hash_adp grp_hash = Hash_adp_.new_();
|
||||
public Fsm_cfg_mgr(Fsdb_db_mgr db_conn_mgr, Db_conn conn) {
|
||||
this.tbl = new Db_cfg_tbl(conn, db_conn_mgr.File__cfg_tbl_name());
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public class Fsm_cfg_mgr {
|
||||
public boolean Patch__page_gt_1() {return patch__page_gt_1;} private boolean patch__page_gt_1 = false;
|
||||
public void Patch__save(String cfg_key) {tbl.Insert_yn(Fsm_cfg_mgr.Grp_core, cfg_key, Bool_.Y);}
|
||||
public Db_cfg_hash Grps_get_or_load(String grp_key) {
|
||||
Db_cfg_hash rv = (Db_cfg_hash)grp_hash.Fetch(grp_key);
|
||||
Db_cfg_hash rv = (Db_cfg_hash)grp_hash.Get_by(grp_key);
|
||||
if (rv == null) {
|
||||
rv = tbl.Select_as_hash(grp_key);
|
||||
grp_hash.Add(grp_key, rv);
|
||||
|
||||
@@ -38,10 +38,10 @@ public class Fsm_mnt_itm {
|
||||
if (!cfg_mgr.Patch_next_id()) Fsm_mnt_itm_.Patch_next_id(this, name);
|
||||
}
|
||||
public int Next_id() {return cfg_mgr.Next_id();}
|
||||
public Fsd_fil_itm Select_fil_or_null(byte[] dir, byte[] fil, boolean is_thumb, int width, double time) {return atr_mgr.Select_fil_or_null(dir, fil);}
|
||||
public boolean Select_thm(Fsd_thm_itm rv, byte[] dir, byte[] fil) {
|
||||
public Fsd_fil_itm Select_fil_or_null(byte[] dir, byte[] fil) {return atr_mgr.Select_fil_or_null(dir, fil);}
|
||||
public boolean Select_thm(boolean exact, Fsd_thm_itm rv, byte[] dir, byte[] fil) {
|
||||
Fsd_fil_itm fil_itm = atr_mgr.Select_fil_or_null(dir, fil);
|
||||
return fil_itm == Fsd_fil_itm.Null ? Bool_.N : atr_mgr.Select_thm(rv, fil_itm.Dir_id(), fil_itm.Fil_id());
|
||||
return fil_itm == Fsd_fil_itm.Null ? Bool_.N : atr_mgr.Select_thm(exact, rv, fil_itm.Dir_id(), fil_itm.Fil_id());
|
||||
}
|
||||
public void Insert_img(Fsd_img_itm rv, Fsm_atr_fil atr_fil, Fsm_bin_fil bin_fil, byte[] dir, byte[] fil, int ext_id, int img_w, int img_h, long bin_len, Io_stream_rdr bin_rdr) {
|
||||
int fil_id = atr_fil.Insert_img(rv, dir, fil, ext_id, img_w, img_h, bin_fil.Id(), bin_len, bin_rdr);
|
||||
|
||||
@@ -48,10 +48,10 @@ public class Fsm_mnt_mgr implements GfoInvkAble {
|
||||
cfg_tbl.Upsert_str(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_upright_use_thumb_w , "y");
|
||||
cfg_tbl.Upsert_str(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_upright_fix_default , "y");
|
||||
}
|
||||
public static void Patch_core(Db_cfg_tbl cfg_tbl) {
|
||||
cfg_tbl.Insert_int (Fsm_cfg_mgr.Grp_core, Fsm_cfg_mgr.Key_next_id , 1); // start next_id at 1
|
||||
cfg_tbl.Insert_yn (Fsm_cfg_mgr.Grp_core, Fsm_cfg_mgr.Key_schema_thm_page , Bool_.Y); // new dbs automatically have page and time in fsdb_xtn_tm
|
||||
cfg_tbl.Insert_yn (Fsm_cfg_mgr.Grp_core, Fsm_cfg_mgr.Key_patch__next_id , Bool_.Y); // new dbs automatically have correct next_id
|
||||
public static void Patch_core(Db_cfg_tbl cfg_tbl) { // NOTE: thes need to be upserts else upgrading will fail; DATE:2015-05-23
|
||||
cfg_tbl.Upsert_int (Fsm_cfg_mgr.Grp_core, Fsm_cfg_mgr.Key_next_id , 1); // start next_id at 1
|
||||
cfg_tbl.Upsert_yn (Fsm_cfg_mgr.Grp_core, Fsm_cfg_mgr.Key_schema_thm_page , Bool_.Y); // new dbs automatically have page and time in fsdb_xtn_tm
|
||||
cfg_tbl.Upsert_yn (Fsm_cfg_mgr.Grp_core, Fsm_cfg_mgr.Key_patch__next_id , Bool_.Y); // new dbs automatically have correct next_id
|
||||
}
|
||||
public static final String Cfg_grp_core = "core", Cfg_key_mnt_insert_idx = "mnt.insert_idx"; // SERIALIZED
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class Fsm_mnt_tbl implements RlsAble {
|
||||
stmt.Clear().Val_str(fld_name, name).Val_str(fld_url, url).Crt_int(fld_id, id).Exec_update();
|
||||
}
|
||||
public Fsm_mnt_itm[] Select_all() {
|
||||
ListAdp list = ListAdp_.new_();
|
||||
List_adp list = List_adp_.new_();
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, Db_meta_fld.Ary_empy).Clear().Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
@@ -53,7 +53,7 @@ public class Fsm_mnt_tbl implements RlsAble {
|
||||
}
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
return (Fsm_mnt_itm[])list.Xto_ary_and_clear(Fsm_mnt_itm.class);
|
||||
return (Fsm_mnt_itm[])list.To_ary_and_clear(Fsm_mnt_itm.class);
|
||||
}
|
||||
public static final String Mnt_name_main = "fsdb.main", Mnt_name_user = "fsdb.user";
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class Gfs_lxr_comment_flat implements Gfs_lxr {
|
||||
public int Process(Gfs_parser_ctx ctx, int lxr_bgn, int lxr_end) {
|
||||
byte[] src = ctx.Src(); int src_len = ctx.Src_len();
|
||||
int end_pos = Bry_finder.Find_fwd(src, end_bry, lxr_end, src_len);
|
||||
// if (end_pos == Bry_.NotFound) throw Err_.new_fmt_("comment is not closed: {0}", String_.new_utf8_(end_bry));
|
||||
// if (end_pos == Bry_.NotFound) throw Err_.new_fmt_("comment is not closed: {0}", String_.new_u8(end_bry));
|
||||
return (end_pos == Bry_.NotFound)
|
||||
? src_len // allow eos to terminate flat comment; needed for "tidy-always-adds-nl-in-textarea" fix; NOTE: DATE:2014-06-21
|
||||
: end_pos + end_bry_len; // position after end_bry
|
||||
@@ -150,7 +150,7 @@ class Gfs_lxr_quote implements Gfs_lxr {
|
||||
public int Process(Gfs_parser_ctx ctx, int lxr_bgn, int lxr_end) {
|
||||
byte[] src = ctx.Src(); int src_len = ctx.Src_len();
|
||||
int end_pos = Bry_finder.Find_fwd(src, end_bry, lxr_end, src_len);
|
||||
if (end_pos == Bry_.NotFound) throw Err_.new_fmt_("quote is not closed: {0}", String_.new_utf8_(end_bry));
|
||||
if (end_pos == Bry_.NotFound) throw Err_.new_fmt_("quote is not closed: {0}", String_.new_u8(end_bry));
|
||||
Bry_bfr bfr = ctx.Tmp_bfr().Clear();
|
||||
int prv_pos = lxr_end;
|
||||
int nxt_pos = end_pos + end_bry_len;
|
||||
@@ -160,7 +160,7 @@ class Gfs_lxr_quote implements Gfs_lxr {
|
||||
bfr.Add(end_bry); // add end_bry
|
||||
prv_pos = nxt_pos + end_bry_len; // set prv_pos to after doubled end_bry
|
||||
end_pos = Bry_finder.Find_fwd(src, end_bry, prv_pos, src_len);
|
||||
if (end_pos == Bry_.NotFound) throw Err_.new_fmt_("quote is not closed: {0}", String_.new_utf8_(end_bry));
|
||||
if (end_pos == Bry_.NotFound) throw Err_.new_fmt_("quote is not closed: {0}", String_.new_u8(end_bry));
|
||||
nxt_pos = end_pos + end_bry_len;
|
||||
if (!Bry_.Match(src, nxt_pos, nxt_pos + end_bry_len, end_bry)) {
|
||||
bfr.Add_mid(src, prv_pos, end_pos);
|
||||
|
||||
@@ -19,20 +19,20 @@ package gplx.gfs; import gplx.*;
|
||||
public class Gfs_msg_bldr implements GfoMsgParser {
|
||||
Gfs_parser parser = new Gfs_parser();
|
||||
public GfoMsg ParseToMsg(String s) {return Bld(s);}
|
||||
public GfoMsg Bld(String src) {return Bld(Bry_.new_utf8_(src));}
|
||||
public GfoMsg Bld(String src) {return Bld(Bry_.new_u8(src));}
|
||||
public GfoMsg Bld(byte[] src) {
|
||||
Gfs_nde nde = parser.Parse(src);
|
||||
return Bld_msg(src, nde);
|
||||
}
|
||||
GfoMsg Bld_msg(byte[] src, Gfs_nde nde) {
|
||||
boolean op_is_assign = (nde.Op_tid() == Gfs_nde.Op_tid_assign);
|
||||
String name = String_.new_utf8_(nde.Name_bry(src));
|
||||
String name = String_.new_u8(nde.Name_bry(src));
|
||||
if (op_is_assign) name += Tkn_mutator;
|
||||
GfoMsg rv = GfoMsg_.new_parse_(name);
|
||||
int len = nde.Atrs_len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Gfs_nde atr = nde.Atrs_get_at(i);
|
||||
rv.Add("", String_.new_utf8_(atr.Name_bry(src)));
|
||||
rv.Add("", String_.new_u8(atr.Name_bry(src)));
|
||||
}
|
||||
len = nde.Subs_len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
||||
@@ -56,9 +56,9 @@ class Gfs_msg_bldr_fxt {
|
||||
}
|
||||
public void Test_build(String raw, GfoMsg... expd) {
|
||||
GfoMsg root = msg_bldr.Bld(raw);
|
||||
Tfds.Eq_str_lines(Xto_str(expd), Xto_str(Xto_ary(root)));
|
||||
Tfds.Eq_str_lines(Xto_str(expd), Xto_str(To_ary(root)));
|
||||
}
|
||||
GfoMsg[] Xto_ary(GfoMsg msg) {
|
||||
GfoMsg[] To_ary(GfoMsg msg) {
|
||||
int len = msg.Subs_count();
|
||||
GfoMsg[] rv = new GfoMsg[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
|
||||
@@ -75,8 +75,8 @@ class Gfs_parser_ {
|
||||
trie_add_many(rv, Gfs_lxr_whitespace._, Byte_ascii.Space, Byte_ascii.NewLine, Byte_ascii.CarriageReturn, Byte_ascii.Tab);
|
||||
trie_add_quote(rv, new byte[] {Byte_ascii.Apos});
|
||||
trie_add_quote(rv, new byte[] {Byte_ascii.Quote});
|
||||
trie_add_quote(rv, Bry_.new_ascii_("<:[\"\n"), Bry_.new_ascii_("\n\"]:>"));
|
||||
trie_add_quote(rv, Bry_.new_ascii_("<:['\n"), Bry_.new_ascii_("\n']:>"));
|
||||
trie_add_quote(rv, Bry_.new_a7("<:[\"\n"), Bry_.new_a7("\n\"]:>"));
|
||||
trie_add_quote(rv, Bry_.new_a7("<:['\n"), Bry_.new_a7("\n']:>"));
|
||||
trie_add_comment(rv, new byte[] {Byte_ascii.Slash, Byte_ascii.Slash}, new byte[] {Byte_ascii.NewLine});
|
||||
trie_add_comment(rv, new byte[] {Byte_ascii.Slash, Byte_ascii.Asterisk}, new byte[] {Byte_ascii.Asterisk, Byte_ascii.Slash});
|
||||
rv.Add(Byte_ascii.Semic, Gfs_lxr_semic._);
|
||||
|
||||
@@ -55,11 +55,11 @@ class Gfs_parser_ctx {
|
||||
cur_nde.Atrs_add(nde);
|
||||
return nde;
|
||||
}
|
||||
public void Cur_nde_from_stack() {cur_nde = (Gfs_nde)nodes.FetchAtLast();}
|
||||
public void Stack_add() {nodes.Add(cur_nde);} ListAdp nodes = ListAdp_.new_();
|
||||
public void Cur_nde_from_stack() {cur_nde = (Gfs_nde)nodes.Get_at_last();}
|
||||
public void Stack_add() {nodes.Add(cur_nde);} List_adp nodes = List_adp_.new_();
|
||||
public void Stack_pop(int pos) {
|
||||
if (nodes.Count() < 2) err_mgr.Fail_nde_stack_empty(this, pos); // NOTE: need at least 2 items; 1 to pop and 1 to set as current
|
||||
ListAdp_.DelAt_last(nodes);
|
||||
List_adp_.DelAt_last(nodes);
|
||||
Cur_nde_from_stack();
|
||||
}
|
||||
public Gfs_err_mgr Err_mgr() {return err_mgr;} Gfs_err_mgr err_mgr = new Gfs_err_mgr();
|
||||
@@ -122,5 +122,5 @@ class Gfs_err_mgr {
|
||||
default: bfr.Add_byte(b); break;
|
||||
}
|
||||
}
|
||||
} static final byte[] Esc_nl = Bry_.new_ascii_("\\n"), Esc_cr = Bry_.new_ascii_("\\r"), Esc_tab = Bry_.new_ascii_("\\t");
|
||||
} static final byte[] Esc_nl = Bry_.new_a7("\\n"), Esc_cr = Bry_.new_a7("\\r"), Esc_tab = Bry_.new_a7("\\t");
|
||||
}
|
||||
|
||||
@@ -134,15 +134,15 @@ public class Gfs_parser_tst {
|
||||
}
|
||||
class Gfs_parser_fxt {
|
||||
public void Clear() {}
|
||||
public Gfs_nde nde_(String v) {return new Gfs_nde().Name_(Bry_.new_ascii_(v));}
|
||||
public Gfs_nde val_(String v) {return new Gfs_nde().Name_(Bry_.new_ascii_(v));}
|
||||
public Gfs_nde nde_(String v) {return new Gfs_nde().Name_(Bry_.new_a7(v));}
|
||||
public Gfs_nde val_(String v) {return new Gfs_nde().Name_(Bry_.new_a7(v));}
|
||||
public void Test_parse(String src_str, Gfs_nde... expd) {
|
||||
byte[] src_bry = Bry_.new_utf8_(src_str);
|
||||
byte[] src_bry = Bry_.new_u8(src_str);
|
||||
Gfs_nde root = parser.Parse(src_bry);
|
||||
Tfds.Eq_str_lines(To_str(null, expd), To_str(src_bry, root.Subs_to_ary()));
|
||||
} private Bry_bfr tmp_bfr = Bry_bfr.new_(), path_bfr = Bry_bfr.new_(); Gfs_parser parser = new Gfs_parser();
|
||||
public void Test_parse_fail(String src_str, String expd_err) {
|
||||
byte[] src_bry = Bry_.new_utf8_(src_str);
|
||||
byte[] src_bry = Bry_.new_u8(src_str);
|
||||
try {parser.Parse(src_bry);}
|
||||
catch (Exception e) {
|
||||
String actl_err = Err_.Message_gplx_brief(e);
|
||||
@@ -192,5 +192,5 @@ class Gfs_parser_fxt {
|
||||
bfr.Add(val);
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
private static final byte[] Atr_name = Bry_.new_ascii_("name=");
|
||||
private static final byte[] Atr_name = Bry_.new_a7("name=");
|
||||
}
|
||||
|
||||
@@ -40,11 +40,11 @@ public class Gfui_bnd_parser {
|
||||
, new_mod_(Gfui_bnd_tkn.Tid_mod_cas , "mod.cas" , "Ctrl + Alt + Shift")
|
||||
};
|
||||
private byte[] src; private int src_len;
|
||||
private ListAdp tkns = ListAdp_.new_(); private int mod_val = Mod_val_null;
|
||||
private List_adp tkns = List_adp_.new_(); private int mod_val = Mod_val_null;
|
||||
public String Xto_norm(String src_str) {return Convert(Bool_.Y, src_str);}
|
||||
public String Xto_gfui(String src_str) {return Convert(Bool_.N, src_str);}
|
||||
private String Convert(boolean src_is_gfui, String src_str) {
|
||||
this.src = Bry_.new_utf8_(src_str); this.src_len = src.length;
|
||||
this.src = Bry_.new_u8(src_str); this.src_len = src.length;
|
||||
tkns.Clear(); mod_val = Mod_val_null;
|
||||
int pos = 0; int itm_bgn = -1, itm_end = -1; boolean is_numeric = false;
|
||||
while (pos <= src_len) { // loop over bytes and break up tkns by symbols
|
||||
@@ -91,7 +91,7 @@ public class Gfui_bnd_parser {
|
||||
}
|
||||
int tkns_len = tkns.Count();
|
||||
for (int i = 0; i < tkns_len; i++) {
|
||||
Gfui_bnd_tkn tkn = (Gfui_bnd_tkn)tkns.FetchAt(i);
|
||||
Gfui_bnd_tkn tkn = (Gfui_bnd_tkn)tkns.Get_at(i);
|
||||
tkn.Write(tmp_bfr, !src_is_gfui);
|
||||
}
|
||||
return tmp_bfr.Xto_str_and_clear();
|
||||
@@ -249,16 +249,16 @@ public class Gfui_bnd_parser {
|
||||
norm_regy.Add(itm.Bry_norm(), itm);
|
||||
}
|
||||
private void Init_itm(byte tid, String gfui, String norm) {
|
||||
byte[] gfui_bry = Bry_.new_utf8_(gfui);
|
||||
byte[] norm_bry = Bry_.new_utf8_(norm);
|
||||
byte[] gfui_bry = Bry_.new_u8(gfui);
|
||||
byte[] norm_bry = Bry_.new_u8(norm);
|
||||
Gfui_bnd_tkn itm = new Gfui_bnd_tkn(tid, Gfui_bnd_tkn.Keycode_null, gfui_bry, norm_bry);
|
||||
gfui_regy.Add(gfui_bry, itm);
|
||||
norm_regy.Add_if_new(norm_bry, itm);
|
||||
norm_regy.Add_if_dupe_use_1st(norm_bry, itm);
|
||||
}
|
||||
private static final int Mod_val_null = 0;
|
||||
public static Gfui_bnd_parser new_en_() {return new Gfui_bnd_parser().Init_en();} Gfui_bnd_parser() {}
|
||||
private static Gfui_bnd_tkn new_sym_(byte tid, byte[] bry) {return new Gfui_bnd_tkn(tid, Gfui_bnd_tkn.Keycode_null, bry, bry);}
|
||||
private static Gfui_bnd_tkn new_mod_(byte tid, String gfui, String norm) {return new Gfui_bnd_tkn(tid, Gfui_bnd_tkn.Keycode_null, Bry_.new_ascii_(gfui), Bry_.new_ascii_(norm));}
|
||||
private static Gfui_bnd_tkn new_mod_(byte tid, String gfui, String norm) {return new Gfui_bnd_tkn(tid, Gfui_bnd_tkn.Keycode_null, Bry_.new_a7(gfui), Bry_.new_a7(norm));}
|
||||
}
|
||||
class Gfui_bnd_tkn {
|
||||
public Gfui_bnd_tkn(byte tid, int keycode, byte[] gfui, byte[] norm) {
|
||||
@@ -312,5 +312,5 @@ class Gfui_bnd_tkn {
|
||||
, Tid_key = 12
|
||||
;
|
||||
public static final int Keycode_null = 0;
|
||||
private static final byte[] Bry_key_prefix = Bry_.new_ascii_("key.");
|
||||
private static final byte[] Bry_key_prefix = Bry_.new_a7("key.");
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ public class Html_atr_ {
|
||||
Src_str = "src"
|
||||
;
|
||||
public static final byte[]
|
||||
Id_bry = Bry_.new_ascii_("id")
|
||||
, Cls_bry = Bry_.new_ascii_("class")
|
||||
, Style_bry = Bry_.new_ascii_("style")
|
||||
, Href_bry = Bry_.new_ascii_("href")
|
||||
Id_bry = Bry_.new_a7("id")
|
||||
, Cls_bry = Bry_.new_a7("class")
|
||||
, Style_bry = Bry_.new_a7("style")
|
||||
, Href_bry = Bry_.new_a7("href")
|
||||
;
|
||||
}
|
||||
|
||||
@@ -21,15 +21,15 @@ public class Html_entity_ {
|
||||
Nl_str = " "
|
||||
;
|
||||
public static final byte[]
|
||||
Lt_bry = Bry_.new_ascii_("<"), Gt_bry = Bry_.new_ascii_(">")
|
||||
, Amp_bry = Bry_.new_ascii_("&"), Quote_bry = Bry_.new_ascii_(""")
|
||||
, Apos_num_bry = Bry_.new_ascii_("'")
|
||||
, Apos_key_bry = Bry_.new_ascii_("'")
|
||||
, Eq_bry = Bry_.new_ascii_("=")
|
||||
, Nl_bry = Bry_.new_ascii_(Nl_str), Space_bry = Bry_.new_ascii_(" ")
|
||||
, Pipe_bry = Bry_.new_ascii_("|")
|
||||
, Colon_bry = Bry_.new_ascii_(":"), Underline_bry = Bry_.new_ascii_("_"), Asterisk_bry = Bry_.new_ascii_("*")
|
||||
, Brack_bgn_bry = Bry_.new_ascii_("["), Brack_end_bry = Bry_.new_ascii_("]")
|
||||
, Nbsp_num_bry = Bry_.new_ascii_(" ")
|
||||
Lt_bry = Bry_.new_a7("<"), Gt_bry = Bry_.new_a7(">")
|
||||
, Amp_bry = Bry_.new_a7("&"), Quote_bry = Bry_.new_a7(""")
|
||||
, Apos_num_bry = Bry_.new_a7("'")
|
||||
, Apos_key_bry = Bry_.new_a7("'")
|
||||
, Eq_bry = Bry_.new_a7("=")
|
||||
, Nl_bry = Bry_.new_a7(Nl_str), Space_bry = Bry_.new_a7(" ")
|
||||
, Pipe_bry = Bry_.new_a7("|")
|
||||
, Colon_bry = Bry_.new_a7(":"), Underline_bry = Bry_.new_a7("_"), Asterisk_bry = Bry_.new_a7("*")
|
||||
, Brack_bgn_bry = Bry_.new_a7("["), Brack_end_bry = Bry_.new_a7("]")
|
||||
, Nbsp_num_bry = Bry_.new_a7(" ")
|
||||
;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class Html_nde {
|
||||
public int Name_bgn() {return name_bgn;} public Html_nde Name_bgn_(int v) {name_bgn = v; return this;} private int name_bgn;
|
||||
public int Name_end() {return name_end;} public Html_nde Name_end_(int v) {name_end = v; return this;} private int name_end;
|
||||
public void Clear() {tag_lhs_bgn = tag_rhs_bgn = -1;}
|
||||
public String Atrs_val_by_key_str(String find_key_str) {return String_.new_utf8_(Atrs_val_by_key_bry(Bry_.new_utf8_(find_key_str)));}
|
||||
public String Atrs_val_by_key_str(String find_key_str) {return String_.new_u8(Atrs_val_by_key_bry(Bry_.new_u8(find_key_str)));}
|
||||
public byte[] Atrs_val_by_key_bry(byte[] find_key_bry) {
|
||||
for (int i = 0; i < atrs_len; i ++) {
|
||||
int atrs_idx = i * 5;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Html_parser {
|
||||
public Html_nde[] Parse_as_ary(byte[] src, int bgn, int end) {return Parse_as_ary(src, bgn, end, Wildcard, Wildcard);}
|
||||
public Html_nde[] Parse_as_ary(byte[] src, int bgn, int end, byte[] find_key, byte[] find_val) { // flattens html into a list of hndes; only used for Options
|
||||
this.src = src; pos = bgn; this.end = end;
|
||||
ListAdp rv = ListAdp_.new_();
|
||||
List_adp rv = List_adp_.new_();
|
||||
while (pos < end) {
|
||||
byte b = src[pos++];
|
||||
switch (b) {
|
||||
@@ -53,7 +53,7 @@ public class Html_parser {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (Html_nde[])rv.Xto_ary(Html_nde.class);
|
||||
return (Html_nde[])rv.To_ary(Html_nde.class);
|
||||
}
|
||||
int cur_lhs_bgn, cur_lhs_end, cur_name_bgn, cur_name_end, cur_rhs_bgn; boolean xnde_init = true, tag_tid_is_inline = false;
|
||||
private boolean Parse_xnde_rhs() {
|
||||
|
||||
@@ -34,8 +34,8 @@ class Xoh_parser_fxt {
|
||||
} private Html_parser parser;
|
||||
public Xoh_parser_fxt Test_parse_find_all(String raw_str, String... expd) {return Test_parse_find(raw_str, Html_parser.Wildcard_str, Html_parser.Wildcard_str, expd);}
|
||||
public Xoh_parser_fxt Test_parse_find(String raw_str, String find_key, String find_val, String... expd) {
|
||||
byte[] raw = Bry_.new_ascii_(raw_str);
|
||||
Html_nde[] actl_ndes = parser.Parse_as_ary(raw, 0, raw.length, Bry_.new_ascii_(find_key), Bry_.new_ascii_(find_val));
|
||||
byte[] raw = Bry_.new_a7(raw_str);
|
||||
Html_nde[] actl_ndes = parser.Parse_as_ary(raw, 0, raw.length, Bry_.new_a7(find_key), Bry_.new_a7(find_val));
|
||||
String[] actl = Xto_ids(raw, actl_ndes);
|
||||
Tfds.Eq_ary_str(expd, actl);
|
||||
return this;
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.html; import gplx.*;
|
||||
public class Html_selecter {
|
||||
public static Html_nde[] Select(byte[] src, Html_nde[] ary, Hash_adp_bry hash) {
|
||||
ListAdp list = ListAdp_.new_();
|
||||
List_adp list = List_adp_.new_();
|
||||
int xndes_len = ary.length;
|
||||
for (int i = 0; i < xndes_len; i++) {
|
||||
Html_nde hnde = ary[i];
|
||||
@@ -33,7 +33,7 @@ public class Html_selecter {
|
||||
}
|
||||
}
|
||||
}
|
||||
Html_nde[] rv = (Html_nde[])list.Xto_ary(Html_nde.class);
|
||||
Html_nde[] rv = (Html_nde[])list.To_ary(Html_nde.class);
|
||||
list.Clear();
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -18,30 +18,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.html; import gplx.*;
|
||||
public class Html_tag_ {
|
||||
public static final byte[]
|
||||
Ul_name_bry = Bry_.new_ascii_("ul")
|
||||
, A_name_bry = Bry_.new_ascii_("a")
|
||||
, Code_name_bry = Bry_.new_ascii_("code")
|
||||
, Tr_name_bry = Bry_.new_ascii_("tr")
|
||||
, Td_name_bry = Bry_.new_ascii_("td")
|
||||
, Table_name_bry = Bry_.new_ascii_("table")
|
||||
Ul_name_bry = Bry_.new_a7("ul")
|
||||
, A_name_bry = Bry_.new_a7("a")
|
||||
, Code_name_bry = Bry_.new_a7("code")
|
||||
, Tr_name_bry = Bry_.new_a7("tr")
|
||||
, Td_name_bry = Bry_.new_a7("td")
|
||||
, Table_name_bry = Bry_.new_a7("table")
|
||||
;
|
||||
public static final byte[]
|
||||
Br_inl = Bry_.new_ascii_("<br/>")
|
||||
, Hr_inl = Bry_.new_ascii_("<hr/>")
|
||||
, Body_lhs = Bry_.new_ascii_("<body>") , Body_rhs = Bry_.new_ascii_("</body>")
|
||||
, B_lhs = Bry_.new_ascii_("<b>") , B_rhs = Bry_.new_ascii_("</b>")
|
||||
, I_lhs = Bry_.new_ascii_("<i>") , I_rhs = Bry_.new_ascii_("</i>")
|
||||
, P_lhs = Bry_.new_ascii_("<p>") , P_rhs = Bry_.new_ascii_("</p>")
|
||||
, Div_lhs = Bry_.new_ascii_("<div>") , Div_rhs = Bry_.new_ascii_("</div>")
|
||||
, Html_rhs = Bry_.new_ascii_("</html>")
|
||||
, Head_lhs_bgn = Bry_.new_ascii_("<head")
|
||||
, Head_rhs = Bry_.new_ascii_("</head>")
|
||||
, Style_lhs_w_type = Bry_.new_ascii_("<style type=\"text/css\">")
|
||||
, Style_rhs = Bry_.new_ascii_("</style>")
|
||||
, Script_lhs = Bry_.new_ascii_("<script>")
|
||||
, Script_lhs_w_type = Bry_.new_ascii_("<script type='text/javascript'>")
|
||||
, Script_rhs = Bry_.new_ascii_("</script>")
|
||||
, Span_rhs = Bry_.new_ascii_("</span>")
|
||||
Br_inl = Bry_.new_a7("<br/>")
|
||||
, Hr_inl = Bry_.new_a7("<hr/>")
|
||||
, Body_lhs = Bry_.new_a7("<body>") , Body_rhs = Bry_.new_a7("</body>")
|
||||
, B_lhs = Bry_.new_a7("<b>") , B_rhs = Bry_.new_a7("</b>")
|
||||
, I_lhs = Bry_.new_a7("<i>") , I_rhs = Bry_.new_a7("</i>")
|
||||
, P_lhs = Bry_.new_a7("<p>") , P_rhs = Bry_.new_a7("</p>")
|
||||
, Div_lhs = Bry_.new_a7("<div>") , Div_rhs = Bry_.new_a7("</div>")
|
||||
, Html_rhs = Bry_.new_a7("</html>")
|
||||
, Head_lhs_bgn = Bry_.new_a7("<head")
|
||||
, Head_rhs = Bry_.new_a7("</head>")
|
||||
, Style_lhs_w_type = Bry_.new_a7("<style type=\"text/css\">")
|
||||
, Style_rhs = Bry_.new_a7("</style>")
|
||||
, Script_lhs = Bry_.new_a7("<script>")
|
||||
, Script_lhs_w_type = Bry_.new_a7("<script type='text/javascript'>")
|
||||
, Script_rhs = Bry_.new_a7("</script>")
|
||||
, Span_rhs = Bry_.new_a7("</span>")
|
||||
;
|
||||
|
||||
public static final String
|
||||
@@ -50,7 +50,7 @@ public class Html_tag_ {
|
||||
, Anchor_str = "#"
|
||||
;
|
||||
public static final byte[]
|
||||
Comm_bgn = Bry_.new_ascii_(Comm_bgn_str), Comm_end = Bry_.new_ascii_(Comm_end_str)
|
||||
Comm_bgn = Bry_.new_a7(Comm_bgn_str), Comm_end = Bry_.new_a7(Comm_end_str)
|
||||
;
|
||||
public static final int
|
||||
Comm_bgn_len = Comm_bgn.length
|
||||
|
||||
@@ -19,14 +19,14 @@ package gplx.html; import gplx.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
public class Html_utl {
|
||||
private static final Url_encoder encoder_id = Url_encoder.new_html_id_(); private static final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
public static String Encode_id_as_str(byte[] key) {return String_.new_utf8_(Encode_id_as_bry(key));}
|
||||
public static String Encode_id_as_str(byte[] key) {return String_.new_u8(Encode_id_as_bry(key));}
|
||||
public static byte[] Encode_id_as_bry(byte[] key) {
|
||||
byte[] escaped = Escape_html_as_bry(tmp_bfr, key, Bool_.N, Bool_.N, Bool_.N, Bool_.Y, Bool_.Y);
|
||||
return encoder_id.Encode(escaped);
|
||||
}
|
||||
public static byte[] Escape_for_atr_val_as_bry(Bry_bfr bfr, byte quote_byte, String s) {
|
||||
if (s == null) return null;
|
||||
return Escape_for_atr_val_as_bry(bfr, quote_byte, Bry_.new_utf8_(s));
|
||||
return Escape_for_atr_val_as_bry(bfr, quote_byte, Bry_.new_u8(s));
|
||||
}
|
||||
public static byte[] Escape_for_atr_val_as_bry(Bry_bfr bfr, byte quote_byte, byte[] bry) {
|
||||
if (bry == null) return null;
|
||||
@@ -55,7 +55,7 @@ public class Html_utl {
|
||||
}
|
||||
return dirty;
|
||||
}
|
||||
public static String Escape_html_as_str(String v) {return String_.new_utf8_(Escape_html_as_bry(Bry_.new_utf8_(v)));}
|
||||
public static String Escape_html_as_str(String v) {return String_.new_u8(Escape_html_as_bry(Bry_.new_u8(v)));}
|
||||
public static byte[] Escape_html_as_bry(Bry_bfr tmp, byte[] bry) {return Escape_html(false, tmp, bry, 0, bry.length, true, true, true, true, true);}
|
||||
public static byte[] Escape_html_as_bry(byte[] bry) {return Escape_html(false, tmp_bfr, bry, 0, bry.length, true, true, true, true, true);}
|
||||
public static byte[] Escape_html_as_bry(byte[] bry, boolean lt, boolean gt, boolean amp, boolean quote, boolean apos)
|
||||
@@ -111,7 +111,7 @@ public class Html_utl {
|
||||
;
|
||||
public static String Unescape_as_str(String src) {
|
||||
Bry_bfr bfr = Bry_bfr.reset_(255);
|
||||
byte[] bry = Bry_.new_utf8_(src);
|
||||
byte[] bry = Bry_.new_u8(src);
|
||||
Unescape(Bool_.Y, bfr, bry, 0, bry.length, Bool_.Y, Bool_.Y, Bool_.Y, Bool_.Y, Bool_.Y);
|
||||
return bfr.Xto_str_and_clear();
|
||||
}
|
||||
|
||||
@@ -43,20 +43,20 @@ class Html_utl_fxt {
|
||||
tmp_bfr.Clear();
|
||||
}
|
||||
public void Test_del_comments(String src, String expd) {
|
||||
byte[] actl = Html_utl.Del_comments(tmp_bfr, Bry_.new_utf8_(src));
|
||||
Tfds.Eq(expd, String_.new_ascii_(actl));
|
||||
byte[] actl = Html_utl.Del_comments(tmp_bfr, Bry_.new_u8(src));
|
||||
Tfds.Eq(expd, String_.new_a7(actl));
|
||||
}
|
||||
public void Test_escape_html(boolean lt, boolean gt, boolean amp, boolean quote, boolean apos, String src, String expd) {
|
||||
byte[] actl = Html_utl.Escape_html_as_bry(Bry_.new_ascii_(src), lt, gt, amp, quote, apos);
|
||||
Tfds.Eq(expd, String_.new_ascii_(actl));
|
||||
byte[] actl = Html_utl.Escape_html_as_bry(Bry_.new_a7(src), lt, gt, amp, quote, apos);
|
||||
Tfds.Eq(expd, String_.new_a7(actl));
|
||||
}
|
||||
public void Test_escape_for_atr(String src, boolean quote_is_apos, String expd) {
|
||||
byte[] actl = Html_utl.Escape_for_atr_val_as_bry(tmp_bfr, quote_is_apos ? Byte_ascii.Apos : Byte_ascii.Quote, src);
|
||||
Tfds.Eq(expd, String_.new_utf8_(actl));
|
||||
Tfds.Eq(expd, String_.new_u8(actl));
|
||||
}
|
||||
public void Test_unescape_html(boolean lt, boolean gt, boolean amp, boolean quote, boolean apos, String src, String expd) {
|
||||
byte[] bry = Bry_.new_utf8_(src);
|
||||
byte[] bry = Bry_.new_u8(src);
|
||||
byte[] actl = Html_utl.Unescape(false, tmp_bfr, bry, 0, bry.length, lt, gt, amp, quote, apos);
|
||||
Tfds.Eq(expd, String_.new_ascii_(actl));
|
||||
Tfds.Eq(expd, String_.new_a7(actl));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.html; import gplx.*;
|
||||
public class Html_wtr {
|
||||
private Bry_bfr bfr = Bry_bfr.reset_(255);
|
||||
private ListAdp nde_stack = ListAdp_.new_();
|
||||
private List_adp nde_stack = List_adp_.new_();
|
||||
public byte Atr_quote() {return atr_quote;} public Html_wtr Atr_quote_(byte v) {atr_quote = v; return this;} private byte atr_quote = Byte_ascii.Quote;
|
||||
public Html_wtr Nde_full_atrs(byte[] tag, byte[] text, boolean text_escape, byte[]... atrs) {
|
||||
Nde_bgn(tag);
|
||||
@@ -68,7 +68,7 @@ public class Html_wtr {
|
||||
}
|
||||
public Html_wtr Nde_end_inline() {
|
||||
bfr.Add_byte(Byte_ascii.Slash).Add_byte(Byte_ascii.Gt);
|
||||
nde_stack.PopLast();
|
||||
List_adp_.Pop_last(nde_stack);
|
||||
return this;
|
||||
}
|
||||
public Html_wtr Nde_end_hdr() {
|
||||
@@ -76,7 +76,7 @@ public class Html_wtr {
|
||||
return this;
|
||||
}
|
||||
public Html_wtr Nde_end() {
|
||||
byte[] name = (byte[])nde_stack.PopLast();
|
||||
byte[] name = (byte[])List_adp_.Pop_last(nde_stack);
|
||||
bfr.Add_byte(Byte_ascii.Lt).Add_byte(Byte_ascii.Slash);
|
||||
bfr.Add(name);
|
||||
bfr.Add_byte(Byte_ascii.Gt);
|
||||
|
||||
@@ -45,12 +45,12 @@ class String_surrogate_utl_fxt {
|
||||
private String_surrogate_utl codepoint_utl = new String_surrogate_utl();
|
||||
public void Clear() {}
|
||||
public void Test_count_surrogates__char_idx(String src_str, int bgn_byte, int char_idx, int expd_count, int expd_pos) {
|
||||
byte[] src_bry = Bry_.new_utf8_(src_str); int src_len = src_bry.length;
|
||||
byte[] src_bry = Bry_.new_u8(src_str); int src_len = src_bry.length;
|
||||
Tfds.Eq(expd_count , codepoint_utl.Count_surrogates__char_idx(src_bry, src_len, bgn_byte, char_idx));
|
||||
Tfds.Eq(expd_pos , codepoint_utl.Byte_pos());
|
||||
}
|
||||
public void Test_count_surrogates__codepoint_idx(String src_str, int bgn_byte, int char_idx, int expd_count, int expd_pos) {
|
||||
byte[] src_bry = Bry_.new_utf8_(src_str); int src_len = src_bry.length;
|
||||
byte[] src_bry = Bry_.new_u8(src_str); int src_len = src_bry.length;
|
||||
Tfds.Eq(expd_count , codepoint_utl.Count_surrogates__codepoint_idx1(src_bry, src_len, bgn_byte, char_idx), "count");
|
||||
Tfds.Eq(expd_pos , codepoint_utl.Byte_pos(), "pos");
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ public class Io_stream_rdr_process implements Io_stream_rdr {
|
||||
private String[] process_args;
|
||||
Io_stream_rdr_process(Io_url process_exe, Io_url stream_url, String[] process_args) {this.process_exe = process_exe; this.url = stream_url; this.process_args = process_args;}
|
||||
public byte Tid() {return Io_stream_.Tid_bzip2;} // for now, classify as bzip2; not sure if separate tid is necessary
|
||||
public boolean Exists() {return this.Len() > 0;}
|
||||
public Io_url Url() {return url;} public Io_stream_rdr Url_(Io_url v) {url = v; return this;} private Io_url url;
|
||||
public long Len() {return len;} public Io_stream_rdr Len_(long v) {len = v; return this;} private long len;
|
||||
public Io_url Process_exe() {return process_exe;} private Io_url process_exe;
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Io_stream_zip_mgr {
|
||||
Io_stream_wtr wtr = Wtr(type);
|
||||
wtr.Write(val, 0, val.length);
|
||||
wtr.Flush();
|
||||
return wtr.Xto_ary_and_clear();
|
||||
return wtr.To_ary_and_clear();
|
||||
}
|
||||
public byte[] Unzip(byte type, byte[] val) {
|
||||
if (type == Io_stream_.Tid_raw) return val;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class Json_doc {
|
||||
return null;
|
||||
}
|
||||
public static Json_doc new_apos_concat_nl(String... ary) {return new_apos_(String_.Concat_lines_nl(ary));}
|
||||
public static Json_doc new_apos_(String v) {return new_(Bry_.Replace(Bry_.new_utf8_(v), Byte_ascii.Apos, Byte_ascii.Quote));}
|
||||
public static Json_doc new_(String v) {return new_(Bry_.new_utf8_(v));}
|
||||
public static Json_doc new_apos_(String v) {return new_(Bry_.Replace(Bry_.new_u8(v), Byte_ascii.Apos, Byte_ascii.Quote));}
|
||||
public static Json_doc new_(String v) {return new_(Bry_.new_u8(v));}
|
||||
public static Json_doc new_(byte[] v) {return parser.Parse(v);} static Json_parser parser = new Json_parser();
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class Json_doc_bldr {
|
||||
owner.Subs_add(rv);
|
||||
return rv;
|
||||
}
|
||||
public Json_itm Str(byte[] v) {return Str(String_.new_utf8_(v));}
|
||||
public Json_itm Str(byte[] v) {return Str(String_.new_u8(v));}
|
||||
public Json_itm Str(String v) {return Json_itm_tmp.new_str_(v);}
|
||||
public Json_itm Int(int v) {return Json_itm_tmp.new_int_(v);}
|
||||
public Json_itm_kv Kv_int(Json_grp owner, String key, int val) {Json_itm_kv rv = factory.Kv(Json_itm_tmp.new_str_(key), Json_itm_tmp.new_int_(val)); owner.Subs_add(rv); return rv;}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class Json_doc_srl {
|
||||
int len = val.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Write_itm_hdr(i != 0); // ', '
|
||||
Write_str(Bry_.new_utf8_(Object_.Xto_str_strict_or_null(val[i])));
|
||||
Write_str(Bry_.new_u8(Object_.Xto_str_strict_or_null(val[i])));
|
||||
Write_new_line();
|
||||
}
|
||||
Indent_del();
|
||||
@@ -50,7 +50,7 @@ public class Json_doc_srl {
|
||||
}
|
||||
private void Write_kv_str(boolean comma, byte[] key, String val) {
|
||||
Write_key(comma, key); // "key":
|
||||
Write_str(Bry_.new_utf8_(val)); // "val"
|
||||
Write_str(Bry_.new_u8(val)); // "val"
|
||||
Write_new_line(); // \n
|
||||
}
|
||||
private void Write_key(boolean comma, byte[] key) { // "key":
|
||||
@@ -64,7 +64,7 @@ public class Json_doc_srl {
|
||||
bfr.Add(Bry_null);
|
||||
else
|
||||
bfr.Add_byte(Byte_ascii.Quote).Add(v).Add_byte(Byte_ascii.Quote);
|
||||
} private static final byte[] Bry_null = Bry_.new_ascii_("null");
|
||||
} private static final byte[] Bry_null = Bry_.new_a7("null");
|
||||
private void Write_comma(boolean comma) {
|
||||
if (comma)
|
||||
bfr.Add_byte(Byte_ascii.Comma);
|
||||
|
||||
@@ -39,7 +39,7 @@ public class Json_doc_tst {
|
||||
}
|
||||
class Json_qry_mgr_fxt {
|
||||
public void Test_get_val_as_str(Json_doc doc, String qry, String expd){
|
||||
byte[][] qry_bry = Bry_.Split(Bry_.new_utf8_(qry), Byte_ascii.Slash);
|
||||
byte[][] qry_bry = Bry_.Split(Bry_.new_u8(qry), Byte_ascii.Slash);
|
||||
Tfds.Eq(expd, doc.Get_val_as_str_or(qry_bry, null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class Json_doc_wtr {
|
||||
else
|
||||
bfr.Add_byte(Byte_ascii.Quote).Add(v).Add_byte(Byte_ascii.Quote);
|
||||
return this;
|
||||
} private static final byte[] Bry_null = Bry_.new_ascii_("null");
|
||||
} private static final byte[] Bry_null = Bry_.new_a7("null");
|
||||
public Json_doc_wtr Int(int v) {bfr.Add_int_variable(v); return this;}
|
||||
public Json_doc_wtr Double(double v) {bfr.Add_double(v); return this;}
|
||||
public Json_doc_wtr Comma() {Indent(); bfr.Add_byte(Byte_ascii.Comma).Add_byte_nl(); return this;}
|
||||
|
||||
@@ -31,7 +31,7 @@ class Json_itm_null extends Json_itm_base {
|
||||
@Override public Object Data() {return null;}
|
||||
@Override public void Print_as_json(Bry_bfr bfr, int depth) {bfr.Add(Bry_null);}
|
||||
@Override public byte[] Data_bry() {return Bry_null;}
|
||||
private static final byte[] Bry_null = Bry_.new_ascii_("null");
|
||||
private static final byte[] Bry_null = Bry_.new_a7("null");
|
||||
public static Json_itm_null Null = new Json_itm_null();
|
||||
}
|
||||
class Json_itm_bool extends Json_itm_base {
|
||||
@@ -47,7 +47,7 @@ class Json_itm_decimal extends Json_itm_base {
|
||||
@Override public byte Tid() {return Json_itm_.Tid_decimal;}
|
||||
@Override public Object Data() {
|
||||
if (data == null)
|
||||
data = DecimalAdp_.parse_(String_.new_ascii_(this.Data_bry()));
|
||||
data = DecimalAdp_.parse_(String_.new_a7(this.Data_bry()));
|
||||
return data;
|
||||
} DecimalAdp data;
|
||||
@Override public byte[] Data_bry() {
|
||||
@@ -68,7 +68,7 @@ class Json_itm_str extends Json_itm_base {
|
||||
if (data_str == null) {
|
||||
if (data_bry == null)
|
||||
data_bry = Data_make_bry();
|
||||
data_str = String_.new_utf8_(data_bry);
|
||||
data_str = String_.new_u8(data_bry);
|
||||
}
|
||||
return data_str;
|
||||
} private String data_str;
|
||||
|
||||
@@ -20,5 +20,5 @@ public class Json_itm_ {
|
||||
public static final Json_itm[] Ary_empty = new Json_itm[0];
|
||||
public static final byte Tid_unknown = 0, Tid_null = 1, Tid_bool = 2, Tid_int = 3, Tid_decimal = 4, Tid_string = 5, Tid_kv = 6, Tid_array = 7, Tid_nde = 8;
|
||||
public static final byte[][] Names = Bry_.Ary("unknown", "null", "boolean", "int", "decimal", "string", "keyval", "array", "nde");
|
||||
public static final byte[] Const_true = Bry_.new_ascii_("true"), Const_false = Bry_.new_ascii_("false"), Const_null = Bry_.new_ascii_("null");
|
||||
public static final byte[] Const_true = Bry_.new_a7("true"), Const_false = Bry_.new_a7("false"), Const_null = Bry_.new_a7("null");
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.json; import gplx.*;
|
||||
public class Json_itm_tmp implements Json_itm {
|
||||
public Json_itm_tmp(byte tid, String data) {this.tid = tid; this.data = data;}
|
||||
public byte Tid() {return tid;} private byte tid;
|
||||
public byte[] Data_bry() {return Bry_.new_utf8_(Object_.Xto_str_strict_or_empty(data));}
|
||||
public byte[] Data_bry() {return Bry_.new_u8(Object_.Xto_str_strict_or_empty(data));}
|
||||
public int Src_bgn() {return -1;}
|
||||
public int Src_end() {return -1;}
|
||||
public Object Data() {return data;} private String data;
|
||||
|
||||
@@ -36,7 +36,7 @@ class Json_kv_ary_srl_fxt {
|
||||
}
|
||||
} private Json_parser parser;
|
||||
public void Test_parse(String raw_str, KeyVal[] expd) {
|
||||
byte[] raw_bry = Json_parser_tst.Replace_apos(Bry_.new_utf8_(raw_str));
|
||||
byte[] raw_bry = Json_parser_tst.Replace_apos(Bry_.new_u8(raw_str));
|
||||
Json_doc doc = parser.Parse(raw_bry);
|
||||
KeyVal[] actl = Json_kv_ary_srl.Val_by_itm_nde(doc.Root());
|
||||
Tfds.Eq_str_lines(KeyVal_.Ary_x_to_str(expd), KeyVal_.Ary_x_to_str(actl));
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.json; import gplx.*;
|
||||
public class Json_parser {
|
||||
public Json_factory Factory() {return factory;} private Json_factory factory = new Json_factory();
|
||||
private byte[] src; private int src_len, pos; private Number_parser num_parser = new Number_parser();
|
||||
private static final byte[] Bry_bool_rue = Bry_.new_ascii_("rue"), Bry_bool_alse = Bry_.new_ascii_("alse"), Bry_null_ull = Bry_.new_ascii_("ull");
|
||||
private static final byte[] Bry_bool_rue = Bry_.new_a7("rue"), Bry_bool_alse = Bry_.new_a7("alse"), Bry_null_ull = Bry_.new_a7("ull");
|
||||
public Json_doc Parse(byte[] src) {
|
||||
Json_doc doc = new Json_doc();
|
||||
this.src = src; this.src_len = src.length; pos = 0;
|
||||
@@ -161,7 +161,7 @@ public class Json_parser {
|
||||
}
|
||||
Err err_(byte[] src, int bgn, String fmt, Object... args) {return err_(src, bgn, src.length, fmt, args);}
|
||||
Err err_(byte[] src, int bgn, int src_len, String fmt, Object... args) {
|
||||
String msg = String_.Format(fmt, args) + " " + Int_.Xto_str(bgn) + " " + String_.new_utf8_len_safe_(src, bgn, 20);
|
||||
String msg = String_.Format(fmt, args) + " " + Int_.Xto_str(bgn) + " " + String_.new_u8_by_len(src, bgn, 20);
|
||||
return Err_.new_(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Json_parser_tst {
|
||||
@Test public void Subs_empty() {fxt.Test_parse("{'k0':{}}", fxt.itm_nde_().Subs_add_many(fxt.itm_kv_("k0", fxt.itm_nde_())));}
|
||||
@Test public void Subs_ws() {fxt.Test_parse("{'k0': { 'k00' : 1 } }", fxt.itm_nde_().Subs_add_many(fxt.itm_kv_("k0", fxt.itm_nde_().Subs_add_many(fxt.itm_kv_("k00", 1)))));}
|
||||
@Test public void Ws() {fxt.Test_parse(" { 'k0' : 'v0' } ", fxt.itm_nde_().Subs_add_many(fxt.itm_kv_("k0", "v0")));}
|
||||
public static String Replace_apos_as_str(String v) {return String_.new_utf8_(Replace_apos(Bry_.new_utf8_(v)));}
|
||||
public static String Replace_apos_as_str(String v) {return String_.new_u8(Replace_apos(Bry_.new_u8(v)));}
|
||||
public static byte[] Replace_apos(byte[] v) {return Bry_.Replace(v, Byte_ascii.Apos, Byte_ascii.Quote);}
|
||||
}
|
||||
class Json_parser_fxt {
|
||||
@@ -75,7 +75,7 @@ class Json_parser_fxt {
|
||||
return factory.Kv(itm_str_(k), ary);
|
||||
}
|
||||
public void Test_parse(String raw_str, Json_itm... expd_ary) {
|
||||
byte[] raw = Json_parser_tst.Replace_apos(Bry_.new_utf8_(raw_str));
|
||||
byte[] raw = Json_parser_tst.Replace_apos(Bry_.new_u8(raw_str));
|
||||
Json_doc doc = parser.Parse(raw);
|
||||
doc.Root().Print_as_json(tmp_bfr, 0);
|
||||
String actl = tmp_bfr.Xto_str_and_clear();
|
||||
@@ -83,7 +83,7 @@ class Json_parser_fxt {
|
||||
Tfds.Eq_str_lines(expd, actl, actl);
|
||||
}
|
||||
public void Test_parse_val0(String raw_str, Object expd) {
|
||||
byte[] raw = Json_parser_tst.Replace_apos(Bry_.new_utf8_(raw_str));
|
||||
byte[] raw = Json_parser_tst.Replace_apos(Bry_.new_u8(raw_str));
|
||||
Json_doc doc = parser.Parse(raw);
|
||||
Json_itm_kv kv = Json_itm_kv.cast_(doc.Root().Subs_get_at(0)); // assume root has kv as first sub; EX: {"a":"b"}
|
||||
Object actl = kv.Val().Data(); // NOTE: Data_bry is escaped val; EX: a\"b has DataBry of a"b
|
||||
|
||||
@@ -25,10 +25,10 @@ NOTE: naive implementation of PHP evaluator. intended only for parsing Messages*
|
||||
public class Php_evaluator implements Php_tkn_wkr {
|
||||
byte mode = Mode_key_bgn, next_tid = 0, next_mode = 0;
|
||||
Php_line_assign cur_line; Php_itm_ary cur_ary; Php_key cur_kv_key;
|
||||
ListAdp frame_stack = ListAdp_.new_();
|
||||
List_adp frame_stack = List_adp_.new_();
|
||||
public Php_evaluator(Gfo_msg_log msg_log) {this.msg_log = msg_log;} Gfo_msg_log msg_log;
|
||||
public void Init(Php_ctx ctx) {src = ctx.Src(); frame_stack.Clear();} private byte[] src;
|
||||
public ListAdp List() {return lines;} ListAdp lines = ListAdp_.new_();
|
||||
public List_adp List() {return lines;} List_adp lines = List_adp_.new_();
|
||||
public Gfo_msg_log Msg_log() {return msg_log;}
|
||||
public void Clear() {
|
||||
lines.Clear(); msg_log.Clear();
|
||||
@@ -179,7 +179,7 @@ public class Php_evaluator implements Php_tkn_wkr {
|
||||
if (frame_stack.Count() == 0)
|
||||
cur_ary = null;
|
||||
else {
|
||||
Php_scanner_frame frame = (Php_scanner_frame)ListAdp_.Pop(frame_stack);
|
||||
Php_scanner_frame frame = (Php_scanner_frame)List_adp_.Pop(frame_stack);
|
||||
cur_ary = frame.Ary();
|
||||
frame.Rls();
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public class Php_evaluator implements Php_tkn_wkr {
|
||||
if (frame_stack.Count() == 0)
|
||||
cur_ary = null;
|
||||
else {
|
||||
Php_scanner_frame frame = (Php_scanner_frame)ListAdp_.Pop(frame_stack);
|
||||
Php_scanner_frame frame = (Php_scanner_frame)List_adp_.Pop(frame_stack);
|
||||
cur_ary = frame.Ary();
|
||||
frame.Rls();
|
||||
}
|
||||
|
||||
@@ -29,13 +29,13 @@ class Php_itm_bool_true implements Php_itm, Php_itm_sub {
|
||||
public byte Itm_tid() {return Php_itm_.Tid_bool_true;}
|
||||
public byte[] Val_obj_bry() {return Bry_true;}
|
||||
public static final Php_itm_bool_true _ = new Php_itm_bool_true(); Php_itm_bool_true() {}
|
||||
private static final byte[] Bry_true = Bry_.new_ascii_("true");
|
||||
private static final byte[] Bry_true = Bry_.new_a7("true");
|
||||
}
|
||||
class Php_itm_bool_false implements Php_itm, Php_itm_sub {
|
||||
public byte Itm_tid() {return Php_itm_.Tid_bool_false;}
|
||||
public byte[] Val_obj_bry() {return Bry_true;}
|
||||
public static final Php_itm_bool_false _ = new Php_itm_bool_false(); Php_itm_bool_false() {}
|
||||
private static final byte[] Bry_true = Bry_.new_ascii_("false");
|
||||
private static final byte[] Bry_true = Bry_.new_a7("false");
|
||||
}
|
||||
class Php_itm_var implements Php_itm, Php_itm_sub, Php_key {
|
||||
public Php_itm_var(byte[] v) {this.val_obj_bry = v;}
|
||||
|
||||
@@ -59,7 +59,7 @@ class Php_lxr_declaration extends Php_lxr_base {
|
||||
tkn_wkr.Process(tkn_factory.Declaration(bgn, cur));
|
||||
return cur;
|
||||
}
|
||||
private static final byte[] Bry_declaration = Bry_.new_ascii_("<?php");
|
||||
private static final byte[] Bry_declaration = Bry_.new_a7("<?php");
|
||||
}
|
||||
class Php_lxr_ws extends Php_lxr_base {
|
||||
public Php_lxr_ws(byte ws_tid) {
|
||||
@@ -95,7 +95,7 @@ class Php_lxr_ws extends Php_lxr_base {
|
||||
tkn_wkr.Process(tkn_factory.Ws(bgn, cur, ws_tid));
|
||||
return cur;
|
||||
}
|
||||
public static final byte[] Bry_ws_space = Bry_.new_ascii_(" "), Bry_ws_nl = Bry_.new_ascii_("\n"), Bry_ws_tab = Bry_.new_ascii_("\t"), Bry_ws_cr = Bry_.new_ascii_("\r");
|
||||
public static final byte[] Bry_ws_space = Bry_.new_a7(" "), Bry_ws_nl = Bry_.new_a7("\n"), Bry_ws_tab = Bry_.new_a7("\t"), Bry_ws_cr = Bry_.new_a7("\r");
|
||||
}
|
||||
class Php_lxr_comment extends Php_lxr_base {
|
||||
public Php_lxr_comment(byte comment_tid) {
|
||||
@@ -127,8 +127,8 @@ class Php_lxr_comment extends Php_lxr_base {
|
||||
return cur;
|
||||
}
|
||||
public static final Gfo_msg_itm Dangling_comment = Gfo_msg_itm_.new_warn_(Php_parser.Log_nde, "dangling_comment", "dangling_comment");
|
||||
public static final byte[] Bry_bgn_mult = Bry_.new_ascii_("/*"), Bry_bgn_slash = Bry_.new_ascii_("//"), Bry_bgn_hash = Bry_.new_ascii_("#")
|
||||
, Bry_end_mult = Bry_.new_ascii_("*/"), Bry_end_nl = Bry_.new_ascii_("\n");
|
||||
public static final byte[] Bry_bgn_mult = Bry_.new_a7("/*"), Bry_bgn_slash = Bry_.new_a7("//"), Bry_bgn_hash = Bry_.new_a7("#")
|
||||
, Bry_end_mult = Bry_.new_a7("*/"), Bry_end_nl = Bry_.new_a7("\n");
|
||||
}
|
||||
class Php_lxr_var extends Php_lxr_base {
|
||||
@Override public byte Lxr_tid() {return Php_lxr_.Tid_var;}
|
||||
@@ -165,10 +165,10 @@ class Php_lxr_var extends Php_lxr_base {
|
||||
tkn_wkr.Process(tkn_factory.Var(bgn, cur));
|
||||
return cur;
|
||||
}
|
||||
private static final byte[] Bry_var = Bry_.new_ascii_("$");
|
||||
private static final byte[] Bry_var = Bry_.new_a7("$");
|
||||
}
|
||||
class Php_lxr_sym extends Php_lxr_base {
|
||||
public Php_lxr_sym(String hook_str, byte tkn_tid) {this.hook = Bry_.new_ascii_(hook_str); this.tkn_tid = tkn_tid;} private byte[] hook; byte tkn_tid;
|
||||
public Php_lxr_sym(String hook_str, byte tkn_tid) {this.hook = Bry_.new_a7(hook_str); this.tkn_tid = tkn_tid;} private byte[] hook; byte tkn_tid;
|
||||
@Override public byte Lxr_tid() {return Php_lxr_.Tid_sym;}
|
||||
@Override public void Lxr_ini(Btrie_slim_mgr trie, Php_parser_interrupt[] parser_interrupts) {
|
||||
trie.Add_obj(hook, this);
|
||||
@@ -228,10 +228,10 @@ class Php_lxr_quote extends Php_lxr_base {
|
||||
return cur;
|
||||
}
|
||||
public static final Gfo_msg_itm Dangling_quote = Gfo_msg_itm_.new_warn_(Php_parser.Log_nde, "dangling_quote", "dangling_quote");
|
||||
public static final byte[] Quote_bry_single = Bry_.new_ascii_("'"), Quote_bry_double = Bry_.new_ascii_("\"");
|
||||
public static final byte[] Quote_bry_single = Bry_.new_a7("'"), Quote_bry_double = Bry_.new_a7("\"");
|
||||
}
|
||||
class Php_lxr_keyword extends Php_lxr_base {
|
||||
public Php_lxr_keyword(String hook_str, byte tkn_tid) {this.hook = Bry_.new_ascii_(hook_str); this.tkn_tid = tkn_tid;} private byte[] hook; byte tkn_tid;
|
||||
public Php_lxr_keyword(String hook_str, byte tkn_tid) {this.hook = Bry_.new_a7(hook_str); this.tkn_tid = tkn_tid;} private byte[] hook; byte tkn_tid;
|
||||
@Override public byte Lxr_tid() {return Php_lxr_.Tid_keyword;}
|
||||
@Override public void Lxr_ini(Btrie_slim_mgr trie, Php_parser_interrupt[] parser_interrupts) {trie.Add_obj(hook, this);}
|
||||
@Override public int Lxr_make(Php_ctx ctx, int bgn, int cur) {
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Php_parser {
|
||||
byte[] src; int src_len; Php_tkn_wkr tkn_wkr; Php_tkn_factory tkn_factory = new Php_tkn_factory(); Php_ctx ctx = new Php_ctx();
|
||||
Php_parser_interrupt[] parser_interrupts = new Php_parser_interrupt[256];
|
||||
public Php_parser() {
|
||||
ListAdp list = ListAdp_.new_();
|
||||
List_adp list = List_adp_.new_();
|
||||
Init_lxr(list, new Php_lxr_declaration());
|
||||
Init_lxr(list, new Php_lxr_ws(Php_tkn_ws.Tid_space));
|
||||
Init_lxr(list, new Php_lxr_ws(Php_tkn_ws.Tid_nl));
|
||||
@@ -49,14 +49,14 @@ public class Php_parser {
|
||||
Init_lxr(list, new Php_lxr_num());
|
||||
Init_lxr(list, new Php_lxr_quote(Byte_ascii.Apos));
|
||||
Init_lxr(list, new Php_lxr_quote(Byte_ascii.Quote));
|
||||
lxrs = (Php_lxr[])list.Xto_ary(Php_lxr.class);
|
||||
lxrs = (Php_lxr[])list.To_ary(Php_lxr.class);
|
||||
lxrs_len = list.Count();
|
||||
}
|
||||
private void Init_lxr(ListAdp list, Php_lxr lxr) {
|
||||
private void Init_lxr(List_adp list, Php_lxr lxr) {
|
||||
lxr.Lxr_ini(trie, parser_interrupts);
|
||||
list.Add(lxr);
|
||||
}
|
||||
public void Parse_tkns(String src, Php_tkn_wkr tkn_wkr) {Parse_tkns(Bry_.new_utf8_(src), tkn_wkr);}
|
||||
public void Parse_tkns(String src, Php_tkn_wkr tkn_wkr) {Parse_tkns(Bry_.new_u8(src), tkn_wkr);}
|
||||
public void Parse_tkns(byte[] src, Php_tkn_wkr tkn_wkr) {
|
||||
this.src = src; this.src_len = src.length; this.tkn_wkr = tkn_wkr;
|
||||
ctx.Src_(src);
|
||||
|
||||
@@ -161,17 +161,17 @@ class Php_parser_fxt {
|
||||
public Php_itm_kv_chkr itm_kv_int(String k, int v) {return new Php_itm_kv_chkr().Key_(k).Val_(itm_int(v));}
|
||||
public Php_itm_kv_chkr itm_kv_itm(String k, Php_itm_chkr_base v) {return new Php_itm_kv_chkr().Key_(k).Val_(v);}
|
||||
public void tst_tkns(String raw, Php_tkn_chkr_base... expd) {
|
||||
byte[] raw_bry = Bry_.new_utf8_(raw);
|
||||
byte[] raw_bry = Bry_.new_u8(raw);
|
||||
parser.Parse_tkns(raw_bry, tkn_wkr);
|
||||
Php_tkn[] actl = (Php_tkn[])tkn_wkr.List().Xto_ary(Php_tkn.class);
|
||||
Php_tkn[] actl = (Php_tkn[])tkn_wkr.List().To_ary(Php_tkn.class);
|
||||
tst_mgr.Vars().Clear().Add("raw_bry", raw_bry);
|
||||
tst_mgr.Tst_ary("", expd, actl);
|
||||
log_mgr_chkr.tst(tst_mgr, tkn_wkr.Msg_log());
|
||||
}
|
||||
public void tst_lines(String raw, Php_line_assign_chkr... expd) {
|
||||
byte[] raw_bry = Bry_.new_utf8_(raw);
|
||||
byte[] raw_bry = Bry_.new_u8(raw);
|
||||
parser.Parse_tkns(raw_bry, line_wkr);
|
||||
Php_line[] actl = (Php_line[])line_wkr.List().Xto_ary(Php_line.class);
|
||||
Php_line[] actl = (Php_line[])line_wkr.List().To_ary(Php_line.class);
|
||||
tst_mgr.Vars().Clear().Add("raw_bry", raw_bry);
|
||||
tst_mgr.Tst_ary("", expd, actl);
|
||||
log_mgr_chkr.tst(tst_mgr, line_wkr.Msg_log());
|
||||
@@ -242,7 +242,7 @@ class Php_tkn_var_chkr extends Php_tkn_chkr_base {
|
||||
Php_tkn_var actl = (Php_tkn_var)actl_obj;
|
||||
int rv = 0;
|
||||
byte[] raw_bry = (byte[])mgr.Vars_get_by_key("raw_bry");
|
||||
rv += mgr.Tst_val(var_name == null, path, "var_name", var_name, String_.new_utf8_(actl.Var_name(raw_bry)));
|
||||
rv += mgr.Tst_val(var_name == null, path, "var_name", var_name, String_.new_u8(actl.Var_name(raw_bry)));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -278,7 +278,7 @@ class Php_line_assign_chkr implements Tst_chkr {
|
||||
public int Chk(Tst_mgr mgr, String path, Object actl_obj) {
|
||||
Php_line_assign actl = (Php_line_assign)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(key == null, path, "key", key, String_.new_utf8_(actl.Key().Val_obj_bry()));
|
||||
rv += mgr.Tst_val(key == null, path, "key", key, String_.new_u8(actl.Key().Val_obj_bry()));
|
||||
if (subs != null) rv += mgr.Tst_sub_ary(subs, actl.Key_subs(), "subs", rv);
|
||||
rv += mgr.Tst_sub_obj(val, actl.Val(), "val", rv);
|
||||
return rv;
|
||||
@@ -320,7 +320,7 @@ class Php_itm_txt_chkr extends Php_itm_chkr_base {
|
||||
@Override public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {
|
||||
Php_itm_var actl = (Php_itm_var)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(false, path, "val_obj_str", val_obj_str, String_.new_utf8_(actl.Val_obj_bry()));
|
||||
rv += mgr.Tst_val(false, path, "val_obj_str", val_obj_str, String_.new_u8(actl.Val_obj_bry()));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -331,7 +331,7 @@ class Php_itm_quote_chkr extends Php_itm_chkr_base {
|
||||
@Override public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {
|
||||
Php_itm_quote actl = (Php_itm_quote)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(false, path, "val_obj_str", val_obj_str, String_.new_utf8_(actl.Val_obj_bry()));
|
||||
rv += mgr.Tst_val(false, path, "val_obj_str", val_obj_str, String_.new_u8(actl.Val_obj_bry()));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -359,13 +359,13 @@ class Php_itm_kv_chkr extends Php_itm_chkr_base {
|
||||
@Override public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {
|
||||
Php_itm_kv actl = (Php_itm_kv)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(false, path, "key", key, String_.new_utf8_(actl.Key().Val_obj_bry()));
|
||||
rv += mgr.Tst_val(false, path, "key", key, String_.new_u8(actl.Key().Val_obj_bry()));
|
||||
rv += mgr.Tst_sub_obj(val, actl.Val(), path, rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Gfo_msg_log_chkr implements Tst_chkr {
|
||||
ListAdp itms = ListAdp_.new_();
|
||||
List_adp itms = List_adp_.new_();
|
||||
public Class<?> TypeOf() {return Gfo_msg_log.class;}
|
||||
public void Clear() {itms.Clear();}
|
||||
public void Add_itm(Gfo_msg_itm itm, int bgn, int end) {
|
||||
@@ -380,7 +380,7 @@ class Gfo_msg_log_chkr implements Tst_chkr {
|
||||
Gfo_msg_data[] actl_itms = new Gfo_msg_data[actl_itms_len];
|
||||
for (int i = 0; i < actl_itms_len; i++)
|
||||
actl_itms[i] = actl.Ary_get(i);
|
||||
mgr.Tst_ary("itms", (Gfo_msg_data_chkr[])itms.Xto_ary(Gfo_msg_data_chkr.class), actl_itms);
|
||||
mgr.Tst_ary("itms", (Gfo_msg_data_chkr[])itms.To_ary(Gfo_msg_data_chkr.class), actl_itms);
|
||||
}
|
||||
}
|
||||
class Gfo_msg_data_chkr implements Tst_chkr {
|
||||
|
||||
@@ -114,7 +114,7 @@ class Php_srl_itm_ary extends Php_srl_itm_base {
|
||||
subs[i].Xto_bfr(bfr, depth + 1);
|
||||
Php_srl_wtr.Indent(bfr, depth);
|
||||
bfr.Add_byte(Byte_ascii.Curly_end).Add_byte_nl();
|
||||
} static final byte[] CONST_ary_bgn = Bry_.new_ascii_("]{\n");
|
||||
} static final byte[] CONST_ary_bgn = Bry_.new_a7("]{\n");
|
||||
Php_srl_itm_kv[] subs = Php_srl_itm_kv.Ary_empty;
|
||||
}
|
||||
class Php_srl_itm_kv {
|
||||
|
||||
@@ -107,7 +107,7 @@ public class Php_srl_parser {
|
||||
case Byte_ascii.Ltr_d: // EX: 'd:1.23;'
|
||||
pos = Chk(raw, pos + 1, Byte_ascii.Colon);
|
||||
int double_end = Bry_finder.Find_fwd(raw, Byte_ascii.Semic, pos, raw_len);
|
||||
String double_str = String_.new_ascii_(raw, pos, double_end);
|
||||
String double_str = String_.new_a7(raw, pos, double_end);
|
||||
double double_val = 0;
|
||||
if (String_.Eq(double_str, "INF")) double_val = Double_.Inf_pos;
|
||||
else if (String_.Eq(double_str, "NAN")) double_val = Double_.NaN;
|
||||
@@ -120,7 +120,7 @@ public class Php_srl_parser {
|
||||
pos = Chk(raw, pos, Byte_ascii.Colon);
|
||||
pos = Chk(raw, pos, Byte_ascii.Quote);
|
||||
int str_end = pos + len_val;
|
||||
String str_val = String_.new_utf8_(raw, pos, str_end);
|
||||
String str_val = String_.new_u8(raw, pos, str_end);
|
||||
rv = factory.Str(pos, str_end, str_val);
|
||||
pos = Chk(raw, str_end, Byte_ascii.Quote);
|
||||
pos = Chk(raw, pos, Byte_ascii.Semic);
|
||||
@@ -142,7 +142,7 @@ public class Php_srl_parser {
|
||||
default: throw err_(raw, pos, "unexpected type: {0}", Char_.XtoStr(b));
|
||||
}
|
||||
return rv;
|
||||
} static final byte[] CONST_funct_bgn = Bry_.new_ascii_("O:42:\"Scribunto_LuaStandaloneInterpreterFunction\":1:{s:2:\"id\";i:"), CONST_funct_end = Bry_.new_ascii_(";}");
|
||||
} static final byte[] CONST_funct_bgn = Bry_.new_a7("O:42:\"Scribunto_LuaStandaloneInterpreterFunction\":1:{s:2:\"id\";i:"), CONST_funct_end = Bry_.new_a7(";}");
|
||||
int Parse_int_val(int bgn) {
|
||||
pos = bgn;
|
||||
pos = Chk(raw, pos + 1, Byte_ascii.Colon);
|
||||
@@ -190,7 +190,7 @@ public class Php_srl_parser {
|
||||
}
|
||||
Err err_(byte[] raw, int bgn, String fmt, Object... args) {return err_(raw, bgn, raw.length, fmt, args);}
|
||||
Err err_(byte[] raw, int bgn, int raw_len, String fmt, Object... args) {
|
||||
String msg = String_.Format(fmt, args) + " " + Int_.Xto_str(bgn) + " " + String_.new_utf8_len_safe_(raw, bgn, 20);
|
||||
String msg = String_.Format(fmt, args) + " " + Int_.Xto_str(bgn) + " " + String_.new_u8_by_len(raw, bgn, 20);
|
||||
return Err_.new_(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class Php_srl_parser_fxt {
|
||||
public Php_srl_itm_kv itm_kvi_(int k, Php_srl_itm v){return factory.Kv().Key_(itm_int_(k)).Val_(v);}
|
||||
public Php_srl_itm_kv itm_kvs_(String k, Php_srl_itm v){return factory.Kv().Key_(itm_str_(k)).Val_(v);}
|
||||
public void Test_parse(String raw_str, Php_srl_itm... expd_ary) {
|
||||
byte[] raw = Bry_.new_utf8_(raw_str);
|
||||
byte[] raw = Bry_.new_u8(raw_str);
|
||||
Php_srl_itm_ary root = parser.Parse(raw);
|
||||
Php_srl_itm root_sub = root.Subs_get_at(0).Val();
|
||||
root_sub.Xto_bfr(tmp_bfr, 0);
|
||||
|
||||
@@ -56,7 +56,7 @@ class Php_text_itm_arg implements Php_text_itm {
|
||||
public int Idx() {return idx;} private int idx;
|
||||
public void Bld(Bry_bfr bfr, byte[] src) {
|
||||
bfr.Add_byte(Byte_ascii.Tilde).Add_byte(Byte_ascii.Curly_bgn)
|
||||
.Add_int_variable(idx - ListAdp_.Base1) // php is super 1
|
||||
.Add_int_variable(idx - List_adp_.Base1) // php is super 1
|
||||
.Add_byte(Byte_ascii.Curly_end);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.core.primitives.*;
|
||||
public class Php_text_itm_parser {
|
||||
public static final byte Rslt_orig = 0, Rslt_dirty = 1, Rslt_fmt = 2;
|
||||
public boolean Quote_is_single() {return quote_is_single;} public Php_text_itm_parser Quote_is_single_(boolean v) {quote_is_single = v; return this;} private boolean quote_is_single;
|
||||
public byte[] Parse_as_bry(ListAdp tmp_list, byte[] raw, Byte_obj_ref rslt_ref, Bry_bfr tmp_bfr) {
|
||||
public byte[] Parse_as_bry(List_adp tmp_list, byte[] raw, Byte_obj_ref rslt_ref, Bry_bfr tmp_bfr) {
|
||||
Parse(tmp_list, raw, rslt_ref);
|
||||
byte[] rv = raw;
|
||||
switch (rslt_ref.Val()) {
|
||||
@@ -30,7 +30,7 @@ public class Php_text_itm_parser {
|
||||
tmp_bfr.Clear();
|
||||
int tmp_list_len = tmp_list.Count();
|
||||
for (int i = 0; i < tmp_list_len; i++) {
|
||||
Php_text_itm itm = (Php_text_itm)tmp_list.FetchAt(i);
|
||||
Php_text_itm itm = (Php_text_itm)tmp_list.Get_at(i);
|
||||
itm.Bld(tmp_bfr, raw);
|
||||
}
|
||||
rv = tmp_bfr.Xto_bry_and_clear();
|
||||
@@ -38,10 +38,10 @@ public class Php_text_itm_parser {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public void Parse(ListAdp tmp_list, byte[] raw) {
|
||||
public void Parse(List_adp tmp_list, byte[] raw) {
|
||||
Parse(tmp_list, raw, Byte_obj_ref.zero_());
|
||||
}
|
||||
public void Parse(ListAdp tmp_list, byte[] raw, Byte_obj_ref rslt) {
|
||||
public void Parse(List_adp tmp_list, byte[] raw, Byte_obj_ref rslt) {
|
||||
tmp_list.Clear();
|
||||
int raw_len = raw.length; int raw_last = raw_len - 1;
|
||||
int txt_bgn = -1;
|
||||
@@ -62,7 +62,7 @@ public class Php_text_itm_parser {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (pos_is_last) throw Err_mgr._.fmt_auto_(GRP_KEY, "backslash_is_last_char", String_.new_utf8_(raw));
|
||||
if (pos_is_last) throw Err_mgr._.fmt_auto_(GRP_KEY, "backslash_is_last_char", String_.new_u8(raw));
|
||||
switch (next_char) {
|
||||
case Byte_ascii.Backslash: next_char = Byte_ascii.Backslash; break;
|
||||
case Byte_ascii.Quote: next_char = Byte_ascii.Quote; break;
|
||||
@@ -101,7 +101,7 @@ public class Php_text_itm_parser {
|
||||
case Byte_ascii.Dollar:
|
||||
if (txt_bgn != -1) {tmp_list.Add(new Php_text_itm_text(txt_bgn, i)); txt_bgn = -1;}
|
||||
if (i == raw_last) {
|
||||
//throw Err_mgr._.fmt_auto_(GRP_KEY, "dollar_is_last_char", String_.new_utf8_(raw));
|
||||
//throw Err_mgr._.fmt_auto_(GRP_KEY, "dollar_is_last_char", String_.new_u8(raw));
|
||||
}
|
||||
int int_end = Find_fwd_non_int(raw, i + 1, raw_len); // +1 to search after $
|
||||
int int_val = Bry_.Xto_int_or(raw, i + 1, int_end, -1); // +1 to search after $
|
||||
@@ -109,7 +109,7 @@ public class Php_text_itm_parser {
|
||||
tmp_list.Add(new Php_text_itm_text(i, i + 1));
|
||||
continue;
|
||||
}
|
||||
//throw Err_mgr._.fmt_auto_(GRP_KEY, "invalid_arg", String_.new_utf8_(raw));
|
||||
//throw Err_mgr._.fmt_auto_(GRP_KEY, "invalid_arg", String_.new_u8(raw));
|
||||
tmp_list.Add(new Php_text_itm_arg(i, int_end, int_val));
|
||||
rslt_val = Rslt_fmt;
|
||||
i = int_end - 1; // -1 b/c i++ in for loop
|
||||
@@ -121,10 +121,10 @@ public class Php_text_itm_parser {
|
||||
}
|
||||
if (txt_bgn != -1) {tmp_list.Add(new Php_text_itm_text(txt_bgn, raw_len)); txt_bgn = -1; rslt_val = Rslt_dirty;}
|
||||
rslt.Val_(rslt_val);
|
||||
} private static final byte[] CONST_utf_prefix = Bry_.new_ascii_("\\u00");
|
||||
private void Parse_utf16(ListAdp rv, byte[] src, int bgn, int src_len) {
|
||||
} private static final byte[] CONST_utf_prefix = Bry_.new_a7("\\u00");
|
||||
private void Parse_utf16(List_adp rv, byte[] src, int bgn, int src_len) {
|
||||
int end = bgn + 4;
|
||||
if (end >= src_len) throw Err_mgr._.fmt_auto_(GRP_KEY, "utf16_parse", String_.new_utf8_(src));
|
||||
if (end >= src_len) throw Err_mgr._.fmt_auto_(GRP_KEY, "utf16_parse", String_.new_u8(src));
|
||||
int v = Int_.Xto_int_hex(src, bgn, end); // +2; skip "\" + "u"
|
||||
byte[] literal = gplx.intl.Utf16_.Encode_int_to_bry(v);
|
||||
rv.Add(new Php_text_itm_utf16(bgn, end, literal));
|
||||
|
||||
@@ -39,13 +39,13 @@ class Php_text_itm_fxt {
|
||||
public Php_text_itm_fxt Init_q1() {parser.Quote_is_single_(Bool_.Y); return this;}
|
||||
public Php_text_itm_fxt Init_q2() {parser.Quote_is_single_(Bool_.N); return this;}
|
||||
public void Test_parse(String raw_str, String expd) {
|
||||
ListAdp list = ListAdp_.new_();
|
||||
byte[] raw = Bry_.new_utf8_(raw_str);
|
||||
List_adp list = List_adp_.new_();
|
||||
byte[] raw = Bry_.new_u8(raw_str);
|
||||
parser.Parse(list, raw);
|
||||
Bry_bfr bfr = Bry_bfr.reset_(255);
|
||||
int list_len = list.Count();
|
||||
for (int i = 0; i < list_len; i++) {
|
||||
Php_text_itm itm = (Php_text_itm)list.FetchAt(i);
|
||||
Php_text_itm itm = (Php_text_itm)list.Get_at(i);
|
||||
itm.Bld(bfr, raw);
|
||||
}
|
||||
Tfds.Eq(expd, bfr.Xto_str_and_clear());
|
||||
|
||||
@@ -23,7 +23,7 @@ public interface Php_tkn_wkr {
|
||||
}
|
||||
class Php_tkn_wkr_tkn implements Php_tkn_wkr {
|
||||
public void Init(Php_ctx ctx) {}
|
||||
public ListAdp List() {return lines;} ListAdp lines = ListAdp_.new_();
|
||||
public List_adp List() {return lines;} List_adp lines = List_adp_.new_();
|
||||
public Gfo_msg_log Msg_log() {return msg_log;} Gfo_msg_log msg_log = new Gfo_msg_log("gplx.php");
|
||||
public void Clear() {lines.Clear(); msg_log.Clear();}
|
||||
public void Process(Php_tkn tkn) {
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Dsv_fld_parser_ {
|
||||
public static final Dsv_fld_parser Int_parser = Dsv_fld_parser_int._;
|
||||
public static final Dsv_fld_parser Line_parser__comment_is_pipe = new Dsv_fld_parser_line(Byte_ascii.Pipe);
|
||||
public static Err err_fld_unhandled(Dsv_fld_parser parser, Dsv_wkr_base wkr, int fld_idx, byte[] src, int bgn, int end) {
|
||||
throw Err_.new_fmt_("fld unhandled; parser={0} wkr={1} fld_idx={2} val={3}", ClassAdp_.NameOf_obj(parser), ClassAdp_.NameOf_obj(wkr), fld_idx, String_.new_utf8_(src, bgn, end));
|
||||
throw Err_.new_fmt_("fld unhandled; parser={0} wkr={1} fld_idx={2} val={3}", ClassAdp_.NameOf_obj(parser), ClassAdp_.NameOf_obj(wkr), fld_idx, String_.new_u8(src, bgn, end));
|
||||
}
|
||||
}
|
||||
class Dsv_fld_parser_line implements Dsv_fld_parser {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class Dsv_tbl_parser implements GfoInvkAble, RlsAble {
|
||||
fld_bgn = fld_idx = row_bgn = row_idx = 0;
|
||||
}
|
||||
public Err Err_row_bgn(String fmt, int pos) {
|
||||
return Err_.new_fmt_(fmt + "; line={0}", String_.new_utf8_(src, row_bgn, pos));
|
||||
return Err_.new_fmt_(fmt + "; line={0}", String_.new_u8(src, row_bgn, pos));
|
||||
}
|
||||
public void Update_by_fld(int pos) {
|
||||
fld_bgn = pos;
|
||||
|
||||
@@ -38,7 +38,7 @@ class Mok_int_itm implements XtoStrAble {
|
||||
}
|
||||
class Mok_int_mgr extends Mok_mgr_base {
|
||||
public void Clear() {itms.Clear();}
|
||||
@Override public XtoStrAble[] Itms() {return (XtoStrAble[])itms.Xto_ary(XtoStrAble.class);} private ListAdp itms = ListAdp_.new_();
|
||||
@Override public XtoStrAble[] Itms() {return (XtoStrAble[])itms.To_ary(XtoStrAble.class);} private List_adp itms = List_adp_.new_();
|
||||
private String fld_0;
|
||||
private int fld_1, fld_2;
|
||||
@Override public Dsv_fld_parser[] Fld_parsers() {
|
||||
@@ -46,7 +46,7 @@ class Mok_int_mgr extends Mok_mgr_base {
|
||||
}
|
||||
@Override public boolean Write_bry(Dsv_tbl_parser parser, int fld_idx, byte[] src, int bgn, int end) {
|
||||
switch (fld_idx) {
|
||||
case 0: fld_0 = String_.new_utf8_(src, bgn, end); return true;
|
||||
case 0: fld_0 = String_.new_u8(src, bgn, end); return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class Dsv_mok_fxt {
|
||||
public Mok_str_itm itm_str_(String... flds) {return new Mok_str_itm(flds);}
|
||||
public Mok_int_itm itm_int_(String fld_0, int fld_1, int fld_2) {return new Mok_int_itm(fld_0, fld_1, fld_2);}
|
||||
public void Test_load(String src, Mok_mgr_base mgr, XtoStrAble... expd) {
|
||||
mgr.Load_by_bry(Bry_.new_utf8_(src));
|
||||
mgr.Load_by_bry(Bry_.new_u8(src));
|
||||
Tfds.Eq_ary_str(expd, mgr.Itms());
|
||||
}
|
||||
}
|
||||
@@ -83,10 +83,10 @@ class Mok_str_mgr extends Mok_mgr_base {
|
||||
this.flds_len = flds_len;
|
||||
}
|
||||
public void Clear() {itms.Clear();}
|
||||
@Override public XtoStrAble[] Itms() {return (XtoStrAble[])itms.Xto_ary(XtoStrAble.class);} private ListAdp itms = ListAdp_.new_();
|
||||
private ListAdp flds = ListAdp_.new_();
|
||||
@Override public XtoStrAble[] Itms() {return (XtoStrAble[])itms.To_ary(XtoStrAble.class);} private List_adp itms = List_adp_.new_();
|
||||
private List_adp flds = List_adp_.new_();
|
||||
@Override public boolean Write_bry(Dsv_tbl_parser parser, int fld_idx, byte[] src, int bgn, int end) {
|
||||
flds.Add(String_.new_utf8_(src, bgn, end));
|
||||
flds.Add(String_.new_u8(src, bgn, end));
|
||||
return true;
|
||||
}
|
||||
@Override public Dsv_fld_parser[] Fld_parsers() {
|
||||
@@ -96,7 +96,7 @@ class Mok_str_mgr extends Mok_mgr_base {
|
||||
return rv;
|
||||
}
|
||||
@Override public void Commit_itm(Dsv_tbl_parser parser, int pos) {
|
||||
Mok_str_itm itm = new Mok_str_itm((String[])flds.Xto_ary_and_clear(String.class));
|
||||
Mok_str_itm itm = new Mok_str_itm((String[])flds.To_ary_and_clear(String.class));
|
||||
itms.Add(itm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class Js_wtr_fxt {
|
||||
wtr.Quote_char_(Byte_ascii.Apos);
|
||||
}
|
||||
public void Test_write_val_html(String raw, String expd) {
|
||||
wtr.Add_str_quote_html(Bry_.new_utf8_(raw));
|
||||
wtr.Add_str_quote_html(Bry_.new_u8(raw));
|
||||
Tfds.Eq(expd, wtr.Xto_str_and_clear());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,17 +16,20 @@ 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; import gplx.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*;
|
||||
import gplx.xowa.bldrs.css.*;
|
||||
import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
|
||||
import gplx.xowa.urls.encoders.*;
|
||||
import gplx.xowa.wmfs.*;
|
||||
import gplx.xowa.html.wtrs.*;
|
||||
import gplx.xowa.users.*;
|
||||
public interface Xoa_app {
|
||||
Xoa_app_type App_type();
|
||||
Xoa_fsys_mgr Fsys_mgr();
|
||||
Xof_cache_mgr File__cache_mgr();
|
||||
Xof_img_mgr File__img_mgr();
|
||||
Io_download_fmt File__download_fmt();
|
||||
Xowmf_mgr Wmf_mgr();
|
||||
Gfo_usr_dlg Usr_dlg();
|
||||
Bry_bfr_mkr Utl__bfr_mkr();
|
||||
@@ -35,4 +38,5 @@ public interface Xoa_app {
|
||||
Xoh_lnki_bldr Html__lnki_bldr();
|
||||
Xoa_css_extractor Html__css_installer();
|
||||
boolean Xwiki_mgr__missing(byte[] domain);
|
||||
Xou_user User();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Xoa_app_ {
|
||||
boot_mgr.Run(args);
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "2.5.2.1";
|
||||
public static final String Version = "2.5.4.1";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys;
|
||||
public static String User_agent = "";
|
||||
@@ -63,7 +63,7 @@ class Xoa_app_boot_mgr {
|
||||
log_wtr = usr_dlg.Log_wkr(); log_wtr.Log_to_session_fmt("env.init: version=~{0}", Xoa_app_.Version);
|
||||
GfuiEnv_.Init_swt(args, Xoa_app_.class);
|
||||
Io_url jar_url = Env_.AppUrl();
|
||||
Xoa_app_.Build_date = Io_mgr._.QueryFil(jar_url).ModifiedTime().XtoUtc().XtoStr_fmt("yyyy-MM-dd HH:mm");
|
||||
Xoa_app_.Build_date = Io_mgr.I.QueryFil(jar_url).ModifiedTime().XtoUtc().XtoStr_fmt("yyyy-MM-dd HH:mm");
|
||||
log_wtr.Log_to_session_fmt("env.init: jar_url=~{0}; build_date=~{1}", jar_url.NameAndExt(), Xoa_app_.Build_date);
|
||||
log_wtr.Log_to_session_fmt("env.init: op_sys=~{0}", Op_sys.Cur().Xto_str());
|
||||
chkpoint = "init_env";
|
||||
@@ -82,7 +82,7 @@ class Xoa_app_boot_mgr {
|
||||
.Fmt_hdr_(hdr)
|
||||
.Expd_add_many
|
||||
( App_cmd_arg.opt_("root_dir").Example_url_("C:\\xowa").Note_("root directory for xowa; defaults to current directory of xowa.jar")
|
||||
, App_cmd_arg.opt_("user_dir").Example_url_("C:\\xowa\\user\\" + Xou_user.Key_xowa_user).Note_("directory for user_data; defaults to '/xowa/user/" + Xou_user.Key_xowa_user + "'")
|
||||
, App_cmd_arg.opt_("user_dir").Example_url_("C:\\xowa\\user\\" + Xoue_user.Key_xowa_user).Note_("directory for user_data; defaults to '/xowa/user/" + Xoue_user.Key_xowa_user + "'")
|
||||
, App_cmd_arg.opt_("wiki_dir").Example_url_("C:\\xowa\\wiki\\").Note_("directory for wikis; defaults to '/xowa/wiki/'")
|
||||
, App_cmd_arg.opt_("bin_dir_name").Example_("windows").Note_("platform-dependent directory name inside /xowa/bin/; valid values are 'linux', 'macosx', 'windows', 'linux_64', 'macosx_64', 'windows_64'; defaults to detected version")
|
||||
, App_cmd_arg.opt_("app_mode").Example_("gui").Note_("type of app to run; valid values are 'gui', 'cmd', 'server', 'http_server'; defaults to 'gui'")
|
||||
@@ -122,7 +122,7 @@ class Xoa_app_boot_mgr {
|
||||
// init vars
|
||||
Io_url jar_dir = Env_.AppUrl().OwnerDir();
|
||||
Io_url root_dir = args_mgr.Args_get("root_dir").Val_as_url_rel_dir_or(jar_dir, jar_dir);
|
||||
Io_url user_dir = args_mgr.Args_get("user_dir").Val_as_url_rel_dir_or(root_dir.GenSubDir("user"), root_dir.GenSubDir_nest("user", Xou_user.Key_xowa_user));
|
||||
Io_url user_dir = args_mgr.Args_get("user_dir").Val_as_url_rel_dir_or(root_dir.GenSubDir("user"), root_dir.GenSubDir_nest("user", Xoue_user.Key_xowa_user));
|
||||
Io_url wiki_dir = args_mgr.Args_get("wiki_dir").Val_as_url_rel_dir_or(root_dir.GenSubDir("wiki"), root_dir.GenSubDir("wiki"));
|
||||
Io_url cmd_file = args_mgr.Args_get("cmd_file").Val_as_url_rel_fil_or(jar_dir, root_dir.GenSubFil("xowa.gfs"));
|
||||
String app_mode = args_mgr.Args_get("app_mode").Val_as_str_or("gui");
|
||||
@@ -154,7 +154,7 @@ class Xoa_app_boot_mgr {
|
||||
app.Usr_dlg().Log_wkr_(app.Log_wtr()); // NOTE: log_wtr must be set for cmd-line (else process will fail);
|
||||
|
||||
// run gfs
|
||||
gplx.xowa.users.prefs.Prefs_rename_mgr._.Check(app.User().Fsys_mgr().App_data_cfg_user_fil());
|
||||
gplx.xowa.users.prefs.Prefs_rename_mgr._.Check(app.Usere().Fsys_mgr().App_data_cfg_user_fil());
|
||||
try {app.Gfs_mgr().Run_url(cmd_file); chkpoint = "run_url";}
|
||||
catch (Exception e) {
|
||||
usr_dlg.Warn_many("", "", "script file failed: ~{0} ~{1} ~{2}", chkpoint, cmd_file.Raw(), Err_.Message_gplx(e));
|
||||
@@ -201,7 +201,7 @@ class Xoa_app_boot_mgr {
|
||||
}
|
||||
private static byte[] System_lang() {
|
||||
String lang_code = Env_.Env_prop__user_language();
|
||||
byte[] lang_code_bry = Bry_.new_ascii_(lang_code);
|
||||
byte[] lang_code_bry = Bry_.new_a7(lang_code);
|
||||
Xol_lang_itm lang_itm = Xol_lang_itm_.Get_by_key(lang_code_bry);
|
||||
return lang_itm == null ? Xol_lang_.Key_en : lang_itm.Key();
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ 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; import gplx.*;
|
||||
import gplx.dbs.*; import gplx.xowa.apps.*;
|
||||
import gplx.dbs.*; import gplx.xowa.apps.*; import gplx.xowa.files.exts.*;
|
||||
public class Xoa_app_fxt {
|
||||
public static Xoae_app app_() {
|
||||
Io_mgr._.InitEngine_mem();
|
||||
Io_mgr.I.InitEngine_mem();
|
||||
Db_conn_bldr.I.Reg_default_mem();
|
||||
return app_("linux", Io_url_.mem_dir_("mem/xowa/"));
|
||||
}
|
||||
@@ -44,6 +44,14 @@ public class Xoa_app_fxt {
|
||||
app.Wiki_mgr().Add(rv);
|
||||
return rv;
|
||||
}
|
||||
public static void repo_(Xoae_app app, Xowe_wiki wiki) {
|
||||
app.File_mgr().Repo_mgr().Set("src:wiki", "mem/wiki/repo/src/", wiki.Domain_str()).Ext_rules_(Xof_rule_grp.Grp_app_default).Dir_depth_(2);
|
||||
app.File_mgr().Repo_mgr().Set("trg:wiki", "mem/wiki/repo/trg/", wiki.Domain_str()).Ext_rules_(Xof_rule_grp.Grp_app_default).Dir_depth_(2).Primary_(true);
|
||||
wiki.File_mgr().Repo_mgr().Add_repo(Bry_.new_u8("src:wiki"), Bry_.new_u8("trg:wiki"));
|
||||
app.File_mgr().Repo_mgr().Set("src:c", "mem/wiki/repo/src/", "commons.wikimedia.org").Ext_rules_(Xof_rule_grp.Grp_app_default).Dir_depth_(2);
|
||||
app.File_mgr().Repo_mgr().Set("trg:c", "mem/wiki/repo/trg/", "commons.wikimedia.org").Ext_rules_(Xof_rule_grp.Grp_app_default).Dir_depth_(2).Primary_(true);
|
||||
wiki.File_mgr().Repo_mgr().Add_repo(Bry_.new_u8("src:c"), Bry_.new_u8("trg:c"));
|
||||
}
|
||||
public static void Init_gui(Xoae_app app, Xowe_wiki wiki) {
|
||||
app.Gui_mgr().Browser_win().Init_by_kit(gplx.gfui.Mem_kit._);
|
||||
app.Gui_mgr().Browser_win().Tab_mgr().Tabs_new_init(wiki, Xoae_page.Empty);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user