1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-06-14 21:52:10 -04:00
parent 51e6188c1e
commit fe0ce6340d
159 changed files with 1381 additions and 483 deletions

View File

@@ -23,27 +23,23 @@ public class Thread_adp implements Runnable {
this.name = name; this.invk = invk; this.cmd = cmd; this.msg = msg;
this.ctor_ThreadAdp();
}
public Thread_adp Start() {thread.start(); return this;}
void ctor_ThreadAdp() {
this.thread = name == null ? new Thread(this) : new Thread(this, name);
}
public Thread Under_thread() {return thread;} private Thread thread;
public Thread_adp Start() {
thread.start();
return this;
}
public void Interrupt() {thread.interrupt();}
public void Join() {
try {
thread.join();
}
catch (Exception e) {
Err_.Noop(e);
}
try {thread.join();}
catch (Exception e) {Err_.Noop(e);}
}
// public void Stop() {thread.stop();}
public boolean IsAlive() {return thread.isAlive();}
void ctor_ThreadAdp() {
if (name == null)
thread = new Thread(this);
else
thread = new Thread(this, name);
}
@Override public void run() {
invk.Invk(GfsCtx._, 0, cmd, msg);
}
public Thread Under_thread() {return thread;} private Thread thread;
public static final Thread_adp Null = new Thread_adp(Thread_adp_.Name_null, GfoInvkAble_.Null, "", GfoMsg_.Null);
}

View File

