mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
v2.10.3.1
This commit is contained in:
parent
8e18af05b6
commit
4f43f51b18
@ -56,7 +56,7 @@ public class Err extends RuntimeException {
|
||||
String nl_str = called_by_log ? "\t" : "\n";
|
||||
String rv = ""; //nl_str + "----------------------------------------------------------------------" + nl_str;
|
||||
for (int i = 0; i < msgs_idx; ++i) {
|
||||
rv += "[err " + Int_.Xto_str(i) + "] " + msgs_ary[i].To_str() + nl_str;
|
||||
rv += "[err " + Int_.To_str(i) + "] " + msgs_ary[i].To_str() + nl_str;
|
||||
}
|
||||
if (include_trace)
|
||||
rv += "[trace]:" + Trace_to_str(is_gplx, called_by_log, trace_ignore, trace == null ? Err_.Trace_lang(this) : trace);
|
||||
|
@ -52,6 +52,7 @@ public class Err_ {
|
||||
}
|
||||
|
||||
public static String Message_lang(Exception e) {return e.getMessage();}
|
||||
public static String Message_lang_error(Error e) {return e.getMessage();}
|
||||
public static String Trace_lang(Exception e) {return Trace_lang_exec(e.getStackTrace());}
|
||||
public static String Trace_lang(Error e) {return Trace_lang_exec(e.getStackTrace());}
|
||||
private static String Trace_lang_exec(StackTraceElement[] ary) {
|
||||
|
@ -108,7 +108,7 @@ public class Btrie_fast_mgr {
|
||||
pos = match_pos;
|
||||
}
|
||||
}
|
||||
return dirty ? tmp_bfr.Xto_bry_and_clear() : src;
|
||||
return dirty ? tmp_bfr.To_bry_and_clear() : src;
|
||||
}
|
||||
public static Btrie_fast_mgr cs() {return new Btrie_fast_mgr(Bool_.N);}
|
||||
public static Btrie_fast_mgr ci_a7() {return new Btrie_fast_mgr(Bool_.Y);}
|
||||
|
@ -79,7 +79,7 @@ public class Btrie_slim_itm {
|
||||
Btrie_slim_itm rv = new Btrie_slim_itm(b, val, case_any);
|
||||
ary[ary_len] = rv;
|
||||
ary_len = new_len;
|
||||
ByteHashItm_sorter._.Sort(ary, ary_len);
|
||||
ByteHashItm_sorter.Instance.Sort(ary, ary_len);
|
||||
return rv;
|
||||
}
|
||||
public void Ary_del(byte b) {
|
||||
@ -126,5 +126,5 @@ class ByteHashItm_sorter {// quicksort
|
||||
if (lo < j) Sort_recurse(lo, j);
|
||||
if (i < hi) Sort_recurse(i, hi);
|
||||
}
|
||||
public static final ByteHashItm_sorter _ = new ByteHashItm_sorter(); ByteHashItm_sorter() {}
|
||||
public static final ByteHashItm_sorter Instance = new ByteHashItm_sorter(); ByteHashItm_sorter() {}
|
||||
}
|
||||
|
@ -21,11 +21,12 @@ public class Btrie_slim_mgr implements Btrie_mgr {
|
||||
Btrie_slim_mgr(boolean case_match) {root = new Btrie_slim_itm(Byte_.Zero, null, !case_match);} private Btrie_slim_itm root;
|
||||
public int Count() {return count;} private int count;
|
||||
public int Match_pos() {return match_pos;} private int match_pos;
|
||||
public Object Match_exact(byte[] src) {return src == null ? null : Match_exact(src, 0, src.length);}
|
||||
public Object Match_exact(byte[] src, int bgn_pos, int end_pos) {
|
||||
Object rv = Match_bgn_w_byte(src[bgn_pos], src, bgn_pos, end_pos);
|
||||
return rv == null ? null : match_pos - bgn_pos == end_pos - bgn_pos ? rv : null;
|
||||
}
|
||||
public Object Match_bgn(byte[] src, int bgn_pos, int end_pos) {return Match_bgn_w_byte(src[bgn_pos], src, bgn_pos, end_pos);}
|
||||
public Object Match_bgn(byte[] src, int bgn_pos, int end_pos) {return bgn_pos < end_pos ? Match_bgn_w_byte(src[bgn_pos], src, bgn_pos, end_pos) : null;} // handle out of bounds gracefully; EX: Match_bgn("abc", 3, 3) should return null not fail
|
||||
public Object Match_bgn_w_byte(byte b, byte[] src, int bgn_pos, int src_len) {
|
||||
Object rv = null; int cur_pos = match_pos = bgn_pos;
|
||||
Btrie_slim_itm cur = root;
|
||||
@ -47,6 +48,7 @@ public class Btrie_slim_mgr implements Btrie_mgr {
|
||||
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_bry(byte[] key, byte[] val) {return (Btrie_slim_mgr)Add_obj(key, val);}
|
||||
public Btrie_slim_mgr Add_bry_byte(byte b, byte val) {return (Btrie_slim_mgr)Add_obj(new byte[] {b}, Byte_obj_val.new_(val));}
|
||||
public Btrie_slim_mgr Add_bry_byte(byte[] bry, byte val) {return (Btrie_slim_mgr)Add_obj(bry, Byte_obj_val.new_(val));}
|
||||
public Btrie_slim_mgr Add_str_byte__many(byte val, String... ary) {
|
||||
@ -127,7 +129,7 @@ public class Btrie_slim_mgr implements Btrie_mgr {
|
||||
pos = match_pos;
|
||||
}
|
||||
}
|
||||
return dirty ? tmp_bfr.Xto_bry_and_clear() : src;
|
||||
return dirty ? tmp_bfr.To_bry_and_clear() : src;
|
||||
}
|
||||
public void Clear() {root.Clear(); count = 0;}
|
||||
public static Btrie_slim_mgr cs() {return new Btrie_slim_mgr(Bool_.Y);}
|
||||
|
@ -62,5 +62,5 @@ public class Console_adp__sys implements Console_adp {
|
||||
catch (java.io.UnsupportedEncodingException e) {throw Err_.new_wo_type("unsupported exception");}
|
||||
ps.println(s);
|
||||
}
|
||||
public static final Console_adp__sys I = new Console_adp__sys();
|
||||
public static final Console_adp__sys Instance = new Console_adp__sys();
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class Utf8__tst {
|
||||
// bgn = end;
|
||||
// bgn_bry = end_by_codepoint_next;
|
||||
// }
|
||||
// Tfds.WriteText(bfr.Xto_str_and_clear());
|
||||
// Tfds.WriteText(bfr.To_str_and_clear());
|
||||
// }
|
||||
}
|
||||
class Utf8__fxt {
|
||||
|
@ -21,8 +21,8 @@ public class Js_wtr {
|
||||
private int arg_idx = 0, ary_idx = 0;
|
||||
public byte Quote_char() {return quote_char;} public Js_wtr Quote_char_(byte v) {quote_char = v; return this;} private byte quote_char = Byte_ascii.Quote;
|
||||
public void Clear() {bfr.Clear();}
|
||||
public String To_str() {return bfr.Xto_str();}
|
||||
public String To_str_and_clear() {return bfr.Xto_str_and_clear();}
|
||||
public String To_str() {return bfr.To_str();}
|
||||
public String To_str_and_clear() {return bfr.To_str_and_clear();}
|
||||
public Js_wtr Func_init(String name) {return Func_init(Bry_.new_u8(name));}
|
||||
public Js_wtr Func_init(byte[] name) {
|
||||
bfr.Add(name).Add_byte(Byte_ascii.Paren_bgn);
|
||||
|
@ -20,7 +20,7 @@ public class Bool_obj_ref {
|
||||
public boolean Val() {return val;} private boolean val;
|
||||
public boolean Val_y() {return val;}
|
||||
public boolean Val_n() {return !val;}
|
||||
public String Val_as_str_yn() {return Yn.Xto_str(val);}
|
||||
public String Val_as_str_yn() {return Yn.To_str(val);}
|
||||
public Bool_obj_ref Val_y_() {val = true; return this;}
|
||||
public Bool_obj_ref Val_n_() {val = false; return this;}
|
||||
public Bool_obj_ref Val_(boolean v) {val = v; return this;}
|
||||
|
@ -21,7 +21,7 @@ public class Byte_obj_ref {
|
||||
public Byte_obj_ref Val_(byte v) {val = v; return this;}
|
||||
@Override public int hashCode() {return val;}
|
||||
@Override public boolean equals(Object obj) {return obj == null ? false : val == ((Byte_obj_ref)obj).Val();}
|
||||
@Override public String toString() {return Int_.Xto_str(val);}
|
||||
@Override public String toString() {return Int_.To_str(val);}
|
||||
public static Byte_obj_ref zero_() {return new_(Byte_.Zero);}
|
||||
public static Byte_obj_ref new_(byte val) {
|
||||
Byte_obj_ref rv = new Byte_obj_ref();
|
||||
|
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.core.primitives; import gplx.*; import gplx.core.*;
|
||||
public class Byte_obj_val {
|
||||
public byte Val() {return val;} private byte val;
|
||||
@Override public String toString() {return Int_.Xto_str(val);}
|
||||
@Override public String toString() {return Int_.To_str(val);}
|
||||
@Override public int hashCode() {return val;}
|
||||
@Override public boolean equals(Object obj) {return obj == null ? false : val == ((Byte_obj_val)obj).Val();}
|
||||
public static Byte_obj_val new_(byte val) {
|
||||
|
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.core.primitives; import gplx.*; import gplx.core.*;
|
||||
public class Double_obj_val implements CompareAble {
|
||||
public double Val() {return val;} double val;
|
||||
@Override public String toString() {return Double_.Xto_str(val);}
|
||||
@Override public String toString() {return Double_.To_str(val);}
|
||||
@Override public int hashCode() {return (int)val;}
|
||||
@Override public boolean equals(Object obj) {return obj == null ? false : val == ((Double_obj_val)obj).Val();}
|
||||
public int compareTo(Object obj) {Double_obj_val comp = (Double_obj_val)obj; return Double_.Compare(val, comp.val);}
|
||||
|
@ -23,8 +23,8 @@ public class Int_obj_ref {
|
||||
public int Val_add(int v) {val += v; return val;}
|
||||
public Int_obj_ref Val_zero_() {val = 0; return this;}
|
||||
public Int_obj_ref Val_neg1_() {val = -1; return this;}
|
||||
public String Val_as_str() {return Int_.Xto_str(val);}
|
||||
@Override public String toString() {return Int_.Xto_str(val);}
|
||||
public String Val_as_str() {return Int_.To_str(val);}
|
||||
@Override public String toString() {return Int_.To_str(val);}
|
||||
@Override public int hashCode() {return val;}
|
||||
@Override public boolean equals(Object obj) {return val == ((Int_obj_ref)obj).Val();}
|
||||
public static Int_obj_ref neg1_() {return new_(-1);}
|
||||
|
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.core.primitives; import gplx.*; import gplx.core.*;
|
||||
public class Int_obj_val implements CompareAble {
|
||||
public int Val() {return val;} int val;
|
||||
@Override public String toString() {return Int_.Xto_str(val);}
|
||||
@Override public String toString() {return Int_.To_str(val);}
|
||||
@Override public int hashCode() {return val;}
|
||||
@Override public boolean equals(Object obj) {return obj == null ? false : val == ((Int_obj_val)obj).Val();}
|
||||
public int compareTo(Object obj) {Int_obj_val comp = (Int_obj_val)obj; return Int_.Compare(val, comp.val);}
|
||||
|
@ -30,7 +30,7 @@ public interface String_bldr {
|
||||
String_bldr Add_str_w_crlf(String v);
|
||||
String_bldr Add_spr_unless_first(String s, String spr, int i);
|
||||
String_bldr Clear();
|
||||
String Xto_str_and_clear();
|
||||
String To_str_and_clear();
|
||||
String To_str();
|
||||
int Count();
|
||||
String_bldr Add(byte[] v);
|
||||
@ -70,7 +70,7 @@ abstract class String_bldr_base implements String_bldr {
|
||||
return this;
|
||||
}
|
||||
public String_bldr Clear() {Del(0, Count()); return this;}
|
||||
public String Xto_str_and_clear() {
|
||||
public String To_str_and_clear() {
|
||||
String rv = To_str();
|
||||
Clear();
|
||||
return rv;
|
||||
|
@ -39,7 +39,7 @@ public class Thread_adp implements Runnable {
|
||||
// public void Stop() {thread.stop();}
|
||||
public boolean IsAlive() {return thread.isAlive();}
|
||||
@Override public void run() {
|
||||
invk.Invk(GfsCtx._, 0, cmd, msg);
|
||||
invk.Invk(GfsCtx.Instance, 0, cmd, msg);
|
||||
}
|
||||
public static final Thread_adp Null = new Thread_adp(Thread_adp_.Name_null, GfoInvkAble_.Null, "", GfoMsg_.Null);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class Gfo_msg_grp_ {
|
||||
public static int Uid_next() {return uid_next++;} static int uid_next = 0;
|
||||
public static byte[] Path(byte[] owner_path, byte[] key) {
|
||||
if (owner_path != Bry_.Empty) tmp_bfr.Add(owner_path).Add_byte(Byte_ascii.Dot); // only add "." if owner_path is available; prevents creating ".gplx"
|
||||
return tmp_bfr.Add(key).Xto_bry_and_clear();
|
||||
return tmp_bfr.Add(key).To_bry_and_clear();
|
||||
}
|
||||
static Bry_bfr tmp_bfr = Bry_bfr.reset_(256);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class Gfo_msg_itm implements Gfo_msg_obj {
|
||||
if (fmtr == null) fmtr = Bry_fmtr.new_bry_(fmt).Compile();
|
||||
if (fmtr.Fmt_args_exist()) {
|
||||
fmtr.Bld_bfr_many(tmp_bfr, vals);
|
||||
return tmp_bfr.Xto_str_and_clear();
|
||||
return tmp_bfr.To_str_and_clear();
|
||||
}
|
||||
else
|
||||
return String_.new_u8(fmt);
|
||||
@ -47,7 +47,7 @@ public class Gfo_msg_itm implements Gfo_msg_obj {
|
||||
if (fmtr == null) fmtr = Bry_fmtr.new_bry_(fmt).Compile();
|
||||
if (fmtr.Fmt_args_exist()) {
|
||||
fmtr.Bld_bfr_one(tmp_bfr, val);
|
||||
return tmp_bfr.Xto_str_and_clear();
|
||||
return tmp_bfr.To_str_and_clear();
|
||||
}
|
||||
else
|
||||
return String_.new_u8(fmt);
|
||||
|
@ -73,8 +73,8 @@ public class Gfo_msg_root {
|
||||
return cur_list;
|
||||
}
|
||||
Gfo_msg_grp root;
|
||||
Ordered_hash owners = Ordered_hash_.new_();
|
||||
Ordered_hash owners = Ordered_hash_.New();
|
||||
int uid_list_next = 0;
|
||||
int uid_item_next = 0;
|
||||
public static final Gfo_msg_root _ = new Gfo_msg_root("gplx");
|
||||
public static final Gfo_msg_root Instance = new Gfo_msg_root("gplx");
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ public class Bool_ implements GfoInvkAble {
|
||||
public static int To_int(boolean v) {return v ? Y_int : N_int;}
|
||||
public static byte To_byte(boolean v) {return v ? Y_byte : N_byte;}
|
||||
public static String To_str_lower(boolean v) {return v ? True_str : False_str;}
|
||||
public static final boolean[] Ary_empty = new boolean[0];
|
||||
|
||||
public static final Bool_ Gfs = new Bool_();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
|
@ -25,7 +25,7 @@ public class Byte__tst {
|
||||
tst_int_( 255, 255);
|
||||
tst_int_( 256, 0); // NOTE: 256 will cast to 1; (byte)256 works same in both JAVA/.NET
|
||||
} void tst_int_(int v, int expd) {Tfds.Eq((byte)expd, Byte_.By_int(v));} // WORKAROUND/JAVA: expd is of type int b/c java promotes numbers to ints
|
||||
@Test public void XtoInt() {
|
||||
@Test public void To_int() {
|
||||
tst_XtoInt( 0, 0);
|
||||
tst_XtoInt( 127, 127);
|
||||
tst_XtoInt( 128, 128);
|
||||
|
@ -101,6 +101,7 @@ public class Byte_ascii {
|
||||
, Quote_bry = new byte[] {Byte_ascii.Quote}
|
||||
, Hash_bry = new byte[] {Byte_ascii.Hash}
|
||||
, Dot_bry = new byte[] {Byte_ascii.Dot}
|
||||
, Angle_bgn_bry = new byte[] {Byte_ascii.Angle_bgn}
|
||||
, Comma_bry = new byte[] {Byte_ascii.Comma}
|
||||
, Colon_bry = new byte[] {Byte_ascii.Colon}
|
||||
, Amp_bry = new byte[] {Byte_ascii.Amp}
|
||||
|
@ -19,14 +19,6 @@ package gplx;
|
||||
public class Char_ {
|
||||
public static final Class<?> Cls_ref_type = Character.class;
|
||||
public static final char Null = '\0', NewLine = '\n';
|
||||
public static final int CharLen = 1;
|
||||
public static final int AsciiZero = 48;
|
||||
public static boolean IsNumber(char c) {
|
||||
switch (c) {
|
||||
case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public static boolean IsCaseLower(char c) {return Character.isLowerCase(c);}
|
||||
public static boolean IsLetterOrDigit(char c) {return Character.isLetterOrDigit(c);}
|
||||
public static boolean IsLetterEnglish(char c) {
|
||||
@ -48,12 +40,23 @@ public class Char_ {
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public static boolean IsNumber(char c) {
|
||||
switch (c) {
|
||||
case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public static boolean IsWhitespace(char c) {
|
||||
switch (c) {
|
||||
case ' ': case '\t': case '\n': case '\r': return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public static boolean In(char match, char... ary) {
|
||||
for (char itm : ary)
|
||||
if (itm == match) return true;
|
||||
return false;
|
||||
}
|
||||
public static int To_int_or(char c, int or) {
|
||||
switch (c) {
|
||||
case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4;
|
||||
@ -61,17 +64,10 @@ public class Char_ {
|
||||
default: return or;
|
||||
}
|
||||
}
|
||||
public static boolean In(char match, char... ary) {
|
||||
for (char itm : ary)
|
||||
if (itm == match) return true;
|
||||
return false;
|
||||
}
|
||||
public static String To_str(char[] ary, int pos, int length) {return new String(ary, pos, length);}
|
||||
public static byte[] XtoByteAry(int v) {return Bry_.new_u8(Char_.To_str((char)v));}
|
||||
public static char XbyInt(int i) {return (char)i;}
|
||||
public static String To_str(int b) {return To_str((char)b);}
|
||||
public static String To_str(char c) {return String.valueOf(c);}
|
||||
public static byte XtoByte(char c) {return (byte)c;}
|
||||
public static char By_int(int i) {return (char)i;}
|
||||
public static char cast(Object o) {try {return (Character)o;} catch(Exception e) {throw Err_.new_type_mismatch_w_exc(e, char.class, o);}}
|
||||
public static char parse(String raw) {try {return raw.charAt(0);} catch(Exception exc) {throw Err_.new_parse_exc(exc, char.class, raw);}}
|
||||
}
|
||||
|
@ -36,15 +36,15 @@ public class Double_ {
|
||||
try {String s = String_.as_(v); return s == null ? Double_.cast(v) : Double_.parse(s);}
|
||||
catch (Exception e) {throw Err_.new_cast(e, double.class, v);}
|
||||
}
|
||||
public static String Xto_str(double v) {
|
||||
public static String To_str(double v) {
|
||||
int v_int = (int)v;
|
||||
return v - v_int == 0 ? Int_.Xto_str(v_int) : Double.toString(v);
|
||||
return v - v_int == 0 ? Int_.To_str(v_int) : Double.toString(v);
|
||||
}
|
||||
public static String Xto_str_loose(double v) {
|
||||
public static String To_str_loose(double v) {
|
||||
int v_as_int = (int)v;
|
||||
return v == v_as_int
|
||||
? Int_.Xto_str(v_as_int) // convert to int, and call print String to eliminate any trailing decimal places
|
||||
: Float_.Xto_str((float)v); // calling ((float)v).toString is better at removing trailing 0s than String.format("%g", v). note that .net .toString() handles it better; EX:2449.600000000000d; DATE:2014-07-29
|
||||
? Int_.To_str(v_as_int) // convert to int, and call print String to eliminate any trailing decimal places
|
||||
: Float_.To_str((float)v); // calling ((float)v).toString is better at removing trailing 0s than String.format("%g", v). note that .net .toString() handles it better; EX:2449.600000000000d; DATE:2014-07-29
|
||||
}
|
||||
public static int Compare(double lhs, double rhs) {
|
||||
if (lhs == rhs) return CompareAble_.Same;
|
||||
|
@ -25,5 +25,5 @@ public class Double__tst {
|
||||
}
|
||||
}
|
||||
class Double__fxt {
|
||||
public void Test_Xto_str_loose(double v, String expd) {Tfds.Eq(expd, Double_.Xto_str_loose(v));}
|
||||
public void Test_Xto_str_loose(double v, String expd) {Tfds.Eq(expd, Double_.To_str_loose(v));}
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ public class Float_ {
|
||||
public static boolean IsNaN(float v) {return Float.isNaN(v);}
|
||||
public static float cast(Object obj) {try {return (Float)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, float.class, obj);}}
|
||||
public static float parse(String raw) {try {return Float.parseFloat(raw);} catch(Exception exc) {throw Err_.new_parse_exc(exc, float.class, raw);}}
|
||||
public static String Xto_str(float v) {
|
||||
public static String To_str(float v) {
|
||||
int v_int = (int)v;
|
||||
return v - v_int == 0 ? Int_.Xto_str(v_int) : Float.toString(v);
|
||||
return v - v_int == 0 ? Int_.To_str(v_int) : Float.toString(v);
|
||||
}
|
||||
public static float Div(int val, int divisor) {return (float)val / (float)divisor;}
|
||||
public static float Div(long val, long divisor) {return (float)val / (float)divisor;}
|
||||
|
@ -128,11 +128,11 @@ public class Int_ implements GfoInvkAble {
|
||||
if (val < 0) throw Err_.new_wo_type("key must be >= 0", "key", key, "val", val);
|
||||
return this;
|
||||
}
|
||||
public static String Xto_str_pad_bgn_space(int v, int reqdPlaces) {return Xto_str_pad_bgn_zero(v, reqdPlaces, Byte_ascii.Space, true);} // EX: 1, 3 returns " 1"
|
||||
public static String Xto_str_pad_bgn_zero(int v, int reqdPlaces) {return Xto_str_pad_bgn_zero(v, reqdPlaces, Byte_ascii.Num_0, true);} // EX: 1, 3 returns "001"
|
||||
static String Xto_str_pad_bgn_zero(int val, int places, byte pad_chr, boolean bgn) {
|
||||
public static String To_str_pad_bgn_space(int v, int reqdPlaces) {return To_str_pad_bgn_zero(v, reqdPlaces, Byte_ascii.Space, true);} // EX: 1, 3 returns " 1"
|
||||
public static String To_str_pad_bgn_zero(int v, int reqdPlaces) {return To_str_pad_bgn_zero(v, reqdPlaces, Byte_ascii.Num_0, true);} // EX: 1, 3 returns "001"
|
||||
static String To_str_pad_bgn_zero(int val, int places, byte pad_chr, boolean bgn) {
|
||||
int len = DigitCount(val);
|
||||
int pad_len = places - len; if (pad_len < 0) return Int_.Xto_str(val);
|
||||
int pad_len = places - len; if (pad_len < 0) return Int_.To_str(val);
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
boolean neg = val < 0;
|
||||
if (bgn) { // special logic to handle negative numbers; EX: -1 -> "-001", not "00-1"
|
||||
@ -146,20 +146,20 @@ public class Int_ implements GfoInvkAble {
|
||||
bfr.Add_int_fixed(val, len);
|
||||
bfr.Add_byte_repeat(pad_chr, pad_len);
|
||||
if (bgn) bfr.Add_int_fixed(val, len); // NOTE: neg handled above
|
||||
return bfr.Xto_str();
|
||||
return bfr.To_str();
|
||||
}
|
||||
public static int read_(Object o) {String s = String_.as_(o); return s != null ? Int_.parse(s) : Int_.cast(o);}
|
||||
public static int parse(String raw) {try {return Integer.parseInt(raw);} catch(Exception e) {throw Err_.new_parse_exc(e, int.class, raw);}}
|
||||
public static int cast(Object obj) {try {return (Integer)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, int.class, obj);}}
|
||||
public static int cast_or(Object obj, int or) {try {return (Integer)obj;} catch(Exception e) {Err_.Noop(e); return or;}}
|
||||
public static int Xby_double_(double v) {return (int)v;}
|
||||
public static String Xto_str(int v) {return new Integer(v).toString();}
|
||||
public static String Xto_str_fmt(int v, String fmt) {return new java.text.DecimalFormat(fmt).format(v);}
|
||||
public static String To_str(int v) {return new Integer(v).toString();}
|
||||
public static String To_str_fmt(int v, String fmt) {return new java.text.DecimalFormat(fmt).format(v);}
|
||||
public static boolean TypeMatch(Class<?> type) {return type == int.class || type == Integer.class;}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_XtoStr_PadBgn)) {
|
||||
int v = m.ReadInt(GfsCore_.Arg_primitive), pad = m.ReadInt("pad");
|
||||
return ctx.Deny() ? (Object)this : Xto_str_pad_bgn_zero(v, pad);
|
||||
return ctx.Deny() ? (Object)this : To_str_pad_bgn_zero(v, pad);
|
||||
}
|
||||
else if (ctx.Match(k, "Add")) {
|
||||
int v = m.ReadInt(GfsCore_.Arg_primitive), operand = m.ReadInt("operand");
|
||||
@ -168,18 +168,17 @@ public class Int_ implements GfoInvkAble {
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
} public static final String Invk_XtoStr_PadBgn = "XtoStr_PadBgn";
|
||||
public static final Int_ Gfs = new Int_();
|
||||
// public static int Xto_int_hex(String v) {return Integer.parseInt(v, 16);}
|
||||
public static int Xto_int_hex(byte[] src) {return Xto_int_hex(src, 0, src.length);}
|
||||
public static int Xto_int_hex(byte[] src, int bgn, int end) {
|
||||
public static int To_int_hex(byte[] src) {return To_int_hex(src, 0, src.length);}
|
||||
public static int To_int_hex(byte[] src, int bgn, int end) {
|
||||
int rv = 0; int factor = 1;
|
||||
for (int i = end - 1; i >= bgn; i--) {
|
||||
int val = Xto_int_hex(src[i]);
|
||||
int val = To_int_hex(src[i]);
|
||||
rv += (val * factor);
|
||||
factor *= 16;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static int Xto_int_hex(byte b) {
|
||||
public static int To_int_hex(byte b) {
|
||||
switch (b) {
|
||||
case Byte_ascii.Num_0: case Byte_ascii.Num_1: case Byte_ascii.Num_2: case Byte_ascii.Num_3: case Byte_ascii.Num_4:
|
||||
case Byte_ascii.Num_5: case Byte_ascii.Num_6: case Byte_ascii.Num_7: case Byte_ascii.Num_8: case Byte_ascii.Num_9:
|
||||
@ -192,18 +191,18 @@ public class Int_ implements GfoInvkAble {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
public static String Xto_str_hex(int v) {return Xto_str_hex(Bool_.Y, Bool_.Y, v);}
|
||||
public static String Xto_str_hex(boolean zero_pad, boolean upper, int v) {
|
||||
public static String To_str_hex(int v) {return To_str_hex(Bool_.Y, Bool_.Y, v);}
|
||||
public static String To_str_hex(boolean zero_pad, boolean upper, int v) {
|
||||
String rv = Integer.toHexString(v);
|
||||
int rv_len = String_.Len(rv);
|
||||
if (zero_pad && rv_len < 8) rv = String_.Repeat("0", 8 - rv_len) + rv;
|
||||
return upper ? String_.Upper(rv) : rv;
|
||||
}
|
||||
public static String Xto_str(int[] ary) {return Xto_str(ary, " ");}
|
||||
public static String Xto_str(int[] ary, String dlm) {
|
||||
public static String To_str(int[] ary) {return To_str(ary, " ");}
|
||||
public static String To_str(int[] ary, String dlm) {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
for (int i = 0; i < ary.length; i++)
|
||||
sb.Add_spr_unless_first(Int_.Xto_str(ary[i]), dlm, i);
|
||||
sb.Add_spr_unless_first(Int_.To_str(ary[i]), dlm, i);
|
||||
return sb.To_str();
|
||||
}
|
||||
public static int[] Ary_parse(String raw_str, int reqd_len, int[] or) {
|
||||
@ -251,7 +250,7 @@ public class Int_ implements GfoInvkAble {
|
||||
rv[i] = Int_.parse(ary[i]);
|
||||
return rv;
|
||||
}
|
||||
public static byte[] Xto_bry(int v) {return Bry_.new_a7(Xto_str(v));}
|
||||
public static byte[] To_bry(int v) {return Bry_.new_a7(To_str(v));}
|
||||
public static final int
|
||||
Min_value = Integer.MIN_VALUE
|
||||
, Max_value = Integer.MAX_VALUE
|
||||
|
@ -26,7 +26,7 @@ public class Int__tst {
|
||||
tst_XtoStr_PadLeft_Zeroes(-12 , 3, "-12"); // negative
|
||||
tst_XtoStr_PadLeft_Zeroes(-123 , 3, "-123"); // negative
|
||||
tst_XtoStr_PadLeft_Zeroes(-1234 , 3, "-1234"); // negative
|
||||
} void tst_XtoStr_PadLeft_Zeroes(int val, int zeros, String expd) {Tfds.Eq(expd, Int_.Xto_str_pad_bgn_zero(val, zeros));}
|
||||
} void tst_XtoStr_PadLeft_Zeroes(int val, int zeros, String expd) {Tfds.Eq(expd, Int_.To_str_pad_bgn_zero(val, zeros));}
|
||||
@Test public void parseOr_() {
|
||||
tst_ParseOr("", -1); // empty
|
||||
tst_ParseOr("123", 123); // single
|
||||
@ -41,7 +41,7 @@ public class Int__tst {
|
||||
@Test public void Xto_fmt() {
|
||||
tst_XtoStr_fmt(1, "1");
|
||||
tst_XtoStr_fmt(1000, "1,000");
|
||||
} void tst_XtoStr_fmt(int v, String expd) {Tfds.Eq(expd, Int_.Xto_str_fmt(v, "#,###"));}
|
||||
} void tst_XtoStr_fmt(int v, String expd) {Tfds.Eq(expd, Int_.To_str_fmt(v, "#,###"));}
|
||||
@Test public void AryRng() {
|
||||
tst_AryRng(1, 3, Int_.Ary(1, 2, 3));
|
||||
} void tst_AryRng(int bgn, int end, int[] expd) {Tfds.Eq_ary(expd, Int_.AryRng(bgn, end));}
|
||||
@ -71,7 +71,7 @@ public class Int__tst {
|
||||
tst_DigitCount(100, 3);
|
||||
tst_DigitCount(-1, 2);
|
||||
tst_DigitCount(-100, 4);
|
||||
} void tst_DigitCount(int val, int expd) {Tfds.Eq(expd, Int_.DigitCount(val), Int_.Xto_str(val));}
|
||||
} void tst_DigitCount(int val, int expd) {Tfds.Eq(expd, Int_.DigitCount(val), Int_.To_str(val));}
|
||||
@Test public void Log10() {
|
||||
tst_Log10( 0, 0);
|
||||
tst_Log10( 1, 0);
|
||||
@ -98,14 +98,14 @@ public class Int__tst {
|
||||
}
|
||||
@Test public void Xto_int_hex_tst() {
|
||||
Xto_int_hex("007C", 124);
|
||||
} void Xto_int_hex(String raw, int expd) {Tfds.Eq(expd, Int_.Xto_int_hex(Bry_.new_a7(raw)));}
|
||||
} void Xto_int_hex(String raw, int expd) {Tfds.Eq(expd, Int_.To_int_hex(Bry_.new_a7(raw)));}
|
||||
@Test public void Ary_parse() {
|
||||
Ary_parse__tst("1,2,3" , 3, Int_.Ary_empty, 1, 2, 3);
|
||||
Ary_parse__tst("123,321,213" , 3, Int_.Ary_empty, 123, 321, 213);
|
||||
Ary_parse__tst(" 1, 2,3" , 3, Int_.Ary_empty, 1, 2, 3);
|
||||
Ary_parse__tst("-1,+2,-3" , 3, Int_.Ary_empty, -1, 2, -3);
|
||||
Ary_parse__tst(Int_.Xto_str(Int_.Min_value) , 1, Int_.Ary_empty, Int_.Min_value);
|
||||
Ary_parse__tst(Int_.Xto_str(Int_.Max_value) , 1, Int_.Ary_empty, Int_.Max_value);
|
||||
Ary_parse__tst(Int_.To_str(Int_.Min_value) , 1, Int_.Ary_empty, Int_.Min_value);
|
||||
Ary_parse__tst(Int_.To_str(Int_.Max_value) , 1, Int_.Ary_empty, Int_.Max_value);
|
||||
Ary_parse__tst("1,2" , 1, Int_.Ary_empty);
|
||||
Ary_parse__tst("1" , 2, Int_.Ary_empty);
|
||||
Ary_parse__tst("a" , 1, Int_.Ary_empty);
|
||||
|
@ -33,9 +33,8 @@ public class Long_ {
|
||||
try {String s = String_.as_(v); return s == null ? Long_.cast(v) : Long_.parse(s);}
|
||||
catch (Exception e) {throw Err_.new_cast(e, long.class, v);}
|
||||
}
|
||||
public static long Xby_int(int v) {return (long)v;}
|
||||
public static String Xto_str(long v) {return Long.toString(v);}
|
||||
public static String Xto_str_PadBgn(long v, int reqdPlaces) {return String_.Pad(Xto_str(v), reqdPlaces, "0", true);} // ex: 1, 3 returns 001
|
||||
public static String To_str(long v) {return Long.toString(v);}
|
||||
public static String To_str_PadBgn(long v, int reqdPlaces) {return String_.Pad(To_str(v), reqdPlaces, "0", true);} // ex: 1, 3 returns 001
|
||||
public static long parse_or(String raw, long or) {
|
||||
if (raw == null) return or;
|
||||
try {
|
||||
|
@ -44,8 +44,8 @@ public class Yn {
|
||||
if (v_int == Bool_.__int) Err_.new_unhandled(v);
|
||||
return v_int == Bool_.Y_int;
|
||||
}
|
||||
public static String Xto_str(boolean v) {return v ? "y" : "n";}
|
||||
public static String Xto_nullable_str(byte v) {
|
||||
public static String To_str(boolean v) {return v ? "y" : "n";}
|
||||
public static String To_nullable_str(byte v) {
|
||||
switch (v) {
|
||||
case Bool_.Y_byte: return "y";
|
||||
case Bool_.N_byte: return "n";
|
||||
@ -53,7 +53,7 @@ public class Yn {
|
||||
default: throw Err_.new_unhandled(v);
|
||||
}
|
||||
}
|
||||
public static byte Xto_nullable_byte(String v) {
|
||||
public static byte To_nullable_byte(String v) {
|
||||
if (v != null && String_.Len(v) == 1) {
|
||||
char c = String_.CharAt(v, 0);
|
||||
switch (c) {
|
||||
|
@ -66,7 +66,7 @@ public class Array_ {
|
||||
public static String To_str_nested_obj(Object o) {
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
To_str_nested_ary(bfr, (Object)o, 0);
|
||||
return bfr.Xto_str_and_clear();
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
private static void To_str_nested_ary(Bry_bfr bfr, Object ary, int indent) {
|
||||
int len = Len(ary);
|
||||
|
@ -40,7 +40,7 @@ public class Object_ {
|
||||
if (Type_adp_.Eq(c, String_.Cls_ref_type)) return (String)v;
|
||||
else if (Type_adp_.Eq(c, Bry_.Cls_ref_type)) return String_.new_u8((byte[])v);
|
||||
else if (Type_adp_.Eq(c, Bool_.Cls_ref_type)) return Bool_.cast(v) ? Bool_.True_str : Bool_.False_str; // always return "true" / "false"
|
||||
else if (Type_adp_.Eq(c, Double_.Cls_ref_type)) return Double_.Xto_str_loose(Double_.cast(v));
|
||||
else if (Type_adp_.Eq(c, Double_.Cls_ref_type)) return Double_.To_str_loose(Double_.cast(v));
|
||||
else return v.toString();
|
||||
}
|
||||
public static final byte[] Bry__null = Bry_.new_a7("null");
|
||||
|
@ -355,13 +355,13 @@ public class String_ implements GfoInvkAble {
|
||||
c = String_.CharAt(raw, i);
|
||||
if (c == dlm) {
|
||||
if (!addEmptyIfDlmIsLast && sb.Count() == 0 && i == rawLen - 1) {}
|
||||
else list.Add(sb.Xto_str_and_clear());
|
||||
else list.Add(sb.To_str_and_clear());
|
||||
}
|
||||
else
|
||||
sb.Add(c);
|
||||
}
|
||||
if (sb.Count() > 0)
|
||||
list.Add(sb.Xto_str_and_clear());
|
||||
list.Add(sb.To_str_and_clear());
|
||||
return list.To_str_ary();
|
||||
}
|
||||
public static String[] Split(String s, String separator) {return Split_do(s, separator, false);}
|
||||
@ -431,7 +431,7 @@ public class String_ implements GfoInvkAble {
|
||||
while (true) {
|
||||
if (sprMatched
|
||||
|| i == textLength) { // last pass; add whatever's in sb to list
|
||||
list.Add(sb.Xto_str_and_clear());
|
||||
list.Add(sb.To_str_and_clear());
|
||||
if (sprMatched && i == textLength) list.Add(""); // if s ends with spr and last pass, add emptyString as last
|
||||
sprMatched = false;
|
||||
}
|
||||
@ -543,6 +543,6 @@ public class String_ implements GfoInvkAble {
|
||||
if (val != null) bfr.Add_str_u8(val);
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
return bfr.Xto_str_and_clear();
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class Io_url implements CompareAble, EqAble, ParseAble, GfoInvkAble { //_
|
||||
public byte[] To_http_file_bry() {
|
||||
return Bry_.Add(Http_file_bry, Http_file_str_encoder.Encode_bry(raw));
|
||||
}
|
||||
public static Url_encoder_interface Http_file_str_encoder = Url_encoder_interface_same._;
|
||||
public static Url_encoder_interface Http_file_str_encoder = Url_encoder_interface_same.Instance;
|
||||
|
||||
public static final String Http_file_str = "file:///";
|
||||
public static final int Http_file_len = String_.Len(Http_file_str);
|
||||
|
@ -38,16 +38,16 @@ public class Io_url_ {
|
||||
public static Io_url Usr_Gplx() {return Usr().GenSubDir("gplx");}
|
||||
public static Io_url mem_dir_(String raw) {
|
||||
raw = EndsWith_or_add(raw, Op_sys.Lnx.Fsys_dir_spr_str());
|
||||
return new Io_url(raw, IoUrlInfoRegy._.Match(raw));
|
||||
return new Io_url(raw, IoUrlInfoRegy.Instance.Match(raw));
|
||||
}
|
||||
public static Io_url mem_fil_(String raw) {return new_inf_(raw, IoUrlInfoRegy._.Match(raw));}
|
||||
public static Io_url mem_fil_(String raw) {return new_inf_(raw, IoUrlInfoRegy.Instance.Match(raw));}
|
||||
public static Io_url wnt_fil_(String raw) {return new_inf_(raw, IoUrlInfo_.Wnt);}
|
||||
public static Io_url wnt_dir_(String raw) {return new_inf_(EndsWith_or_add(raw, Op_sys.Wnt.Fsys_dir_spr_str()), IoUrlInfo_.Wnt);}
|
||||
public static Io_url lnx_fil_(String raw) {return new_inf_(raw, IoUrlInfo_.Lnx);}
|
||||
public static Io_url lnx_dir_(String raw) {return new_inf_(EndsWith_or_add(raw, Op_sys.Lnx.Fsys_dir_spr_str()), IoUrlInfo_.Lnx);}
|
||||
public static Io_url new_fil_(String raw) {return new_any_(raw);}
|
||||
public static Io_url new_dir_(String raw) {return new_any_(raw);} // NOTE: for now, same as new_fil; stack overflow when doing new_dir
|
||||
public static Io_url new_any_(String raw) {return new_inf_(raw, IoUrlInfoRegy._.Match(raw));}
|
||||
public static Io_url new_any_(String raw) {return new_inf_(raw, IoUrlInfoRegy.Instance.Match(raw));}
|
||||
public static Io_url new_inf_(String raw, IoUrlInfo info) {return String_.Eq(raw, "") ? Io_url_.Empty : new Io_url(raw, info);}
|
||||
public static Io_url http_any_(String src, boolean wnt) {
|
||||
return new_any_(parse_http_file(src, wnt));
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
public class KeyValHash {
|
||||
private Ordered_hash hash = Ordered_hash_.new_();
|
||||
private Ordered_hash hash = Ordered_hash_.New();
|
||||
public int Count() {return hash.Count();}
|
||||
public KeyValHash Clear() {hash.Clear(); return this;}
|
||||
public boolean Has(String key) {return hash.Has(key);}
|
||||
|
@ -66,7 +66,7 @@ public class KeyVal_ {
|
||||
public static String Ary_to_str_nested(KeyVal... ary) {
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
Ary_to_str_nested(bfr, 0, ary);
|
||||
return bfr.Xto_str_and_clear();
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
private static void Ary_to_str_nested(Bry_bfr bfr, int indent, KeyVal[] ary) {
|
||||
int len = ary.length;
|
||||
|
@ -78,7 +78,7 @@ public class TimeSpanAdp implements CompareAble, EqAble {
|
||||
case 1: return "s";
|
||||
case 2: return "m";
|
||||
case 3: return "h";
|
||||
default: return "unknown:<" + Int_.Xto_str(i) + ">";
|
||||
default: return "unknown:<" + Int_.To_str(i) + ">";
|
||||
}
|
||||
}
|
||||
@gplx.Internal protected TimeSpanAdp(long fracs) {this.fracs = fracs;}
|
||||
|
@ -93,9 +93,9 @@ public class TimeSpanAdp_ {
|
||||
sb.Add(Sprs[i]);
|
||||
if (val < 10) // zeroPad
|
||||
sb.Add("0");
|
||||
sb.Add(Int_.Xto_str(val));
|
||||
sb.Add(Int_.To_str(val));
|
||||
}
|
||||
return sb.Xto_str_and_clear();
|
||||
return sb.To_str_and_clear();
|
||||
}
|
||||
boolean fmt_fracs = !String_.Eq(fmt, TimeSpanAdp_.Fmt_NoFractionals);
|
||||
boolean fmt_padZeros = String_.Eq(fmt, TimeSpanAdp_.Fmt_PadZeros);
|
||||
@ -116,7 +116,7 @@ public class TimeSpanAdp_ {
|
||||
zeros = first && !fmt_padZeros ? 1 : padZerosAry[i]; // if first, don't zero pad (avoid "01")
|
||||
dlm = first ? "" : Sprs[i]; // if first, don't use dlm (avoid ":01")
|
||||
sb.Add(dlm);
|
||||
sb.Add(Int_.Xto_str_pad_bgn_zero(val, zeros));
|
||||
sb.Add(Int_.To_str_pad_bgn_zero(val, zeros));
|
||||
first = false;
|
||||
}
|
||||
return sb.To_str();
|
||||
|
@ -23,5 +23,5 @@ public interface Url_encoder_interface {
|
||||
class Url_encoder_interface_same implements Url_encoder_interface {
|
||||
public String Encode_str(String v) {return v;}
|
||||
public byte[] Encode_bry(String v) {return Bry_.new_u8(v);}
|
||||
public static final Url_encoder_interface_same _ = new Url_encoder_interface_same(); Url_encoder_interface_same() {}
|
||||
public static final Url_encoder_interface_same Instance = new Url_encoder_interface_same(); Url_encoder_interface_same() {}
|
||||
}
|
||||
|
@ -743,7 +743,7 @@ public class Bry_ {
|
||||
}
|
||||
else if (next == lkp) {
|
||||
posRef.Val_(pos + 2); // 1=endQuote;1=lkp;
|
||||
return make ? bb.Xto_bry() : Bry_.Empty;
|
||||
return make ? bb.To_bry() : Bry_.Empty;
|
||||
}
|
||||
else throw Err_.new_wo_type("quote found, but not doubled", "txt", String_.new_u8__by_len(ary, bgn, pos + 1));
|
||||
}
|
||||
@ -830,7 +830,7 @@ public class Bry_ {
|
||||
}
|
||||
if (dirty)
|
||||
bfr.Add_mid(src, bfr_bgn, src_end);
|
||||
return dirty ? bfr.Xto_bry_and_clear() : src;
|
||||
return dirty ? bfr.To_bry_and_clear() : src;
|
||||
}
|
||||
public static byte[] Replace(byte[] src, byte[] find, byte[] replace) {return Replace_between(src, find, null, replace);}
|
||||
public static byte[] Replace_between(byte[] src, byte[] bgn, byte[] end, byte[] replace) {
|
||||
@ -859,7 +859,7 @@ public class Bry_ {
|
||||
}
|
||||
}
|
||||
}
|
||||
return bfr.Xto_bry_and_clear();
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
public static int Trim_end_pos(byte[] src, int end) {
|
||||
for (int i = end - 1; i > -1; i--) {
|
||||
|
@ -50,7 +50,7 @@ public class Bry_bfr {
|
||||
public byte[] To_bry_and_rls() {
|
||||
byte[] rv = null;
|
||||
synchronized (bfr) {
|
||||
rv = Xto_bry();
|
||||
rv = To_bry();
|
||||
this.Clear();
|
||||
if (reset > 0) Reset_if_gt(reset);
|
||||
synchronized (mkr_mgr) {
|
||||
@ -279,6 +279,7 @@ public class Bry_bfr {
|
||||
return this;
|
||||
}
|
||||
public Bry_bfr Add_str(String v) {return Add_str_u8(v);}
|
||||
public Bry_bfr Add_str_u8_w_nl(String s) {Add_str_u8(s); return Add_byte_nl();}
|
||||
public Bry_bfr Add_str_u8(String str) {
|
||||
try {
|
||||
int str_len = str.length();
|
||||
@ -290,6 +291,7 @@ public class Bry_bfr {
|
||||
}
|
||||
catch (Exception e) {throw Err_.new_exc(e, "core", "invalid UTF-8 sequence", "s", str);}
|
||||
}
|
||||
public Bry_bfr Add_str_a7_w_nl(String s) {Add_str_a7(s); return Add_byte_nl();}
|
||||
public Bry_bfr Add_str_a7(String str) {
|
||||
try {
|
||||
int bry_len = str.length();
|
||||
@ -310,8 +312,8 @@ public class Bry_bfr {
|
||||
this.Add_byte(line ? Byte_ascii.Nl : Byte_ascii.Tab);
|
||||
return this;
|
||||
}
|
||||
public Bry_bfr Add_float(float f) {Add_str(Float_.Xto_str(f)); return this;}
|
||||
public Bry_bfr Add_double(double v) {Add_str(Double_.Xto_str(v)); return this;}
|
||||
public Bry_bfr Add_float(float f) {Add_str(Float_.To_str(f)); return this;}
|
||||
public Bry_bfr Add_double(double v) {Add_str(Double_.To_str(v)); return this;}
|
||||
public Bry_bfr Add_dte(DateAdp val) {return Add_dte_segs(val.Year(), val.Month(),val.Day(), val.Hour(), val.Minute(), val.Second(), val.Frac());}
|
||||
public Bry_bfr Add_dte_segs(int y, int M, int d, int H, int m, int s, int f) { // yyyyMMdd HHmmss.fff
|
||||
if (bfr_len + 19 > bfr_max) Resize((bfr_len + 19) * 2);
|
||||
@ -403,7 +405,7 @@ public class Bry_bfr {
|
||||
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);
|
||||
else ((Bry_fmtr_arg)o).Fmt__do(this);
|
||||
return this;
|
||||
}
|
||||
public Bry_bfr Add_obj_strict(Object o) {
|
||||
@ -420,7 +422,7 @@ public class Bry_bfr {
|
||||
else if (o_type == Boolean.class) Add_bool(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);
|
||||
else ((Bry_fmtr_arg)o).Fmt__do(this);
|
||||
return this;
|
||||
}
|
||||
public Bry_bfr Add_yn(boolean v) {Add_byte(v ? Byte_ascii.Ltr_y : Byte_ascii.Ltr_n); return this;}
|
||||
@ -495,31 +497,26 @@ public class Bry_bfr {
|
||||
return this;
|
||||
}
|
||||
public boolean Eq(byte b) {return bfr_len == 1 && bfr[0] == b;}
|
||||
public byte[] Xto_bry(int bgn, int end) {return bfr_len == 0 ? Bry_.Empty : Bry_.Mid(bfr, bgn, end);}
|
||||
public byte[] Xto_bry() {return bfr_len == 0 ? Bry_.Empty : Bry_.Mid(bfr, 0, bfr_len);}
|
||||
public byte[] Xto_bry_and_reset(int v) {
|
||||
byte[] rv = Xto_bry();
|
||||
this.Clear().Reset_if_gt(v);
|
||||
return rv;
|
||||
}
|
||||
public byte[] Xto_bry_and_clear_and_trim() {return Xto_bry_and_clear_and_trim(true, true, Bry_.Trim_ary_ws);}
|
||||
public byte[] Xto_bry_and_clear_and_trim(boolean trim_bgn, boolean trim_end, byte[] trim_bry) {
|
||||
public byte[] To_bry(int bgn, int end) {return bfr_len == 0 ? Bry_.Empty : Bry_.Mid(bfr, bgn, end);}
|
||||
public byte[] To_bry() {return bfr_len == 0 ? Bry_.Empty : Bry_.Mid(bfr, 0, bfr_len);}
|
||||
public byte[] To_bry_and_clear_and_trim() {return To_bry_and_clear_and_trim(true, true, Bry_.Trim_ary_ws);}
|
||||
public byte[] To_bry_and_clear_and_trim(boolean trim_bgn, boolean trim_end, byte[] trim_bry) {
|
||||
byte[] rv = Bry_.Trim(bfr, 0, bfr_len, trim_bgn, trim_end, trim_bry);
|
||||
this.Clear();
|
||||
return rv;
|
||||
}
|
||||
public byte[] Xto_bry_and_clear() {
|
||||
byte[] rv = Xto_bry();
|
||||
public byte[] To_bry_and_clear() {
|
||||
byte[] rv = To_bry();
|
||||
this.Clear();
|
||||
if (reset > 0) Reset_if_gt(reset);
|
||||
return rv;
|
||||
}
|
||||
public String Xto_str() {return String_.new_u8(Xto_bry());}
|
||||
public String Xto_str_by_pos(int bgn, int end) {return String_.new_u8(Xto_bry(), bgn, end);}
|
||||
public String Xto_str_and_clear() {return String_.new_u8(Xto_bry_and_clear());}
|
||||
public String Xto_str_and_clear_and_trim() {return String_.new_u8(Xto_bry_and_clear_and_trim());}
|
||||
public int XtoIntAndClear(int or) {int rv = XtoInt(or); this.Clear(); return rv;}
|
||||
public int XtoInt(int or) {
|
||||
public String To_str() {return String_.new_u8(To_bry());}
|
||||
public String To_str_by_pos(int bgn, int end) {return String_.new_u8(To_bry(), bgn, end);}
|
||||
public String To_str_and_clear() {return String_.new_u8(To_bry_and_clear());}
|
||||
public String To_str_and_clear_and_trim() {return String_.new_u8(To_bry_and_clear_and_trim());}
|
||||
public int To_int_and_clear(int or) {int rv = To_int(or); this.Clear(); return rv;}
|
||||
public int To_int(int or) {
|
||||
switch (bfr_len) {
|
||||
case 0: return or;
|
||||
case 1: {
|
||||
|
@ -25,7 +25,6 @@ public class Bry_bfr_mkr {
|
||||
public Bry_bfr Get_m001() {return mkr_m001.Get();}
|
||||
public void Rls(Bry_bfr v) {
|
||||
v.Mkr_rls();
|
||||
// v.Mkr_mgr().Rls(v);
|
||||
}
|
||||
public void Reset_if_gt(int v) {
|
||||
for (byte i = Tid_b128; i <= Tid_m001; i++)
|
||||
@ -35,12 +34,11 @@ public class Bry_bfr_mkr {
|
||||
for (byte i = Tid_b128; i <= Tid_m001; i++)
|
||||
mkr(i).Clear_fail_check();
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
for (byte i = Tid_b128; i <= Tid_m001; i++)
|
||||
mkr(i).Clear();
|
||||
}
|
||||
Bry_bfr_mkr_mgr mkr(byte tid) {
|
||||
private Bry_bfr_mkr_mgr mkr(byte tid) {
|
||||
switch (tid) {
|
||||
case Tid_b128: return mkr_b128;
|
||||
case Tid_b512: return mkr_b512;
|
||||
@ -51,9 +49,8 @@ public class Bry_bfr_mkr {
|
||||
}
|
||||
}
|
||||
class Bry_bfr_mkr_mgr {
|
||||
private final Object thread_lock;
|
||||
private final Object thread_lock = new Object();
|
||||
public Bry_bfr_mkr_mgr(byte mgr_id, int reset) {// NOTE: random IndexOutOfBounds errors in Get around free[--free_len] with free_len being -1; put member variable initialization within thread_lock to try to avoid; DATE:2014-09-21
|
||||
thread_lock = new Object();
|
||||
synchronized (thread_lock) {
|
||||
this.mgr_id = mgr_id;
|
||||
this.reset = reset;
|
||||
@ -72,7 +69,7 @@ class Bry_bfr_mkr_mgr {
|
||||
for (int i = 0; i < ary_max; i++) {
|
||||
Bry_bfr itm = ary[i];
|
||||
if (itm != null) {
|
||||
if (!itm.Mkr_idx_is_null()) throw Err_.new_wo_type("failed to clear bfr", "idx", Int_.Xto_str(i));
|
||||
if (!itm.Mkr_idx_is_null()) throw Err_.new_wo_type("failed to clear bfr", "idx", Int_.To_str(i));
|
||||
itm.Clear();
|
||||
}
|
||||
ary[i] = null;
|
||||
@ -132,18 +129,6 @@ class Bry_bfr_mkr_mgr {
|
||||
Array_.Copy_to(free, 0, new_free, 0, free_len);
|
||||
free = new_free;
|
||||
}
|
||||
// public void Rls(Bry_bfr v) {
|
||||
// synchronized (thread_lock) {
|
||||
// int idx = v.Mkr_itm();
|
||||
// if (idx == -1) throw Err_mgr._.fmt_("gplx.Bry_bfr", "rls_failed", "rls called on bfr that was not created by factory");
|
||||
// int new_ary_len = nxt_idx - 1;
|
||||
// if (idx == new_ary_len)
|
||||
// nxt_idx = new_ary_len;
|
||||
// else
|
||||
// free[free_len++] = idx;
|
||||
// v.Mkr_(null, -1);
|
||||
// }
|
||||
// }
|
||||
public void Rls(int idx) {
|
||||
synchronized (thread_lock) {
|
||||
if (idx == -1) throw Err_.new_wo_type("rls called on bfr that was not created by factory");
|
||||
|
@ -33,13 +33,13 @@ public class Bry_bfr_tst {
|
||||
@Test public void Add_byte_repeat() { // NOTE: make sure auto-expands
|
||||
bb = Bry_bfr.new_(2);
|
||||
tst_Add_byte_repeat(Byte_ascii.Space, 12, String_.Repeat(" ", 12));
|
||||
} void tst_Add_byte_repeat(byte b, int len, String expd) {Tfds.Eq(expd, bb.Add_byte_repeat(b, len).Xto_str_and_clear());}
|
||||
} void tst_Add_byte_repeat(byte b, int len, String expd) {Tfds.Eq(expd, bb.Add_byte_repeat(b, len).To_str_and_clear());}
|
||||
void tst_AddByte(String s, String expdStr, int expdLen) {
|
||||
if (String_.Len(s) == 1)
|
||||
bb.Add_byte((byte)String_.CharAt(s, 0));
|
||||
else
|
||||
bb.Add(Bry_.new_u8(s));
|
||||
Tfds.Eq(expdStr, String_.new_u8(bb.Xto_bry()));
|
||||
Tfds.Eq(expdStr, String_.new_u8(bb.To_bry()));
|
||||
Tfds.Eq(expdLen, bb.Bfr_max());
|
||||
}
|
||||
@Test public void Add_dte() {
|
||||
@ -47,7 +47,7 @@ public class Bry_bfr_tst {
|
||||
}
|
||||
void tst_AddDte(String raw) {
|
||||
bb.Add_dte(DateAdp_.parse_fmt(raw, Bry_.Fmt_csvDte));
|
||||
Tfds.Eq(raw, String_.new_u8(bb.Xto_bry()));
|
||||
Tfds.Eq(raw, String_.new_u8(bb.To_bry()));
|
||||
}
|
||||
@Test public void Add_int_variable() {
|
||||
Add_int_variable(-1);
|
||||
@ -64,12 +64,12 @@ public class Bry_bfr_tst {
|
||||
}
|
||||
void tst_Add_float(float v) {
|
||||
bb.Add_float(v);
|
||||
Tfds.Eq(v, Float_.parse(String_.new_u8(bb.Xto_bry())));
|
||||
Tfds.Eq(v, Float_.parse(String_.new_u8(bb.To_bry())));
|
||||
}
|
||||
void Add_int_variable(int val) {
|
||||
bb.Clear();
|
||||
bb.Add_int_variable(val);
|
||||
Tfds.Eq(val, Int_.parse(String_.new_u8(bb.Xto_bry())));
|
||||
Tfds.Eq(val, Int_.parse(String_.new_u8(bb.To_bry())));
|
||||
}
|
||||
@Test public void Add_int_fixed_len3() {tst_Add_int_fixed(123, 3, "123");}
|
||||
@Test public void Add_int_fixed_pad_1() {tst_Add_int_fixed(2, 1, "2");}
|
||||
@ -79,7 +79,7 @@ public class Bry_bfr_tst {
|
||||
@Test public void Add_int_fixed_neg_pad1() {tst_Add_int_fixed(-2, 1, "-");}
|
||||
@Test public void Add_int_fixed_chop_1() {tst_Add_int_fixed(123, 1, "3");}
|
||||
@Test public void Add_int_fixed_chop_neg() {tst_Add_int_fixed(-21, 2, "-1");}
|
||||
void tst_Add_int_fixed(int val, int digits, String expd) {Tfds.Eq(expd, String_.new_u8(bb.Add_int_fixed(val, digits).Xto_bry()));}
|
||||
void tst_Add_int_fixed(int val, int digits, String expd) {Tfds.Eq(expd, String_.new_u8(bb.Add_int_fixed(val, digits).To_bry()));}
|
||||
@Test public void Add_long_fixed_len3() {tst_Add_long_fixed(123, 3, "123");}
|
||||
@Test public void Add_long_fixed_pad_1() {tst_Add_long_fixed(2, 1, "2");}
|
||||
@Test public void Add_long_fixed_pad_2() {tst_Add_long_fixed(2, 2, "02");}
|
||||
@ -89,7 +89,7 @@ public class Bry_bfr_tst {
|
||||
@Test public void Add_long_fixed_chop_1() {tst_Add_long_fixed(123, 1, "3");}
|
||||
@Test public void Add_long_fixed_chop_neg() {tst_Add_long_fixed(-21, 2, "-1");}
|
||||
@Test public void Add_long_fixed_large() {tst_Add_long_fixed(123456789012345L, 15, "123456789012345");}
|
||||
void tst_Add_long_fixed(long val, int digits, String expd) {Tfds.Eq(expd, String_.new_u8(bb.Add_long_fixed(val, digits).Xto_bry()));}
|
||||
void tst_Add_long_fixed(long val, int digits, String expd) {Tfds.Eq(expd, String_.new_u8(bb.Add_long_fixed(val, digits).To_bry()));}
|
||||
@Test public void AddDte_short() {
|
||||
tst_AddDte_short("2010-08-26T22:38:36Z");
|
||||
}
|
||||
@ -100,12 +100,12 @@ public class Bry_bfr_tst {
|
||||
// for (int i = 0; i < aryLen; i++) {
|
||||
// byte b = ary[i];
|
||||
// switch (i) {
|
||||
// case 4: y = ib.XtoIntAndClear(); break;
|
||||
// case 7: m = ib.XtoIntAndClear(); break;
|
||||
// case 10: d = ib.XtoIntAndClear(); break;
|
||||
// case 13: h = ib.XtoIntAndClear(); break;
|
||||
// case 16: n = ib.XtoIntAndClear(); break;
|
||||
// case 19: s = ib.XtoIntAndClear(); break;
|
||||
// case 4: y = ib.To_int_and_clear(); break;
|
||||
// case 7: m = ib.To_int_and_clear(); break;
|
||||
// case 10: d = ib.To_int_and_clear(); break;
|
||||
// case 13: h = ib.To_int_and_clear(); break;
|
||||
// case 16: n = ib.To_int_and_clear(); break;
|
||||
// case 19: s = ib.To_int_and_clear(); break;
|
||||
// default: ib.Add(b); break;
|
||||
// }
|
||||
// }
|
||||
@ -122,10 +122,10 @@ public class Bry_bfr_tst {
|
||||
// bb = Bry_bfr.new_(16);
|
||||
// bb.Add_str(orig);
|
||||
// bb.InsertAt_str(insertAt, insertStr);
|
||||
// String actl = bb.Xto_str_and_clear();
|
||||
// String actl = bb.To_str_and_clear();
|
||||
// Tfds.Eq(expd, actl);
|
||||
// }
|
||||
@Test public void Xto_bry_and_clear_and_trim() {
|
||||
@Test public void To_bry_and_clear_and_trim() {
|
||||
tst_XtoAryAndClearAndTrim("a" , "a");
|
||||
tst_XtoAryAndClearAndTrim(" a " , "a");
|
||||
tst_XtoAryAndClearAndTrim(" a b " , "a b");
|
||||
@ -133,7 +133,7 @@ public class Bry_bfr_tst {
|
||||
}
|
||||
void tst_XtoAryAndClearAndTrim(String raw, String expd) {
|
||||
bb.Add_str(raw);
|
||||
Tfds.Eq(expd, String_.new_u8(bb.Xto_bry_and_clear_and_trim()));
|
||||
Tfds.Eq(expd, String_.new_u8(bb.To_bry_and_clear_and_trim()));
|
||||
}
|
||||
@Test public void XtoInt() {
|
||||
tst_XtoInt("123", 123);
|
||||
@ -142,7 +142,7 @@ public class Bry_bfr_tst {
|
||||
}
|
||||
void tst_XtoInt(String raw, int expd) {
|
||||
bb.Add_str(raw);
|
||||
Tfds.Eq(expd, bb.XtoIntAndClear(Int_.Min_value));
|
||||
Tfds.Eq(expd, bb.To_int_and_clear(Int_.Min_value));
|
||||
}
|
||||
static long Pow38_to(int year, int month, int day, int hour, int minute, int second, int frac) {
|
||||
return ((long)year) << 26
|
||||
@ -167,7 +167,7 @@ public class Bry_bfr_tst {
|
||||
}
|
||||
void tst_Add_bfr_trimEnd_and_clear(String raw, String expd) {
|
||||
Bry_bfr tmp = Bry_bfr.new_().Add_str(raw);
|
||||
Tfds.Eq(expd, bb.Add_bfr_trim_and_clear(tmp, false, true).Xto_str_and_clear());
|
||||
Tfds.Eq(expd, bb.Add_bfr_trim_and_clear(tmp, false, true).To_str_and_clear());
|
||||
}
|
||||
@Test public void Add_bfr_trimAll_and_clear() {
|
||||
tst_Add_bfr_trimAll_and_clear(" a ", "a");
|
||||
@ -177,7 +177,7 @@ public class Bry_bfr_tst {
|
||||
}
|
||||
void tst_Add_bfr_trimAll_and_clear(String raw, String expd) {
|
||||
Bry_bfr tmp = Bry_bfr.new_().Add_str(raw);
|
||||
Tfds.Eq(expd, bb.Add_bfr_trim_and_clear(tmp, true, true).Xto_str_and_clear());
|
||||
Tfds.Eq(expd, bb.Add_bfr_trim_and_clear(tmp, true, true).To_str_and_clear());
|
||||
}
|
||||
@Test public void Add_int_pad_bgn() {
|
||||
fxt.Test_Add_int_pad_bgn(Byte_ascii.Num_0, 3, 0, "000");
|
||||
@ -214,14 +214,14 @@ class ByteAryBfr_fxt {
|
||||
public void Clear() {
|
||||
bfr.ClearAndReset();
|
||||
}
|
||||
public void Test_Add_int_pad_bgn(byte pad_byte, int str_len, int val, String expd) {Tfds.Eq(expd, bfr.Add_int_pad_bgn(pad_byte, str_len, val).Xto_str_and_clear());}
|
||||
public void Test_Add_int_pad_bgn(byte pad_byte, int str_len, int val, String expd) {Tfds.Eq(expd, bfr.Add_int_pad_bgn(pad_byte, str_len, val).To_str_and_clear());}
|
||||
public void Test_Add_bry_escape(String val, String expd) {
|
||||
byte[] val_bry = Bry_.new_u8(val);
|
||||
Tfds.Eq(expd, bfr.Add_bry_escape(Byte_ascii.Apos, Byte_.Ary(Byte_ascii.Apos, Byte_ascii.Apos), val_bry, 0, val_bry.length).Xto_str_and_clear());
|
||||
Tfds.Eq(expd, bfr.Add_bry_escape(Byte_ascii.Apos, Byte_.Ary(Byte_ascii.Apos, Byte_ascii.Apos), val_bry, 0, val_bry.length).To_str_and_clear());
|
||||
}
|
||||
public void Test_Insert_at(String init, int pos, String val, String expd) {Tfds.Eq(expd, bfr.Add_str(init).Insert_at(pos, Bry_.new_u8(val)).Xto_str_and_clear());}
|
||||
public void Test_Insert_at(String init, int pos, String val, int val_bgn, int val_end, String expd) {Tfds.Eq(expd, bfr.Add_str(init).Insert_at(pos, Bry_.new_u8(val), val_bgn, val_end).Xto_str_and_clear());}
|
||||
public void Test_Delete_rng(String init, int bgn, int end, String expd) {Tfds.Eq(expd, bfr.Add_str(init).Delete_rng(bgn, end).Xto_str_and_clear());}
|
||||
public void Test_Delete_rng_to_bgn(String init, int pos, String expd) {Tfds.Eq(expd, bfr.Add_str(init).Delete_rng_to_bgn(pos).Xto_str_and_clear());}
|
||||
public void Test_Delete_rng_to_end(String init, int pos, String expd) {Tfds.Eq(expd, bfr.Add_str(init).Delete_rng_to_end(pos).Xto_str_and_clear());}
|
||||
public void Test_Insert_at(String init, int pos, String val, String expd) {Tfds.Eq(expd, bfr.Add_str(init).Insert_at(pos, Bry_.new_u8(val)).To_str_and_clear());}
|
||||
public void Test_Insert_at(String init, int pos, String val, int val_bgn, int val_end, String expd) {Tfds.Eq(expd, bfr.Add_str(init).Insert_at(pos, Bry_.new_u8(val), val_bgn, val_end).To_str_and_clear());}
|
||||
public void Test_Delete_rng(String init, int bgn, int end, String expd) {Tfds.Eq(expd, bfr.Add_str(init).Delete_rng(bgn, end).To_str_and_clear());}
|
||||
public void Test_Delete_rng_to_bgn(String init, int pos, String expd) {Tfds.Eq(expd, bfr.Add_str(init).Delete_rng_to_bgn(pos).To_str_and_clear());}
|
||||
public void Test_Delete_rng_to_end(String init, int pos, String expd) {Tfds.Eq(expd, bfr.Add_str(init).Delete_rng_to_end(pos).To_str_and_clear());}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import gplx.core.primitives.*; import gplx.core.strings.*;
|
||||
public class Bry_fmtr {
|
||||
public byte[] Fmt() {return fmt;} private byte[] fmt = Bry_.Empty;
|
||||
public boolean Fmt_null() {return fmt.length == 0;}
|
||||
public Bry_fmtr_eval_mgr Eval_mgr() {return eval_mgr;} public Bry_fmtr Eval_mgr_(Bry_fmtr_eval_mgr v) {eval_mgr = v; return this;} Bry_fmtr_eval_mgr eval_mgr = Bry_fmtr_eval_mgr_gfs._;
|
||||
public Bry_fmtr_eval_mgr Eval_mgr() {return eval_mgr;} public Bry_fmtr Eval_mgr_(Bry_fmtr_eval_mgr v) {eval_mgr = v; return this;} Bry_fmtr_eval_mgr eval_mgr = Bry_fmtr_eval_mgr_gfs.Instance;
|
||||
public Bry_fmtr Fmt_(byte[] v) {fmt = v; dirty = true; return this;} public Bry_fmtr Fmt_(String v) {return Fmt_(Bry_.new_u8(v));}
|
||||
public Bry_fmtr Keys_(String... ary) {
|
||||
if (keys == null) keys = Hash_adp_.new_();
|
||||
@ -62,7 +62,7 @@ public class Bry_fmtr {
|
||||
for (int i = 0; i < itms_len; i++) {
|
||||
Bry_fmtr_itm itm = itms[i];
|
||||
if (itm.Arg)
|
||||
args[itm.ArgIdx].XferAry(bfr, itm.ArgIdx);
|
||||
args[itm.ArgIdx].Fmt__do(bfr);
|
||||
else
|
||||
bfr.Add(itm.Dat);
|
||||
}
|
||||
@ -88,14 +88,14 @@ public class Bry_fmtr {
|
||||
bfr.Add(itm.Dat);
|
||||
}
|
||||
}
|
||||
public byte[] Bld_bry_none(Bry_bfr bfr) {Bld_bfr_ary(bfr, Object_.Ary_empty); return bfr.Xto_bry_and_clear();}
|
||||
public byte[] Bld_bry_none(Bry_bfr bfr) {Bld_bfr_ary(bfr, Object_.Ary_empty); return bfr.To_bry_and_clear();}
|
||||
public byte[] Bld_bry_many(Bry_bfr bfr, Object... args) {
|
||||
Bld_bfr_ary(bfr, args);
|
||||
return bfr.Xto_bry_and_clear();
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
public String Bld_str_many(Bry_bfr bfr, String fmt, Object... args) {
|
||||
this.Fmt_(fmt).Bld_bfr_many(bfr, args);
|
||||
return bfr.Xto_str_and_clear();
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
public String Bld_str_many(String... args) {
|
||||
if (dirty) Compile();
|
||||
@ -134,9 +134,9 @@ public class Bry_fmtr {
|
||||
if (lkp_is_active) {
|
||||
if (cur_byte == char_arg_end) {
|
||||
if (lkp_is_numeric)
|
||||
list.Add(Bry_fmtr_itm.arg_(lkp_bfr.XtoInt(0) - baseInt));
|
||||
list.Add(Bry_fmtr_itm.arg_(lkp_bfr.To_int(0) - baseInt));
|
||||
else {
|
||||
byte[] key_fmt = lkp_bfr.Xto_bry();
|
||||
byte[] key_fmt = lkp_bfr.To_bry();
|
||||
Object idx_ref = keys.Get_by(Bry_obj_ref.new_(key_fmt));
|
||||
if (idx_ref == null) {
|
||||
int lkp_bfr_len = lkp_bfr.Len();
|
||||
@ -195,7 +195,7 @@ public class Bry_fmtr {
|
||||
else if (nxt_byte == char_escape_nl) tmp_byte = Byte_ascii.Nl;
|
||||
else if (nxt_byte == char_escape_tab) tmp_byte = Byte_ascii.Tab;
|
||||
else {
|
||||
if (fail_when_invalid_escapes) throw Err_.new_wo_type("unknown escape code", "code", Char_.XbyInt(nxt_byte), "fmt_pos", fmt_pos + 1);
|
||||
if (fail_when_invalid_escapes) throw Err_.new_wo_type("unknown escape code", "code", Char_.By_int(nxt_byte), "fmt_pos", fmt_pos + 1);
|
||||
else
|
||||
tmp_byte = cur_byte;
|
||||
}
|
||||
@ -254,12 +254,12 @@ public class Bry_fmtr {
|
||||
tmp_bfr.Add_byte(Byte_ascii.Curly_end);
|
||||
tmp_bfr.Add_byte(Byte_ascii.Apos);
|
||||
}
|
||||
return tmp_bfr.Xto_str_and_clear();
|
||||
return tmp_bfr.To_str_and_clear();
|
||||
} static Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
public void Bld_bfr_many_and_set_fmt(Object... args) {
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
this.Bld_bfr_many(bfr, args);
|
||||
byte[] bry = bfr.Xto_bry_and_clear();
|
||||
byte[] bry = bfr.To_bry_and_clear();
|
||||
this.Fmt_(bry).Compile();
|
||||
}
|
||||
public static String Escape_tilde(String v) {return String_.Replace(v, "~", "~~");}
|
||||
|
@ -17,5 +17,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
public interface Bry_fmtr_arg {
|
||||
void XferAry(Bry_bfr bfr, int idx);
|
||||
void Fmt__do(Bry_bfr bfr);
|
||||
}
|
||||
|
@ -29,5 +29,5 @@ public class Bry_fmtr_arg_ {
|
||||
public static final Bry_fmtr_arg Noop = new Bry_fmtr_arg__noop();
|
||||
}
|
||||
class Bry_fmtr_arg__noop implements Bry_fmtr_arg {
|
||||
public void XferAry(Bry_bfr trg, int idx) {}
|
||||
public void Fmt__do(Bry_bfr bfr) {}
|
||||
}
|
||||
|
@ -18,8 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx;
|
||||
public class Bry_fmtr_arg_fmtr_objs implements Bry_fmtr_arg {
|
||||
public Bry_fmtr_arg_fmtr_objs Atrs_(Bry_fmtr fmtr, Object... objs) {this.fmtr = fmtr; this.objs = objs; return this;}
|
||||
public void XferAry(Bry_bfr trg, int idx) {
|
||||
fmtr.Bld_bfr_many(trg, objs);
|
||||
}
|
||||
public void Fmt__do(Bry_bfr bfr) {fmtr.Bld_bfr_many(bfr, objs);}
|
||||
public Bry_fmtr_arg_fmtr_objs(Bry_fmtr fmtr, Object[] objs) {this.fmtr = fmtr; this.objs = objs;} Bry_fmtr fmtr; Object[] objs;
|
||||
}
|
||||
|
@ -22,6 +22,6 @@ public class Bry_fmtr_eval_mgr_ {
|
||||
Bry_bfr bfr = Bry_bfr.reset_(255);
|
||||
Bry_fmtr fmtr = Bry_fmtr.tmp_();
|
||||
fmtr.Eval_mgr_(eval_mgr).Fmt_(fmt).Bld_bfr_none(bfr);
|
||||
return Io_url_.new_any_(bfr.Xto_str_and_clear());
|
||||
return Io_url_.new_any_(bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ package gplx;
|
||||
public class Bry_fmtr_eval_mgr_gfs implements Bry_fmtr_eval_mgr {
|
||||
public boolean Enabled() {return enabled;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled;
|
||||
public byte[] Eval(byte[] cmd) {
|
||||
return enabled ? Bry_.new_u8(Object_.Xto_str_strict_or_null_mark(GfsCore._.ExecText(String_.new_u8(cmd)))) : null;
|
||||
return enabled ? Bry_.new_u8(Object_.Xto_str_strict_or_null_mark(GfsCore.Instance.ExecText(String_.new_u8(cmd)))) : null;
|
||||
}
|
||||
public static final Bry_fmtr_eval_mgr_gfs _ = new Bry_fmtr_eval_mgr_gfs(); Bry_fmtr_eval_mgr_gfs() {}
|
||||
public static final Bry_fmtr_eval_mgr_gfs Instance = new Bry_fmtr_eval_mgr_gfs(); Bry_fmtr_eval_mgr_gfs() {}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public class Bry_fmtr_vals implements Bry_fmtr_arg {
|
||||
private final Bry_fmtr fmtr; private Object[] vals;
|
||||
Bry_fmtr_vals(Bry_fmtr fmtr) {this.fmtr = fmtr;}
|
||||
public Bry_fmtr_vals Vals_(Object... v) {this.vals = v; return this;}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
fmtr.Bld_bfr_ary(bfr, vals);
|
||||
}
|
||||
public static Bry_fmtr_vals new_fmt(String fmt, String... keys) {
|
||||
|
@ -22,7 +22,7 @@ public class Bry_split_ {
|
||||
public static byte[][] Split(byte[] src, byte dlm) {return Split(src, dlm, false);}
|
||||
public static byte[][] Split(byte[] src, byte dlm, boolean trim) {
|
||||
synchronized (thread_lock) {
|
||||
Bry_split_wkr__to_ary wkr = Bry_split_wkr__to_ary.I;
|
||||
Bry_split_wkr__to_ary wkr = Bry_split_wkr__to_ary.Instance;
|
||||
Split(src, 0, src == null ? 0 : src.length, dlm, trim, wkr);
|
||||
return wkr.To_ary();
|
||||
}
|
||||
@ -128,5 +128,5 @@ class Bry_split_wkr__to_ary implements gplx.core.brys.Bry_split_wkr {
|
||||
return (byte[][])list.To_ary_and_clear(byte[].class);
|
||||
}
|
||||
}
|
||||
public static final Bry_split_wkr__to_ary I = new Bry_split_wkr__to_ary(); Bry_split_wkr__to_ary() {}
|
||||
public static final Bry_split_wkr__to_ary Instance = new Bry_split_wkr__to_ary(); Bry_split_wkr__to_ary() {}
|
||||
}
|
||||
|
@ -19,9 +19,9 @@ package gplx.brys; import gplx.*;
|
||||
public class Bry_fmtr_arg_ary_dim2 implements Bry_fmtr_arg {
|
||||
public Bry_fmtr_arg_ary_dim2 Data_(byte[][] v) {ary_dim2 = v; return this;}
|
||||
public Bry_fmtr_arg_ary_dim2 Ary_dim2_(byte[][] v) {this.ary_dim2 = v; return this;}
|
||||
public void XferAry(Bry_bfr trg, int idx) {
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
for (byte[] ary : ary_dim2)
|
||||
trg.Add(ary);
|
||||
bfr.Add(ary);
|
||||
}
|
||||
public Bry_fmtr_arg_ary_dim2() {} byte[][] ary_dim2 = new byte[0][];
|
||||
}
|
||||
|
@ -18,6 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.brys; import gplx.*;
|
||||
public class Bry_fmtr_arg_bfr implements Bry_fmtr_arg {
|
||||
public Bry_fmtr_arg_bfr Data_(Bry_bfr v) {bfr = v; return this;}
|
||||
public void XferAry(Bry_bfr trg, int idx) {trg.Add_bfr_and_clear(bfr);}
|
||||
public void Fmt__do(Bry_bfr trg) {trg.Add_bfr_and_clear(bfr);}
|
||||
public Bry_fmtr_arg_bfr(Bry_bfr bfr) {this.bfr = bfr;} Bry_bfr bfr;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.brys; import gplx.*;
|
||||
public class Bry_fmtr_arg_bfr_preserve implements Bry_fmtr_arg {
|
||||
public Bry_fmtr_arg_bfr_preserve Data_(Bry_bfr v) {bfr = v; return this;}
|
||||
public void XferAry(Bry_bfr trg, int idx) {trg.Add_bfr_and_preserve(bfr);}
|
||||
public Bry_fmtr_arg_bfr_preserve(Bry_bfr bfr) {this.bfr = bfr;} Bry_bfr bfr;
|
||||
public Bry_fmtr_arg_bfr_preserve Data_(Bry_bfr v) {bfr = v; return this;}
|
||||
public void Fmt__do(Bry_bfr trg) {trg.Add_bfr_and_preserve(bfr);}
|
||||
}
|
||||
|
@ -18,6 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.brys; import gplx.*;
|
||||
public class Bry_fmtr_arg_bry implements Bry_fmtr_arg {
|
||||
public Bry_fmtr_arg_bry Data_(byte[] v) {ary = v; return this;}
|
||||
public void XferAry(Bry_bfr trg, int idx) {trg.Add(ary);}
|
||||
public void Fmt__do(Bry_bfr bfr) {bfr.Add(ary);}
|
||||
public Bry_fmtr_arg_bry(byte[] v) {this.ary = v;} byte[] ary;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.brys; import gplx.*;
|
||||
public class Bry_fmtr_arg_byt implements Bry_fmtr_arg {
|
||||
public Bry_fmtr_arg_byt Data_(byte v) {byt = v; return this;}
|
||||
public void XferAry(Bry_bfr trg, int idx) {trg.Add_byte(byt);}
|
||||
public Bry_fmtr_arg_byt(byte byt) {this.byt = byt;} private byte byt;
|
||||
public Bry_fmtr_arg_byt Data_(byte v) {byt = v; return this;}
|
||||
public void Fmt__do(Bry_bfr bfr) {bfr.Add_byte(byt);}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ package gplx.brys; import gplx.*;
|
||||
public class Bry_fmtr_arg_decimal_int implements Bry_fmtr_arg {
|
||||
public int Val() {return val;} public Bry_fmtr_arg_decimal_int Val_(int v) {val = v; return this;} int val;
|
||||
public Bry_fmtr_arg_decimal_int Places_(int v) {places = v; multiple = (int)Math_.Pow(10, v); return this;} int multiple = 1000, places = 3;
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
bfr.Add_int_variable(val / multiple).Add_byte(Byte_ascii.Dot).Add_int_fixed(val % multiple, places);
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.brys; import gplx.*;
|
||||
public class Bry_fmtr_arg_fmtr implements Bry_fmtr_arg {
|
||||
public Bry_fmtr_arg_fmtr Data_(Bry_fmtr v) {fmtr = v; return this;}
|
||||
public void XferAry(Bry_bfr trg, int idx) {
|
||||
fmtr.Bld_bfr(trg, arg_ary);
|
||||
}
|
||||
public void Fmt__do(Bry_bfr bfr) {fmtr.Bld_bfr(bfr, arg_ary);}
|
||||
public Bry_fmtr_arg_fmtr(Bry_fmtr fmtr, Bry_fmtr_arg... arg_ary) {this.fmtr = fmtr; this.arg_ary = arg_ary;} Bry_fmtr fmtr; Bry_fmtr_arg[] arg_ary;
|
||||
}
|
||||
|
@ -18,6 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.brys; import gplx.*;
|
||||
public class Bry_fmtr_arg_int implements Bry_fmtr_arg {
|
||||
public Bry_fmtr_arg_int Data_(int v) {val = Int_.cast(v); val_digits = Int_.DigitCount(val); return this;}
|
||||
public void XferAry(Bry_bfr trg, int idx) {trg.Add_int_fixed(val, val_digits);}
|
||||
public void Fmt__do(Bry_bfr bfr) {bfr.Add_int_fixed(val, val_digits);}
|
||||
public Bry_fmtr_arg_int(int v) {this.val = v; this.val_digits = Int_.DigitCount(v);} int val, val_digits;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class Bry_fmtr_arg_time implements Bry_fmtr_arg {
|
||||
int[] units = new int[] {86400, 3600, 60, 1};
|
||||
int units_len;
|
||||
byte[] spr = new byte[] {Byte_ascii.Space};
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
if (seconds == 0) { // handle 0 separately (since it will always be < than units[*]
|
||||
bfr.Add_int_fixed(0, 2).Add(segs[units_len - 1]);
|
||||
return;
|
||||
|
@ -36,7 +36,7 @@ class Time_fmtr_arg_fxt {
|
||||
public void XferAry(int seconds, String expd) {
|
||||
Bry_bfr bfr = Bry_bfr.reset_(255);
|
||||
arg.Seconds_(seconds);
|
||||
arg.XferAry(bfr, 0);
|
||||
Tfds.Eq(expd, bfr.Xto_str());
|
||||
arg.Fmt__do(bfr);
|
||||
Tfds.Eq(expd, bfr.To_str());
|
||||
}
|
||||
}
|
||||
|
@ -34,5 +34,5 @@ class Hash_adp_noop implements Hash_adp {
|
||||
public boolean Add_if_dupe_use_1st(Object key, Object val) {return false;}
|
||||
public void Del(Object key) {}
|
||||
public void Clear() {}
|
||||
public java.util.Iterator iterator() {return gplx.lists.Iterator_null._;}
|
||||
public java.util.Iterator iterator() {return gplx.lists.Iterator_null.Instance;}
|
||||
}
|
||||
|
@ -68,8 +68,8 @@ public class Hash_adp_bry extends gplx.lists.Hash_adp_base implements Hash_adp {
|
||||
key_itm.Init(key_bry, 0, key_bry.length);
|
||||
super.Add_base(key_itm, val);
|
||||
}
|
||||
public static Hash_adp_bry cs() {return new Hash_adp_bry(Hash_adp_bry_itm_cs._);}
|
||||
public static Hash_adp_bry ci_a7() {return new Hash_adp_bry(Hash_adp_bry_itm_ci_a7._);}
|
||||
public static Hash_adp_bry cs() {return new Hash_adp_bry(Hash_adp_bry_itm_cs.Instance);}
|
||||
public static Hash_adp_bry ci_a7() {return new Hash_adp_bry(Hash_adp_bry_itm_ci_a7.Instance);}
|
||||
public static Hash_adp_bry ci_u8(Gfo_case_mgr case_mgr) {return new Hash_adp_bry(Hash_adp_bry_itm_ci_u8.get_or_new(case_mgr));}
|
||||
public static Hash_adp_bry c__u8(boolean case_match, Gfo_case_mgr case_mgr) {return case_match ? cs() : ci_u8(case_mgr);}
|
||||
}
|
||||
@ -103,7 +103,7 @@ class Hash_adp_bry_itm_cs extends Hash_adp_bry_itm_base {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static final Hash_adp_bry_itm_cs _ = new Hash_adp_bry_itm_cs(); Hash_adp_bry_itm_cs() {}
|
||||
public static final Hash_adp_bry_itm_cs Instance = new Hash_adp_bry_itm_cs(); Hash_adp_bry_itm_cs() {}
|
||||
}
|
||||
class Hash_adp_bry_itm_ci_a7 extends Hash_adp_bry_itm_base {
|
||||
private byte[] src; int src_bgn, src_end;
|
||||
@ -136,7 +136,7 @@ class Hash_adp_bry_itm_ci_a7 extends Hash_adp_bry_itm_base {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static final Hash_adp_bry_itm_ci_a7 _ = new Hash_adp_bry_itm_ci_a7(); Hash_adp_bry_itm_ci_a7() {}
|
||||
public static final Hash_adp_bry_itm_ci_a7 Instance = new Hash_adp_bry_itm_ci_a7(); Hash_adp_bry_itm_ci_a7() {}
|
||||
}
|
||||
class Hash_adp_bry_itm_ci_u8 extends Hash_adp_bry_itm_base {
|
||||
private final Gfo_case_mgr case_mgr;
|
||||
|
@ -33,6 +33,7 @@ public interface List_adp extends EnumerAble {
|
||||
Object To_ary(Class<?> memberType);
|
||||
Object To_ary_and_clear(Class<?> memberType);
|
||||
String[] To_str_ary();
|
||||
String[] To_str_ary_and_clear();
|
||||
String To_str();
|
||||
Object[] To_obj_ary();
|
||||
void Resize_bounds(int i);
|
||||
@ -64,10 +65,11 @@ class List_adp_noop implements List_adp {
|
||||
public void Resize_bounds(int i) {}
|
||||
public Object To_ary(Class<?> memberType) {return Object_.Ary_empty;}
|
||||
public Object To_ary_and_clear(Class<?> memberType) {return Object_.Ary_empty;}
|
||||
public String[] To_str_ary() {return new String[0];}
|
||||
public String[] To_str_ary() {return String_.Ary_empty;}
|
||||
public String[] To_str_ary_and_clear() {return To_str_ary();}
|
||||
public String To_str() {return "";}
|
||||
public Object[] To_obj_ary() {return Object_.Ary_empty;}
|
||||
public java.util.Iterator iterator() {return Iterator_null._;}
|
||||
public java.util.Iterator iterator() {return Iterator_null.Instance;}
|
||||
public void Reverse() {}
|
||||
public void Sort() {}
|
||||
public void Sort_by(ComparerAble comparer) {}
|
||||
|
@ -24,7 +24,7 @@ public abstract class List_adp_base implements List_adp, GfoInvkAble {
|
||||
}
|
||||
public java.util.Iterator iterator() {
|
||||
if (count == 0)
|
||||
return Iterator_null._;
|
||||
return Iterator_null.Instance;
|
||||
else
|
||||
return new Iterator_objAry(list, count);
|
||||
}
|
||||
@ -128,6 +128,7 @@ public abstract class List_adp_base implements List_adp, GfoInvkAble {
|
||||
Array_.Set_at(rv, i, list[i]);
|
||||
return rv;
|
||||
}
|
||||
public String[] To_str_ary_and_clear() {String[] rv = To_str_ary(); this.Clear(); return rv;}
|
||||
public String[] To_str_ary() {return (String[])To_ary(String.class);}
|
||||
public Object[] To_obj_ary() {
|
||||
Object[] rv = new Object[count];
|
||||
@ -139,7 +140,7 @@ public abstract class List_adp_base implements List_adp, GfoInvkAble {
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
for (int i = 0; i < count; ++i)
|
||||
bfr.Add_str_u8(Object_.Xto_str_strict_or_null_mark(list[i])).Add_byte_nl();
|
||||
return bfr.Xto_str_and_clear();
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
private void BoundsChk(int bgn, int end, int len) {
|
||||
if ( bgn >= 0 && bgn < len
|
||||
|
@ -111,7 +111,7 @@ public class List_adp_tst {
|
||||
list_AddMany("0", "1", "2");
|
||||
for (Object valObj : list) {
|
||||
String val = (String)valObj;
|
||||
Tfds.Eq(Int_.Xto_str(pos++), val);
|
||||
Tfds.Eq(Int_.To_str(pos++), val);
|
||||
tst_Enumerator("0", "1", "2");
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx;
|
||||
import gplx.core.primitives.*;
|
||||
public class Ordered_hash_ {
|
||||
public static Ordered_hash new_() {return new Ordered_hash_base();}
|
||||
public static Ordered_hash new_bry_() {return new Ordered_hash_bry();}
|
||||
public static Ordered_hash New() {return new Ordered_hash_base();}
|
||||
public static Ordered_hash New_bry() {return new Ordered_hash_bry();}
|
||||
}
|
||||
class Ordered_hash_bry extends Ordered_hash_base {
|
||||
private final Bry_obj_ref tmp_ref = Bry_obj_ref.null_();
|
||||
|
@ -67,9 +67,9 @@ public class Ordered_hash_base extends Hash_adp_base implements Ordered_hash, Gf
|
||||
private String To_str_ui() {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
int count = ordered.Count();
|
||||
int pad = String_.Len(Int_.Xto_str(count));
|
||||
int pad = String_.Len(Int_.To_str(count));
|
||||
for (int i = 0; i < count; i++) {
|
||||
sb .Add(Int_.Xto_str_pad_bgn_zero(i, pad))
|
||||
sb .Add(Int_.To_str_pad_bgn_zero(i, pad))
|
||||
.Add(":").Add(ordered.Get_at(i).toString())
|
||||
.Add(Op_sys.Cur().Nl_str());
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ package gplx;
|
||||
import org.junit.*;
|
||||
public class Ordered_hash_tst {
|
||||
@Before public void setup() {
|
||||
hash = Ordered_hash_.new_();
|
||||
hash = Ordered_hash_.New();
|
||||
}
|
||||
@Test public void Get_at() {
|
||||
hash.Add("key1", "val1");
|
||||
|
@ -20,5 +20,5 @@ public class Iterator_null implements java.util.Iterator {
|
||||
public boolean hasNext() {return false;}
|
||||
public Object next() {return null;}
|
||||
public void remove() {}
|
||||
public static final Iterator_null _ = new Iterator_null();
|
||||
public static final Iterator_null Instance = new Iterator_null();
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class CharStream {
|
||||
length = (pos + length > len) ? len - pos : length;
|
||||
return Char_.To_str(ary, pos, length);
|
||||
}
|
||||
public String Xto_str_by_pos(int bgn, int end) {
|
||||
public String To_str_by_pos(int bgn, int end) {
|
||||
if (bgn < 0) bgn = 0; if (end > len - 1) end = len - 1;
|
||||
return Char_.To_str(ary, bgn, end - bgn + 1);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public class HexDecUtl {
|
||||
case 0: return '0'; case 1: return '1'; case 2: return '2'; case 3: return '3'; case 4: return '4';
|
||||
case 5: return '5'; case 6: return '6'; case 7: return '7'; case 8: return '8'; case 9: return '9';
|
||||
case 10: return 'A'; case 11: return 'B'; case 12: return 'C'; case 13: return 'D'; case 14: return 'E'; case 15: return 'F';
|
||||
default: throw Err_.new_parse("hexstring", Int_.Xto_str(val));
|
||||
default: throw Err_.new_parse("hexstring", Int_.To_str(val));
|
||||
}
|
||||
}
|
||||
static byte Xto_byte(int v) {
|
||||
@ -82,7 +82,7 @@ public class HexDecUtl {
|
||||
case 0: return Byte_ascii.Num_0; case 1: return Byte_ascii.Num_1; case 2: return Byte_ascii.Num_2; case 3: return Byte_ascii.Num_3; case 4: return Byte_ascii.Num_4;
|
||||
case 5: return Byte_ascii.Num_5; case 6: return Byte_ascii.Num_6; case 7: return Byte_ascii.Num_7; case 8: return Byte_ascii.Num_8; case 9: return Byte_ascii.Num_9;
|
||||
case 10: return Byte_ascii.Ltr_A; case 11: return Byte_ascii.Ltr_B; case 12: return Byte_ascii.Ltr_C; case 13: return Byte_ascii.Ltr_D; case 14: return Byte_ascii.Ltr_E; case 15: return Byte_ascii.Ltr_F;
|
||||
default: throw Err_.new_parse("hexstring", Int_.Xto_str(v));
|
||||
default: throw Err_.new_parse("hexstring", Int_.To_str(v));
|
||||
}
|
||||
}
|
||||
public static void Write(byte[] bry, int bgn, int end, int val) {
|
||||
|
@ -47,11 +47,11 @@ public class StringTableBldr {
|
||||
}
|
||||
sb.Add(String_.CrLf);
|
||||
}
|
||||
return sb.Xto_str_and_clear();
|
||||
return sb.To_str_and_clear();
|
||||
}
|
||||
|
||||
public static StringTableBldr new_() {return new StringTableBldr();} StringTableBldr() {}
|
||||
Ordered_hash cols = Ordered_hash_.new_();
|
||||
Ordered_hash cols = Ordered_hash_.New();
|
||||
List_adp rows = List_adp_.new_();
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ class HashDlgWtrDefault implements HashDlgWtr {
|
||||
current += increment;
|
||||
int percentage = (current * 100) / total;
|
||||
if (percentage <= lastPercentage) return;
|
||||
dialog.Write_tmp(String_.LimitToFirst(p, dialog.Chars_per_line_max()) + Int_.Xto_str(percentage) + "%");
|
||||
dialog.Write_tmp(String_.LimitToFirst(p, dialog.Chars_per_line_max()) + Int_.To_str(percentage) + "%");
|
||||
lastPercentage = percentage;
|
||||
}
|
||||
public void End() {}
|
||||
|
@ -19,7 +19,7 @@ package gplx;
|
||||
import gplx.core.primitives.*; import gplx.ios.*; /*IoItmFil, IoItmDir..*/
|
||||
public class Io_mgr { // exists primarily to gather all cmds under gplx namespace; otherwise need to use gplx.ios whenever copying/deleting file
|
||||
public boolean Exists(Io_url url) {return url.Type_dir() ? ExistsDir(url) : ExistsFil(url);}
|
||||
public boolean ExistsFil(Io_url url) {return IoEnginePool._.Get_by(url.Info().EngineKey()).ExistsFil_api(url);}
|
||||
public boolean ExistsFil(Io_url url) {return IoEnginePool.Instance.Get_by(url.Info().EngineKey()).ExistsFil_api(url);}
|
||||
public void ExistsFilOrFail(Io_url url) {if (!ExistsFil(url)) throw Err_.new_wo_type("could not find file", "url", url);}
|
||||
public void SaveFilStr(String url, String text) {SaveFilStr_args(Io_url_.new_fil_(url), text).Exec();}
|
||||
public void SaveFilStr(Io_url url, String text) {SaveFilStr_args(url, text).Exec();}
|
||||
@ -32,16 +32,16 @@ public class Io_mgr { // exists primarily to gather all cmds under gplx namespac
|
||||
public IoEngine_xrg_xferFil MoveFil_args(Io_url src, Io_url trg, boolean overwrite) {return IoEngine_xrg_xferFil.move_(src, trg).Overwrite_(overwrite);}
|
||||
public void CopyFil(Io_url src, Io_url trg, boolean overwrite) {IoEngine_xrg_xferFil.copy_(src, trg).Overwrite_(overwrite).Exec();}
|
||||
public IoEngine_xrg_xferFil CopyFil_args(Io_url src, Io_url trg, boolean overwrite) {return IoEngine_xrg_xferFil.copy_(src, trg).Overwrite_(overwrite);}
|
||||
public IoRecycleBin RecycleBin() {return recycleBin;} IoRecycleBin recycleBin = IoRecycleBin._;
|
||||
public IoRecycleBin RecycleBin() {return recycleBin;} IoRecycleBin recycleBin = IoRecycleBin.Instance;
|
||||
|
||||
public IoStream OpenStreamWrite(Io_url url) {return OpenStreamWrite_args(url).Exec();}
|
||||
public IoEngine_xrg_openWrite OpenStreamWrite_args(Io_url url) {return IoEngine_xrg_openWrite.new_(url);}
|
||||
public IoItmFil QueryFil(Io_url url) {return IoEnginePool._.Get_by(url.Info().EngineKey()).QueryFil(url);}
|
||||
public void UpdateFilAttrib(Io_url url, IoItmAttrib attrib) {IoEnginePool._.Get_by(url.Info().EngineKey()).UpdateFilAttrib(url, attrib);}
|
||||
public void UpdateFilModifiedTime(Io_url url, DateAdp modified) {IoEnginePool._.Get_by(url.Info().EngineKey()).UpdateFilModifiedTime(url, modified);}
|
||||
public IoItmFil QueryFil(Io_url url) {return IoEnginePool.Instance.Get_by(url.Info().EngineKey()).QueryFil(url);}
|
||||
public void UpdateFilAttrib(Io_url url, IoItmAttrib attrib) {IoEnginePool.Instance.Get_by(url.Info().EngineKey()).UpdateFilAttrib(url, attrib);}
|
||||
public void UpdateFilModifiedTime(Io_url url, DateAdp modified) {IoEnginePool.Instance.Get_by(url.Info().EngineKey()).UpdateFilModifiedTime(url, modified);}
|
||||
|
||||
public boolean ExistsDir(Io_url url) {return IoEnginePool._.Get_by(url.Info().EngineKey()).ExistsDir(url);}
|
||||
public void CreateDir(Io_url url) {IoEnginePool._.Get_by(url.Info().EngineKey()).CreateDir(url);}
|
||||
public boolean ExistsDir(Io_url url) {return IoEnginePool.Instance.Get_by(url.Info().EngineKey()).ExistsDir(url);}
|
||||
public void CreateDir(Io_url url) {IoEnginePool.Instance.Get_by(url.Info().EngineKey()).CreateDir(url);}
|
||||
public boolean CreateDirIfAbsent(Io_url url) {
|
||||
boolean exists = ExistsDir(url);
|
||||
if (!exists) {
|
||||
@ -70,7 +70,7 @@ public class Io_mgr { // exists primarily to gather all cmds under gplx namespac
|
||||
this.DeleteDirDeep(url);
|
||||
}
|
||||
public void AliasDir_sysEngine(String srcRoot, String trgRoot) {AliasDir(srcRoot, trgRoot, IoEngine_.SysKey);}
|
||||
public void AliasDir(String srcRoot, String trgRoot, String engineKey) {IoUrlInfoRegy._.Reg(IoUrlInfo_.alias_(srcRoot, trgRoot, engineKey));}
|
||||
public void AliasDir(String srcRoot, String trgRoot, String engineKey) {IoUrlInfoRegy.Instance.Reg(IoUrlInfo_.alias_(srcRoot, trgRoot, engineKey));}
|
||||
public IoStream OpenStreamRead(Io_url url) {return OpenStreamRead_args(url).ExecAsIoStreamOrFail();}
|
||||
public IoEngine_xrg_openRead OpenStreamRead_args(Io_url url) {return IoEngine_xrg_openRead.new_(url);}
|
||||
public String LoadFilStr(String url) {return LoadFilStr_args(Io_url_.new_fil_(url)).Exec();}
|
||||
@ -131,30 +131,30 @@ public class Io_mgr { // exists primarily to gather all cmds under gplx namespac
|
||||
public IoEngine InitEngine_mem() {return IoEngine_.Mem_init_();}
|
||||
public IoEngine InitEngine_mem_(String key) {
|
||||
IoEngine engine = IoEngine_.mem_new_(key);
|
||||
IoEnginePool._.Add_if_dupe_use_nth(engine);
|
||||
IoUrlInfoRegy._.Reg(IoUrlInfo_.mem_(key, key));
|
||||
IoEnginePool.Instance.Add_if_dupe_use_nth(engine);
|
||||
IoUrlInfoRegy.Instance.Reg(IoUrlInfo_.mem_(key, key));
|
||||
return engine;
|
||||
}
|
||||
public boolean DownloadFil(String src, Io_url trg) {return IoEngine_xrg_downloadFil.new_(src, trg).Exec();}
|
||||
public IoEngine_xrg_downloadFil DownloadFil_args(String src, Io_url trg) {return IoEngine_xrg_downloadFil.new_(src, trg);}
|
||||
public static final Io_mgr I = new Io_mgr(); public Io_mgr() {}
|
||||
public static final Io_mgr Instance = new Io_mgr(); public Io_mgr() {}
|
||||
public static final int Len_kb = 1024, Len_mb = 1048576, Len_gb = 1073741824, Len_gb_2 = 2147483647;
|
||||
public static final long Len_mb_long = Len_mb;
|
||||
public static final long Len_null = -1;
|
||||
}
|
||||
class Io_mgr_ {
|
||||
public static int Delete_dir_empty(Io_url url) {
|
||||
IoItmDir dir = Io_mgr.I.QueryDir_args(url).ExecAsDir();
|
||||
IoItmDir dir = Io_mgr.Instance.QueryDir_args(url).ExecAsDir();
|
||||
int sub_dirs_len = dir.SubDirs().Count();
|
||||
int deleted_dirs = 0;
|
||||
for (int i = 0; i < sub_dirs_len; ++i) {
|
||||
IoItmDir sub_dir = (IoItmDir)dir.SubDirs().Get_at(i);
|
||||
deleted_dirs += Io_mgr.I.Delete_dir_empty(sub_dir.Url());
|
||||
deleted_dirs += Io_mgr.Instance.Delete_dir_empty(sub_dir.Url());
|
||||
}
|
||||
if ( dir.SubFils().Count() == 0
|
||||
&& deleted_dirs == sub_dirs_len
|
||||
) {
|
||||
Io_mgr.I.DeleteDirIfEmpty(url);
|
||||
Io_mgr.Instance.DeleteDirIfEmpty(url);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
@ -77,23 +77,23 @@ public class Io_mgr__tst {
|
||||
}
|
||||
}
|
||||
class Io_mgr__fxt {
|
||||
public void Clear() {Io_mgr.I.InitEngine_mem();}
|
||||
public void Clear() {Io_mgr.Instance.InitEngine_mem();}
|
||||
public void Exec_itm_create(String... ary) {
|
||||
for (String itm : ary) {
|
||||
Io_url url = Io_url_.new_any_(itm);
|
||||
if (url.Type_dir())
|
||||
Io_mgr.I.CreateDir(url);
|
||||
Io_mgr.Instance.CreateDir(url);
|
||||
else
|
||||
Io_mgr.I.SaveFilStr(url, url.NameAndExt());
|
||||
Io_mgr.Instance.SaveFilStr(url, url.NameAndExt());
|
||||
}
|
||||
}
|
||||
public void Exec_dir_delete_empty(String url) {Io_mgr.I.Delete_dir_empty(Io_url_.mem_dir_(url));}
|
||||
public void Exec_dir_delete_empty(String url) {Io_mgr.Instance.Delete_dir_empty(Io_url_.mem_dir_(url));}
|
||||
public void Test_itm_exists_n(String... ary) {Test_itm_exists(Bool_.N, ary);}
|
||||
public void Test_itm_exists_y(String... ary) {Test_itm_exists(Bool_.Y, ary);}
|
||||
public void Test_itm_exists(boolean expd, String... ary) {
|
||||
for (String itm : ary) {
|
||||
Io_url url = Io_url_.new_any_(itm);
|
||||
boolean actl = url.Type_dir() ? Io_mgr.I.ExistsDir(url) : Io_mgr.I.ExistsFil(url);
|
||||
boolean actl = url.Type_dir() ? Io_mgr.Instance.ExistsDir(url) : Io_mgr.Instance.ExistsFil(url);
|
||||
Tfds.Eq(expd, actl, itm);
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ class IoEngineUtl {
|
||||
IoStream srcStream = null;
|
||||
IoStream trgStream = null;
|
||||
try {
|
||||
srcStream = IoEnginePool._.Get_by(src.Info().EngineKey()).OpenStreamRead(src);
|
||||
srcStream = IoEnginePool.Instance.Get_by(src.Info().EngineKey()).OpenStreamRead(src);
|
||||
trgStream = IoEngine_xrg_openWrite.new_(trg).Exec();
|
||||
srcStream.Transfer(trgStream, bufferLength);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class IoEnginePool {
|
||||
IoEngine rv = (IoEngine)hash.Get_by(key);
|
||||
return rv == null ? IoEngine_.Mem : rv; // rv == null when url is null or empty; return Mem which should be a noop; DATE:2013-06-04
|
||||
}
|
||||
public static final IoEnginePool _ = new IoEnginePool();
|
||||
public static final IoEnginePool Instance = new IoEnginePool();
|
||||
IoEnginePool() {
|
||||
this.Add_if_dupe_use_nth(IoEngine_.Sys);
|
||||
this.Add_if_dupe_use_nth(IoEngine_.Mem);
|
||||
|
@ -49,7 +49,7 @@ public abstract class IoEngine_base implements IoEngine {
|
||||
Io_url recycleUrl = xrg.RecycleUrl();
|
||||
if (recycleUrl.Type_fil()) {
|
||||
this.MoveFil(IoEngine_xrg_xferFil.move_(xrg.Url(), recycleUrl).Overwrite_(false).ReadOnlyFails_(true).MissingFails_(xrg.MissingFails()));
|
||||
IoRecycleBin._.Regy_add(xrg);
|
||||
IoRecycleBin.Instance.Regy_add(xrg);
|
||||
}
|
||||
else
|
||||
this.MoveDirDeep(IoEngine_xrg_xferDir.move_(xrg.Url(), recycleUrl).Overwrite_(false).ReadOnlyFails_(true));
|
||||
|
@ -118,8 +118,8 @@ public class IoEngine_memory extends IoEngine_base {
|
||||
IoItmDir ownerDir = FetchDir(url.OwnerDir()); if (ownerDir == null) return; // no ownerDir; no need to unregister
|
||||
ownerDir.SubDirs().Del(url);
|
||||
}
|
||||
@Override public void XferDir(IoEngine_xrg_xferDir args) {Io_url trg = args.Trg(); utl.XferDir(this, args.Src(), IoEnginePool._.Get_by(trg.Info().EngineKey()), trg, args);}
|
||||
@Override public void MoveDirDeep(IoEngine_xrg_xferDir args) {Io_url trg = args.Trg(); utl.XferDir(this, args.Src(), IoEnginePool._.Get_by(trg.Info().EngineKey()), trg, args);}
|
||||
@Override public void XferDir(IoEngine_xrg_xferDir args) {Io_url trg = args.Trg(); utl.XferDir(this, args.Src(), IoEnginePool.Instance.Get_by(trg.Info().EngineKey()), trg, args);}
|
||||
@Override public void MoveDirDeep(IoEngine_xrg_xferDir args) {Io_url trg = args.Trg(); utl.XferDir(this, args.Src(), IoEnginePool.Instance.Get_by(trg.Info().EngineKey()), trg, args);}
|
||||
@Override public void MoveDir(Io_url src, Io_url trg) {if (ExistsDir(trg)) throw Err_.new_wo_type("trg already exists", "trg", trg);
|
||||
IoItmDir dir = FetchDir(src); dir.Name_(trg.NameAndExt());
|
||||
for (Object filObj : dir.SubFils()) { // move all subFiles
|
||||
|
@ -31,11 +31,11 @@ import gplx.core.criterias.*;
|
||||
public class IoEngine_system extends IoEngine_base {
|
||||
@Override public String Key() {return IoEngine_.SysKey;}
|
||||
@Override public void DeleteDirDeep(IoEngine_xrg_deleteDir args) {utl.DeleteDirDeep(this, args.Url(), args);}
|
||||
@Override public void XferDir(IoEngine_xrg_xferDir args) {Io_url trg = args.Trg(); utl.XferDir(this, args.Src(), IoEnginePool._.Get_by(trg.Info().EngineKey()), trg, args);}
|
||||
@Override public void XferDir(IoEngine_xrg_xferDir args) {Io_url trg = args.Trg(); utl.XferDir(this, args.Src(), IoEnginePool.Instance.Get_by(trg.Info().EngineKey()), trg, args);}
|
||||
@Override public void XferFil(IoEngine_xrg_xferFil args) {utl.XferFil(this, args);}
|
||||
@Override public IoItmDir QueryDirDeep(IoEngine_xrg_queryDir args) {return utl.QueryDirDeep(this, args);}
|
||||
@Override public void CopyDir(Io_url src, Io_url trg) {IoEngine_xrg_xferDir.copy_(src, trg).Recur_().Exec();}
|
||||
@Override public void MoveDirDeep(IoEngine_xrg_xferDir args) {Io_url trg = args.Trg(); utl.XferDir(this, args.Src(), IoEnginePool._.Get_by(trg.Info().EngineKey()), trg, args);}
|
||||
@Override public void MoveDirDeep(IoEngine_xrg_xferDir args) {Io_url trg = args.Trg(); utl.XferDir(this, args.Src(), IoEnginePool.Instance.Get_by(trg.Info().EngineKey()), trg, args);}
|
||||
@Override public void DeleteFil_api(IoEngine_xrg_deleteFil args) {
|
||||
Io_url url = args.Url();
|
||||
File fil = Fil_(url);
|
||||
@ -98,14 +98,14 @@ public class IoEngine_system extends IoEngine_base {
|
||||
}
|
||||
@SuppressWarnings("resource") public static String Load_from_stream_as_str(InputStream stream, String url_str) {
|
||||
InputStreamReader reader = null;
|
||||
try {reader = new InputStreamReader(stream, IoEngineArgs._.LoadFilStr_Encoding);}
|
||||
try {reader = new InputStreamReader(stream, IoEngineArgs.Instance.LoadFilStr_Encoding);}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
Closeable_close(stream, url_str, false);
|
||||
throw Err_text_unsupported_encoding(IoEngineArgs._.LoadFilStr_Encoding, "", url_str, e);
|
||||
throw Err_text_unsupported_encoding(IoEngineArgs.Instance.LoadFilStr_Encoding, "", url_str, e);
|
||||
}
|
||||
|
||||
// make other objects
|
||||
char[] readerBuffer = new char[IoEngineArgs._.LoadFilStr_BufferSize];
|
||||
char[] readerBuffer = new char[IoEngineArgs.Instance.LoadFilStr_BufferSize];
|
||||
int pos = 0;
|
||||
StringWriter sw = new StringWriter();
|
||||
|
||||
@ -135,7 +135,7 @@ public class IoEngine_system extends IoEngine_base {
|
||||
File dir = new File(url.Xto_api());
|
||||
if (!dir.exists()) return;
|
||||
boolean rv = dir.delete();
|
||||
if (!rv) throw Err_.new_(IoEngineArgs._.Err_IoException, "delete dir failed", "url", url.Xto_api());
|
||||
if (!rv) throw Err_.new_(IoEngineArgs.Instance.Err_IoException, "delete dir failed", "url", url.Xto_api());
|
||||
}
|
||||
@Override public IoItmDir QueryDir(Io_url url) {
|
||||
IoItmDir rv = IoItmDir_.scan_(url);
|
||||
@ -185,7 +185,7 @@ public class IoEngine_system extends IoEngine_base {
|
||||
if (!Op_sys.Cur().Tid_is_drd())
|
||||
IoEngine_system_xtn.SetWritable(f, true);
|
||||
}
|
||||
if (!rv) throw Err_.new_(IoEngineArgs._.Err_IoException, "set file attribute failed", "attribute", "readOnly", "cur", Fil_ReadOnly(f), "new", atr.ReadOnly(), "url", url.Xto_api());
|
||||
if (!rv) throw Err_.new_(IoEngineArgs.Instance.Err_IoException, "set file attribute failed", "attribute", "readOnly", "cur", Fil_ReadOnly(f), "new", atr.ReadOnly(), "url", url.Xto_api());
|
||||
}
|
||||
if (atr.Hidden() != f.isHidden()) {
|
||||
//Runtime.getRuntime().exec("attrib +H myHiddenFile.java");
|
||||
@ -265,7 +265,7 @@ public class IoEngine_system extends IoEngine_base {
|
||||
long pos = 0, count = 0, read = 0;
|
||||
try {count = srcChannel.size();}
|
||||
catch (IOException e) {throw Err_.new_exc(e, "io", "size failed", "src", srcUrl.Xto_api());}
|
||||
int totalBufferSize = IoEngineArgs._.LoadFilStr_BufferSize;
|
||||
int totalBufferSize = IoEngineArgs.Instance.LoadFilStr_BufferSize;
|
||||
long transferSize = (count > totalBufferSize) ? totalBufferSize : count; // transfer as much as fileSize, but limit to LoadFilStr_BufferSize
|
||||
while (pos < count) {
|
||||
try {read = trgChannel.transferFrom(srcChannel, pos, transferSize);}
|
||||
@ -389,7 +389,7 @@ public class IoEngine_system extends IoEngine_base {
|
||||
java.net.URL src_url = null;
|
||||
HttpURLConnection src_conn = null;
|
||||
if (user_agent_needs_resetting) {user_agent_needs_resetting = false; System.setProperty("http.agent", "");}
|
||||
boolean exists = Io_mgr.I.ExistsDir(xrg.Trg().OwnerDir());
|
||||
boolean exists = Io_mgr.Instance.ExistsDir(xrg.Trg().OwnerDir());
|
||||
Gfo_usr_dlg prog_dlg = null;
|
||||
String src_str = xrg.Src();
|
||||
Io_download_fmt xfer_fmt = xrg.Download_fmt();
|
||||
@ -402,7 +402,7 @@ public class IoEngine_system extends IoEngine_base {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
trg_stream = Io_mgr.I.OpenStreamWrite(xrg.Trg());
|
||||
trg_stream = Io_mgr.Instance.OpenStreamWrite(xrg.Trg());
|
||||
src_url = new java.net.URL(src_str);
|
||||
src_conn = (HttpURLConnection)src_url.openConnection();
|
||||
// src_conn.setReadTimeout(5000); // do not set; if file does not exist, will wait 5 seconds before timing out; want to fail immediately
|
||||
@ -414,7 +414,7 @@ public class IoEngine_system extends IoEngine_base {
|
||||
if (xrg.Exec_meta_only()) return true;
|
||||
src_stream = new java.io.BufferedInputStream(src_conn.getInputStream());
|
||||
if (!exists) {
|
||||
Io_mgr.I.CreateDir(xrg.Trg().OwnerDir()); // dir must exist for OpenStreamWrite; create dir at last possible moment in case stream does not exist.
|
||||
Io_mgr.Instance.CreateDir(xrg.Trg().OwnerDir()); // dir must exist for OpenStreamWrite; create dir at last possible moment in case stream does not exist.
|
||||
}
|
||||
byte[] download_bfr = new byte[Download_bfr_len]; // NOTE: download_bfr was originally member variable; DATE:2013-05-03
|
||||
xfer_fmt.Bgn(content_length);
|
||||
@ -423,7 +423,7 @@ public class IoEngine_system extends IoEngine_base {
|
||||
if (xrg.Prog_cancel()) {
|
||||
src_stream.close();
|
||||
trg_stream.Rls();
|
||||
Io_mgr.I.DeleteFil(xrg.Trg());
|
||||
Io_mgr.Instance.DeleteFil(xrg.Trg());
|
||||
}
|
||||
xfer_fmt.Prog(count);
|
||||
trg_stream.Write(download_bfr, 0, count);
|
||||
@ -467,7 +467,7 @@ public class IoEngine_system extends IoEngine_base {
|
||||
} Io_url session_fil; Bry_bfr prog_fmt_bfr;
|
||||
byte[] download_bfr; static final int Download_bfr_len = Io_mgr.Len_kb * 128;
|
||||
public static Err Err_Fil_NotFound(Io_url url) {
|
||||
return Err_.new_(IoEngineArgs._.Err_FileNotFound, "file not found", "url", url.Xto_api()).Trace_ignore_add_1_();
|
||||
return Err_.new_(IoEngineArgs.Instance.Err_FileNotFound, "file not found", "url", url.Xto_api()).Trace_ignore_add_1_();
|
||||
}
|
||||
public static Err Err_Fil_NotFound(Exception e, Io_url url) {
|
||||
return Err_.new_exc(e, "io", "file not found", "url", url.Xto_api()).Trace_ignore_add_1_();
|
||||
@ -475,7 +475,7 @@ public class IoEngine_system extends IoEngine_base {
|
||||
void MarkFileWritable(File fil, Io_url url, boolean readOnlyFails, String op) {
|
||||
if (Fil_ReadOnly(fil)) {
|
||||
if (readOnlyFails) // NOTE: java will always allow final files to be deleted; programmer api is responsible for check
|
||||
throw Err_.new_(IoEngineArgs._.Err_ReadonlyFileNotWritable, "writable operation attempted on readOnly file", "op", op, "url", url.Xto_api());
|
||||
throw Err_.new_(IoEngineArgs.Instance.Err_ReadonlyFileNotWritable, "writable operation attempted on readOnly file", "op", op, "url", url.Xto_api());
|
||||
else
|
||||
Fil_Writable(fil);
|
||||
}
|
||||
@ -483,7 +483,7 @@ public class IoEngine_system extends IoEngine_base {
|
||||
void DeleteFil_lang(File fil, Io_url url) {
|
||||
boolean rv = Fil_Delete(fil);
|
||||
if (!rv)
|
||||
throw Err_.new_(IoEngineArgs._.Err_IoException, "file not deleted", "url", url.Xto_api());
|
||||
throw Err_.new_(IoEngineArgs.Instance.Err_IoException, "file not deleted", "url", url.Xto_api());
|
||||
}
|
||||
IoEngineUtl utl = IoEngineUtl.new_();
|
||||
public static IoEngine_system new_() {return new IoEngine_system();} IoEngine_system() {}
|
||||
@ -496,7 +496,7 @@ class IoEngineArgs {
|
||||
public String Err_ReadonlyFileNotWritable = "gplx.ios.ReadonlyFileNotWritable";
|
||||
public String Err_FileNotFound = "gplx.ios.FileNotFound";
|
||||
public String Err_IoException = "gplx.ios.IoException";
|
||||
public static final IoEngineArgs _ = new IoEngineArgs();
|
||||
public static final IoEngineArgs Instance = new IoEngineArgs();
|
||||
}
|
||||
class IoEngine_system_xtn {
|
||||
// PATCH.DROID:VerifyError if file.setExecutable is referenced directly in IoEngine_system. However, if placed in separate class
|
||||
@ -513,10 +513,10 @@ class Io_download_http {
|
||||
Io_stream_rdr_http rdr = new Io_stream_rdr_http(xrg);
|
||||
IoStream trg_stream = null;
|
||||
try {
|
||||
boolean exists = Io_mgr.I.ExistsDir(xrg.Trg().OwnerDir());
|
||||
boolean exists = Io_mgr.Instance.ExistsDir(xrg.Trg().OwnerDir());
|
||||
if (!exists)
|
||||
Io_mgr.I.CreateDir(xrg.Trg().OwnerDir()); // dir must exist for OpenStreamWrite; create dir at last possible moment in case stream does not exist.
|
||||
trg_stream = Io_mgr.I.OpenStreamWrite(xrg.Trg());
|
||||
Io_mgr.Instance.CreateDir(xrg.Trg().OwnerDir()); // dir must exist for OpenStreamWrite; create dir at last possible moment in case stream does not exist.
|
||||
trg_stream = Io_mgr.Instance.OpenStreamWrite(xrg.Trg());
|
||||
byte[] bfr = new byte[Download_bfr_len];
|
||||
rdr.Open();
|
||||
while (rdr.Read(bfr, 0, Download_bfr_len) != Read_done) {
|
||||
@ -527,7 +527,7 @@ class Io_download_http {
|
||||
if (trg_stream != null) trg_stream.Rls();
|
||||
}
|
||||
if (xrg.Rslt() != IoEngine_xrg_downloadFil.Rslt_pass)
|
||||
Io_mgr.I.DeleteFil_args(xrg.Trg()).MissingFails_off().Exec();
|
||||
Io_mgr.Instance.DeleteFil_args(xrg.Trg()).MissingFails_off().Exec();
|
||||
}
|
||||
public static final int Read_done = -1;
|
||||
public static final int Download_bfr_len = Io_mgr.Len_kb * 128;
|
||||
|
@ -25,7 +25,7 @@ public class IoEngine_xrg_deleteDir {
|
||||
public Criteria MatchCrt() {return matchCrt;} public IoEngine_xrg_deleteDir MatchCrt_(Criteria v) {matchCrt = v; return this;} Criteria matchCrt = Criteria_.All;
|
||||
public Criteria SubDirScanCrt() {return subDirScanCrt;} public IoEngine_xrg_deleteDir SubDirScanCrt_(Criteria v) {subDirScanCrt = v; return this;} Criteria subDirScanCrt = Criteria_.All;
|
||||
public Console_adp UsrDlg() {return usrDlg;} public IoEngine_xrg_deleteDir UsrDlg_(Console_adp v) {usrDlg = v; return this;} Console_adp usrDlg = Console_adp_.Noop;
|
||||
public void Exec() {IoEnginePool._.Get_by(url.Info().EngineKey()).DeleteDirDeep(this);}
|
||||
public void Exec() {IoEnginePool.Instance.Get_by(url.Info().EngineKey()).DeleteDirDeep(this);}
|
||||
public static IoEngine_xrg_deleteDir new_(Io_url url) {
|
||||
IoEngine_xrg_deleteDir rv = new IoEngine_xrg_deleteDir();
|
||||
rv.url = url;
|
||||
|
@ -20,7 +20,7 @@ public class IoEngine_xrg_deleteFil extends IoEngine_xrg_fil_affects1_base {
|
||||
@gplx.New public IoEngine_xrg_deleteFil Url_(Io_url val) {Url_set(val); return this;}
|
||||
public IoEngine_xrg_deleteFil ReadOnlyFails_off() {return ReadOnlyFails_(false);} public IoEngine_xrg_deleteFil ReadOnlyFails_(boolean v) {ReadOnlyFails_set(v); return this;}
|
||||
public IoEngine_xrg_deleteFil MissingFails_off() {return MissingFails_(false);} public IoEngine_xrg_deleteFil MissingFails_(boolean v) {MissingFails_set(v); return this;}
|
||||
@Override public void Exec() {IoEnginePool._.Get_by(this.Url().Info().EngineKey()).DeleteFil_api(this);}
|
||||
@Override public void Exec() {IoEnginePool.Instance.Get_by(this.Url().Info().EngineKey()).DeleteFil_api(this);}
|
||||
public static IoEngine_xrg_deleteFil proto_() {return new IoEngine_xrg_deleteFil();}
|
||||
public static IoEngine_xrg_deleteFil new_(Io_url url) {
|
||||
IoEngine_xrg_deleteFil rv = new IoEngine_xrg_deleteFil();
|
||||
|
@ -35,20 +35,20 @@ public class IoEngine_xrg_downloadFil {
|
||||
public boolean Src_last_modified_query() {return src_last_modified_query;} public IoEngine_xrg_downloadFil Src_last_modified_query_(boolean v) {src_last_modified_query = v; return this;} private boolean src_last_modified_query;
|
||||
public String Trg_engine_key() {return trg_engine_key;} public IoEngine_xrg_downloadFil Trg_engine_key_(String v) {trg_engine_key = v; return this;} private String trg_engine_key = IoEngine_.SysKey;
|
||||
public Io_download_fmt Download_fmt() {return download_fmt;} private final Io_download_fmt download_fmt = new Io_download_fmt();
|
||||
public boolean Exec() {return IoEnginePool._.Get_by(trg.Info().EngineKey()).DownloadFil(this);}
|
||||
public Io_stream_rdr Exec_as_rdr() {return IoEnginePool._.Get_by(IoEngine_.SysKey).DownloadFil_as_rdr(this);}
|
||||
public boolean Exec() {return IoEnginePool.Instance.Get_by(trg.Info().EngineKey()).DownloadFil(this);}
|
||||
public Io_stream_rdr Exec_as_rdr() {return IoEnginePool.Instance.Get_by(IoEngine_.SysKey).DownloadFil_as_rdr(this);}
|
||||
public boolean Exec_meta_only() {return exec_meta_only;} private boolean exec_meta_only;
|
||||
public byte[] Exec_as_bry(String src) {
|
||||
this.Src_(src); this.Trg_(trg_mem);
|
||||
download_fmt.Download_init(src, prog_fmt_hdr); // NOTE: must set src else NULL error
|
||||
boolean pass = IoEnginePool._.Get_by(trg_engine_key).DownloadFil(this);
|
||||
return pass ? Io_mgr.I.LoadFilBry(trg_mem) : null;
|
||||
boolean pass = IoEnginePool.Instance.Get_by(trg_engine_key).DownloadFil(this);
|
||||
return pass ? Io_mgr.Instance.LoadFilBry(trg_mem) : null;
|
||||
} private Io_url trg_mem = Io_url_.mem_fil_("mem/download.tmp");
|
||||
public boolean Exec_meta(String src) {
|
||||
this.Src_(src); this.Trg_(trg_mem); // NOTE: set Trg_ else error in download proc
|
||||
download_fmt.Download_init(src, prog_fmt_hdr); // NOTE: must set src else NULL error
|
||||
exec_meta_only = true;
|
||||
boolean rv = IoEnginePool._.Get_by(trg_engine_key).DownloadFil(this);
|
||||
boolean rv = IoEnginePool.Instance.Get_by(trg_engine_key).DownloadFil(this);
|
||||
exec_meta_only = false;
|
||||
return rv;
|
||||
}
|
||||
|
@ -22,10 +22,10 @@ public class IoEngine_xrg_loadFilStr {
|
||||
public boolean MissingIgnored() {return missingIgnored;} public IoEngine_xrg_loadFilStr MissingIgnored_() {return MissingIgnored_(true);} public IoEngine_xrg_loadFilStr MissingIgnored_(boolean v) {missingIgnored = v; return this;} private boolean missingIgnored = false;
|
||||
public boolean BomUtf8Convert() {return bomUtf8Convert;} public IoEngine_xrg_loadFilStr BomUtf8Convert_(boolean v) {bomUtf8Convert = v; return this;} private boolean bomUtf8Convert = true;
|
||||
public String Exec() {
|
||||
String s = IoEnginePool._.Get_by(url.Info().EngineKey()).LoadFilStr(this);
|
||||
String s = IoEnginePool.Instance.Get_by(url.Info().EngineKey()).LoadFilStr(this);
|
||||
if (bomUtf8Convert && String_.Len(s) > 0 && String_.CodePointAt(s, 0) == Bom_Utf8) {
|
||||
s = String_.Mid(s, 1);
|
||||
UsrDlg_._.Warn(UsrMsg.new_("UTF8 BOM removed").Add("url", url.Xto_api()));
|
||||
UsrDlg_.Instance.Warn(UsrMsg.new_("UTF8 BOM removed").Add("url", url.Xto_api()));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
@ -19,9 +19,9 @@ package gplx.ios; import gplx.*;
|
||||
public class IoEngine_xrg_openRead {
|
||||
public Io_url Url() {return url;} Io_url url;
|
||||
public String ErrMsg() {return errMsg;} private String errMsg;
|
||||
public IoStream ExecAsIoStreamOrFail() {return IoEnginePool._.Get_by(url.Info().EngineKey()).OpenStreamRead(url);}
|
||||
public IoStream ExecAsIoStreamOrFail() {return IoEnginePool.Instance.Get_by(url.Info().EngineKey()).OpenStreamRead(url);}
|
||||
public IoStream ExecAsIoStreamOrNull() {
|
||||
try {return IoEnginePool._.Get_by(url.Info().EngineKey()).OpenStreamRead(url);}
|
||||
try {return IoEnginePool.Instance.Get_by(url.Info().EngineKey()).OpenStreamRead(url);}
|
||||
catch (Exception exc) {
|
||||
errMsg = Err_.Message_lang(exc);
|
||||
return IoStream_.Null;
|
||||
|
@ -22,7 +22,7 @@ public class IoEngine_xrg_openWrite {
|
||||
public boolean MissingIgnored() {return missingIgnored;} public IoEngine_xrg_openWrite MissingIgnored_() {return MissingIgnored_(true);} public IoEngine_xrg_openWrite MissingIgnored_(boolean v) {missingIgnored = v; return this;} private boolean missingIgnored = false;
|
||||
public byte Mode() {return mode;} public IoEngine_xrg_openWrite Mode_(byte v) {mode = v; return this;} private byte mode = IoStream_.Mode_wtr_create;
|
||||
public IoEngine_xrg_openWrite Mode_update_() {return Mode_(IoStream_.Mode_wtr_update);}
|
||||
public IoStream Exec() {return IoEnginePool._.Get_by(url.Info().EngineKey()).OpenStreamWrite(this);}
|
||||
public IoStream Exec() {return IoEnginePool.Instance.Get_by(url.Info().EngineKey()).OpenStreamWrite(this);}
|
||||
public static IoEngine_xrg_openWrite new_(Io_url url) {
|
||||
IoEngine_xrg_openWrite rv = new IoEngine_xrg_openWrite();
|
||||
rv.url = url;
|
||||
|
@ -36,12 +36,12 @@ public class IoEngine_xrg_queryDir {
|
||||
filCrt = Criteria_fld.new_(IoItm_base_.Prop_Path, crt);
|
||||
return this;
|
||||
}
|
||||
public IoItmDir ExecAsDir() {return IoEnginePool._.Get_by(url.Info().EngineKey()).QueryDirDeep(this);}
|
||||
public IoItmDir ExecAsDir() {return IoEnginePool.Instance.Get_by(url.Info().EngineKey()).QueryDirDeep(this);}
|
||||
public Io_url[] ExecAsUrlAry() {return ExecAsItmHash().XtoIoUrlAry();}
|
||||
public IoItmHash ExecAsItmHash() {
|
||||
Criteria crt = dirInclude ? Criteria_.All : Criteria_fld.new_(IoItm_base_.Prop_Type, Criteria_.eq_(IoItmFil.Type_Fil));
|
||||
IoItmHash list = ExecAsDir().XtoIoItmList(crt);
|
||||
list.Sort_by(IoItmBase_comparer_nest._);
|
||||
list.Sort_by(IoItmBase_comparer_nest.Instance);
|
||||
return list;
|
||||
}
|
||||
public static IoEngine_xrg_queryDir new_(Io_url url) {
|
||||
|
@ -44,7 +44,7 @@ public class IoEngine_xrg_recycleFil extends IoEngine_xrg_fil_affects1_base {
|
||||
return sb.To_str();
|
||||
}
|
||||
@Override public void Exec() {
|
||||
IoEnginePool._.Get_by(this.Url().Info().EngineKey()).RecycleFil(this);
|
||||
IoEnginePool.Instance.Get_by(this.Url().Info().EngineKey()).RecycleFil(this);
|
||||
}
|
||||
public IoEngine_xrg_recycleFil(int v) {
|
||||
mode = v;
|
||||
|
@ -23,7 +23,7 @@ public class IoEngine_xrg_saveFilStr {
|
||||
public boolean Append() {return append;} public IoEngine_xrg_saveFilStr Append_() {return Append_(true);} public IoEngine_xrg_saveFilStr Append_(boolean val) {append = val; return this;} private boolean append = false;
|
||||
public void Exec() {
|
||||
if (String_.Eq(text, "") && append) return; // no change; don't bother writing to disc
|
||||
IoEnginePool._.Get_by(url.Info().EngineKey()).SaveFilText_api(this);
|
||||
IoEnginePool.Instance.Get_by(url.Info().EngineKey()).SaveFilText_api(this);
|
||||
}
|
||||
public static IoEngine_xrg_saveFilStr new_(Io_url url, String text) {
|
||||
IoEngine_xrg_saveFilStr rv = new IoEngine_xrg_saveFilStr();
|
||||
|
@ -26,7 +26,7 @@ public class IoEngine_xrg_xferDir {
|
||||
public boolean ReadOnlyFails() {return readOnlyFails;} public IoEngine_xrg_xferDir ReadOnlyFails_() {return ReadOnlyFails_(true);} public IoEngine_xrg_xferDir ReadOnlyFails_(boolean v) {readOnlyFails = v; return this;} private boolean readOnlyFails = false;
|
||||
public Criteria MatchCrt() {return matchCrt;} public IoEngine_xrg_xferDir MatchCrt_(Criteria v) {matchCrt = v; return this;} Criteria matchCrt = Criteria_.All;
|
||||
public Criteria SubDirScanCrt() {return subDirScanCrt;} public IoEngine_xrg_xferDir SubDirScanCrt_(Criteria v) {subDirScanCrt = v; return this;} Criteria subDirScanCrt = Criteria_.All;
|
||||
public void Exec() {IoEnginePool._.Get_by(src.Info().EngineKey()).XferDir(this);}
|
||||
public void Exec() {IoEnginePool.Instance.Get_by(src.Info().EngineKey()).XferDir(this);}
|
||||
public static IoEngine_xrg_xferDir move_(Io_url src, Io_url trg) {return new_(src, trg, true);}
|
||||
public static IoEngine_xrg_xferDir copy_(Io_url src, Io_url trg) {return new_(src, trg, false);}
|
||||
static IoEngine_xrg_xferDir new_(Io_url src, Io_url trg, boolean move) {
|
||||
|
@ -23,7 +23,7 @@ public class IoEngine_xrg_xferFil {
|
||||
public boolean Overwrite() {return overwrite;} public IoEngine_xrg_xferFil Overwrite_() {return Overwrite_(true);} public IoEngine_xrg_xferFil Overwrite_(boolean v) {overwrite = v; return this;} private boolean overwrite = false;
|
||||
public boolean ReadOnlyFails() {return readOnlyFails;} public IoEngine_xrg_xferFil ReadOnlyFails_off() {return ReadOnlyFails_(false);} public IoEngine_xrg_xferFil ReadOnlyFails_(boolean v) {readOnlyFails = v; return this;} private boolean readOnlyFails = true;
|
||||
public boolean MissingFails() {return missingFails;} public IoEngine_xrg_xferFil MissingFails_off() {return MissingFails_(false);} public IoEngine_xrg_xferFil MissingFails_(boolean v) {missingFails = v; return this;} private boolean missingFails = true;
|
||||
public void Exec() {IoEnginePool._.Get_by(src.Info().EngineKey()).XferFil(this);}
|
||||
public void Exec() {IoEnginePool.Instance.Get_by(src.Info().EngineKey()).XferFil(this);}
|
||||
public static IoEngine_xrg_xferFil move_(Io_url src, Io_url trg) {return new_(src, trg, true);}
|
||||
public static IoEngine_xrg_xferFil copy_(Io_url src, Io_url trg) {return new_(src, trg, false);}
|
||||
static IoEngine_xrg_xferFil new_(Io_url src, Io_url trg, boolean move) {
|
||||
|
@ -28,5 +28,5 @@ public class IoItmClassXtn extends ClassXtn_base implements ClassXtn {
|
||||
else throw Err_.new_unhandled(raw);
|
||||
}
|
||||
@Override public Object XtoDb(Object obj) {return Int_.cast(obj);}
|
||||
public static final IoItmClassXtn _ = new IoItmClassXtn(); IoItmClassXtn() {}
|
||||
public static final IoItmClassXtn Instance = new IoItmClassXtn(); IoItmClassXtn() {}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class IoItmDir_ {
|
||||
return rv;
|
||||
}
|
||||
public static void Make(IoItmDir dir) {
|
||||
Io_mgr.I.CreateDir(dir.Url());
|
||||
Io_mgr.Instance.CreateDir(dir.Url());
|
||||
int len = dir.SubDirs().Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
IoItmDir sub_dir = (IoItmDir)dir.SubDirs().Get_at(i);
|
||||
@ -48,8 +48,8 @@ public class IoItmDir_ {
|
||||
IoItmFil sub_fil = (IoItmFil)dir.SubFils().Get_at(i);
|
||||
String text = String_.Repeat("a", (int)sub_fil.Size());
|
||||
Io_url sub_url = sub_fil.Url();
|
||||
Io_mgr.I.SaveFilStr(sub_url, text);
|
||||
Io_mgr.I.UpdateFilModifiedTime(sub_url, sub_fil.ModifiedTime());
|
||||
Io_mgr.Instance.SaveFilStr(sub_url, text);
|
||||
Io_mgr.Instance.UpdateFilModifiedTime(sub_url, sub_fil.ModifiedTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class IoItmList extends Ordered_hash_base {
|
||||
rv[i] = IoItm_base_.as_(i).Url();
|
||||
return rv;
|
||||
}
|
||||
@Override public void Sort() {Sort_by(IoItmBase_comparer_nest._);}
|
||||
@Override public void Sort() {Sort_by(IoItmBase_comparer_nest.Instance);}
|
||||
@Override protected Object Fetch_base(Object keyObj) {
|
||||
String key = MakeKey((String)keyObj);
|
||||
return super.Fetch_base(key);
|
||||
@ -72,5 +72,5 @@ class IoItmBase_comparer_nest implements ComparerAble {
|
||||
Io_url url = itm.Url();
|
||||
return String_.Count(url.OwnerDir().Raw(), url.Info().DirSpr()); // use OwnerDir, else dir.Raw will return extra dirSeparator
|
||||
}
|
||||
public static final IoItmBase_comparer_nest _ = new IoItmBase_comparer_nest(); IoItmBase_comparer_nest() {}
|
||||
public static final IoItmBase_comparer_nest Instance = new IoItmBase_comparer_nest(); IoItmBase_comparer_nest() {}
|
||||
}
|
||||
|
@ -56,5 +56,5 @@ public class IoRecycleBin {
|
||||
String sourceApp = String_.GetStrBefore(url.NameAndExt_noDirSpr(), ";");
|
||||
return url.OwnerDir().GenSubFil_ary(sourceApp, ".recycle.csv");
|
||||
}
|
||||
public static final IoRecycleBin _ = new IoRecycleBin(); IoRecycleBin() {}
|
||||
public static final IoRecycleBin Instance = new IoRecycleBin(); IoRecycleBin() {}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class IoUrlInfo_nil implements IoUrlInfo {
|
||||
public String NameOnly(String raw) {return "";}
|
||||
public String Ext(String raw) {return "";}
|
||||
public String XtoRootName(String raw, int rawLen) {return "";}
|
||||
public static final IoUrlInfo_nil _ = new IoUrlInfo_nil(); IoUrlInfo_nil() {}
|
||||
public static final IoUrlInfo_nil Instance = new IoUrlInfo_nil(); IoUrlInfo_nil() {}
|
||||
}
|
||||
abstract class IoUrlInfo_base implements IoUrlInfo {
|
||||
@gplx.Internal protected static final int DirSprLen = 1;
|
||||
@ -134,7 +134,7 @@ class IoUrlInfo_wnt extends IoUrlInfo_base {
|
||||
? Char_.To_str(String_.CharAt(raw, 0))
|
||||
: null;
|
||||
}
|
||||
public static final IoUrlInfo_wnt _ = new IoUrlInfo_wnt(); IoUrlInfo_wnt() {}
|
||||
public static final IoUrlInfo_wnt Instance = new IoUrlInfo_wnt(); IoUrlInfo_wnt() {}
|
||||
}
|
||||
class IoUrlInfo_lnx extends IoUrlInfo_base {
|
||||
@Override public String Key() {return "lnx";}
|
||||
@ -154,7 +154,7 @@ class IoUrlInfo_lnx extends IoUrlInfo_base {
|
||||
? DirSprStr
|
||||
: super.Xto_api(raw); // NOTE: super.Xto_api will strip off last /
|
||||
}
|
||||
public static final IoUrlInfo_lnx _ = new IoUrlInfo_lnx(); IoUrlInfo_lnx() {}
|
||||
public static final IoUrlInfo_lnx Instance = new IoUrlInfo_lnx(); IoUrlInfo_lnx() {}
|
||||
}
|
||||
class IoUrlInfo_rel extends IoUrlInfo_base {
|
||||
@Override public String Key() {return "rel";}
|
||||
|
@ -28,10 +28,10 @@ public class IoUrlInfoRegy implements GfoInvkAble {
|
||||
}
|
||||
public void Reset() {
|
||||
hash.Clear();
|
||||
Reg(IoUrlInfo_rel.new_(Op_sys.Cur().Tid_is_wnt() ? (IoUrlInfo)IoUrlInfo_wnt._ : (IoUrlInfo)IoUrlInfo_lnx._));
|
||||
Reg(IoUrlInfo_rel.new_(Op_sys.Cur().Tid_is_wnt() ? (IoUrlInfo)IoUrlInfo_wnt.Instance : (IoUrlInfo)IoUrlInfo_lnx.Instance));
|
||||
Reg(IoUrlInfo_.Mem);
|
||||
Reg(IoUrlInfo_lnx._);
|
||||
Reg(IoUrlInfo_wnt._);
|
||||
Reg(IoUrlInfo_lnx.Instance);
|
||||
Reg(IoUrlInfo_wnt.Instance);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_Add)) {
|
||||
@ -40,12 +40,12 @@ public class IoUrlInfoRegy implements GfoInvkAble {
|
||||
String engineKey = m.ReadStrOr("engineKey", IoEngine_.SysKey);
|
||||
if (ctx.Deny()) return this;
|
||||
IoUrlInfo_alias alias = IoUrlInfo_alias.new_(srcDirStr, trgDirStr, engineKey);
|
||||
IoUrlInfoRegy._.Reg(alias);
|
||||
IoUrlInfoRegy.Instance.Reg(alias);
|
||||
}
|
||||
return this;
|
||||
} public static final String Invk_Add = "Add";
|
||||
Ordered_hash hash = Ordered_hash_.new_();
|
||||
public static final IoUrlInfoRegy _ = new IoUrlInfoRegy();
|
||||
Ordered_hash hash = Ordered_hash_.New();
|
||||
public static final IoUrlInfoRegy Instance = new IoUrlInfoRegy();
|
||||
IoUrlInfoRegy() {
|
||||
this.Reset();
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
public class IoUrlInfo_ {
|
||||
public static final IoUrlInfo Nil = IoUrlInfo_nil._;
|
||||
public static final IoUrlInfo Wnt = IoUrlInfo_wnt._;
|
||||
public static final IoUrlInfo Lnx = IoUrlInfo_lnx._;
|
||||
public static final IoUrlInfo Nil = IoUrlInfo_nil.Instance;
|
||||
public static final IoUrlInfo Wnt = IoUrlInfo_wnt.Instance;
|
||||
public static final IoUrlInfo Lnx = IoUrlInfo_lnx.Instance;
|
||||
public static final IoUrlInfo Mem = IoUrlInfo_mem.new_("mem", IoEngine_.MemKey);
|
||||
|
||||
public static IoUrlInfo mem_(String key, String engineKey) {return IoUrlInfo_mem.new_(key, engineKey);}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user