@@ -25,9 +25,9 @@ public class Thread_adp_ {
try {o.wait();}
catch (InterruptedException e) {throw Err_.err_key_(e, "gplx.Thread", "thread wait");}
}
public static Thread_adp invk_(GfoInvkAble invk, String cmd) {return invk_(Name_null, invk, cmd);}
public static Thread_adp invk_(GfoInvkAble invk, String cmd) {return invk_(Name_null, invk, cmd);}
public static Thread_adp invk_(String name, GfoInvkAble invk, String cmd) {return new Thread_adp(name, invk, cmd, GfoMsg_.Null);}
public static Thread_adp invk_msg_(GfoInvkAble invk, GfoMsg msg) {return invk_msg_(Name_null, invk, msg);}
public static Thread_adp invk_msg_(GfoInvkAble invk, GfoMsg msg) {return invk_msg_(Name_null, invk, msg);}
public static Thread_adp invk_msg_(String name, GfoInvkAble invk, GfoMsg msg) {return new Thread_adp(name, invk, msg.Key(), msg);}
public static void Run_invk_msg(String name, GfoInvkAble invk, GfoMsg m) {
Thread_adp_.invk_msg_(name, invk, m).Start();

View File

@@ -101,7 +101,7 @@ public class Bry_ {
}
}
}
public static byte[] Coalesce(byte[] orig, byte[] val_if_not_blank) {return Bry_.Len_eq_0(val_if_not_blank) ? orig : val_if_not_blank;}
public static byte[] Coalesce(byte[] orig, byte[] val_if_not_blank) {return Bry_.Len_eq_0(orig) ? val_if_not_blank : orig;}
public static byte Get_at_end_or_fail(byte[] bry) {
if (bry == null) throw Err_.new_("bry is null");
int bry_len = bry.length;

View File

@@ -393,7 +393,7 @@ public class Bry_bfr {
else if (o_type == Bry_bfr.class) Add_bfr_and_preserve((Bry_bfr)o);
else if (o_type == DateAdp.class) Add_dte((DateAdp)o);
else if (o_type == Io_url.class) Add(((Io_url)o).RawBry());
else if (o_type == boolean.class) Add_yn(Bool_.cast_(o));
else if (o_type == Boolean.class) Add_yn(Bool_.cast_(o));
else if (o_type == Double.class) Add_double(Double_.cast_(o));
else if (o_type == Float.class) Add_float(Float_.cast_(o));
else ((Bry_fmtr_arg)o).XferAry(this, 0);

View File

@@ -47,6 +47,10 @@ public class DateAdp_ implements GfoInvkAble {
return new DateAdp(y, M, d, h, m, s, f);
}
public static DateAdp cast_(Object arg) {try {return (DateAdp)arg;} catch(Exception exc) {throw Err_.type_mismatch_exc_(exc, DateAdp.class, arg);}}
public static DateAdp parse_iso8561_or(String raw, DateAdp or) {
try {return parse_iso8561(raw);}
catch (Exception e) {Err_.Noop(e); return or;}
}
public static DateAdp parse_iso8561(String raw) { // NOTE: for now, same as parse_gplx
int[] ary = date_parser.Parse_iso8651_like(raw);
if (ary[1] < 1 || ary[1] > 12) return DateAdp_.MinValue; // guard against invalid month

View File

@@ -20,10 +20,10 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegxAdp {
void Under_sync() {
try {under = Pattern.compile(pattern, Pattern.DOTALL);}
try {under = Pattern.compile(pattern, Pattern.DOTALL | Pattern.UNICODE_CHARACTER_CLASS);} // JRE.7:UNICODE_CHARACTER_CLASS; added during %w fix for en.w:A#; DATE:2015-06-10
catch (Exception e) { // NOTE: if invalid, then default to empty pattern (which should return nothing); EX:d:〆る generates [^]; DATE:2013-10-20
pattern_is_invalid = true;
under = Pattern.compile("", Pattern.DOTALL);
under = Pattern.compile("", Pattern.DOTALL | Pattern.UNICODE_CHARACTER_CLASS);
}
} private Pattern under;
public RegxMatch Match(String input, int bgn) {

View File

@@ -185,7 +185,7 @@ public class IoEngine_memory extends IoEngine_base {
Io_url src = Io_url_.mem_fil_(xrg.Src());
if (!ExistsFil_api(src)) {
xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_file_not_found);
return Io_stream_rdr_.Null;
return Io_stream_rdr_.Noop;
}
byte[] bry = Bry_.new_u8(FetchFil(Io_url_.mem_fil_(xrg.Src())).Text());
return Io_stream_rdr_.mem_(bry);

View File

@@ -63,7 +63,7 @@ public class Io_stream_rdr_ {
}
} finally {rdr.Rls();}
}
public static final Io_stream_rdr Null = new Io_stream_rdr_noop();
public static final Io_stream_rdr Noop = new Io_stream_rdr_noop();
public static Io_stream_rdr mem_(String v) {return mem_(Bry_.new_u8(v));}
public static Io_stream_rdr mem_(byte[] v) {
Io_stream_rdr rv = new Io_stream_rdr_adp(Stream_new_mem(v));

View File

@@ -45,7 +45,7 @@ class DataRdr_null implements DataRdr {
public byte ReadByte(String key) {return Byte_.Min_value;} public byte ReadByteOr(String key, byte or) {return or;}
public DecimalAdp ReadDecimal(String key) {return DecimalAdp_.Zero;}public DecimalAdp ReadDecimalOr(String key, DecimalAdp or) {return or;}
public DateAdp ReadDate(String key) {return DateAdp_.MinValue;} public DateAdp ReadDateOr(String key, DateAdp or) {return or;}
public gplx.ios.Io_stream_rdr ReadRdr(String key) {return gplx.ios.Io_stream_rdr_.Null;}
public gplx.ios.Io_stream_rdr ReadRdr(String key) {return gplx.ios.Io_stream_rdr_.Noop;}
public boolean MoveNextPeer() {return false;}
public DataRdr Subs() {return this;}
public DataRdr Subs_byName(String name) {return this;}

View File

@@ -179,7 +179,7 @@ public abstract class DataRdr_base implements SrlMgr {
try {return (byte[])val;}
catch (Exception exc) {Err_dataRdr_ReadFailed_useOr(exc, byte[].class, key, val, or); return or;}
}
public gplx.ios.Io_stream_rdr ReadRdr(String key) {return gplx.ios.Io_stream_rdr_.Null;}
public gplx.ios.Io_stream_rdr ReadRdr(String key) {return gplx.ios.Io_stream_rdr_.Noop;}
public boolean SrlBoolOr(String key, boolean or) {return ReadBoolOr(key, or);}
public byte SrlByteOr(String key, byte or) {return ReadByteOr(key, or);}
public int SrlIntOr(String key, int or) {return ReadIntOr(key, or);}