mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
v2.8.5.1
This commit is contained in:
parent
ed911e3de5
commit
5fc4eb41ec
@ -3,8 +3,10 @@
|
|||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="src" path="src_000_err"/>
|
<classpathentry kind="src" path="src_000_err"/>
|
||||||
<classpathentry kind="src" path="src_100_interface"/>
|
<classpathentry kind="src" path="src_100_interface"/>
|
||||||
<classpathentry kind="src" path="src_110_primitive"/>
|
<classpathentry kind="src" path="src_100_types_primitive"/>
|
||||||
|
<classpathentry kind="src" path="src_101_types_object"/>
|
||||||
<classpathentry kind="src" path="src_120_basicDataType"/>
|
<classpathentry kind="src" path="src_120_basicDataType"/>
|
||||||
|
<classpathentry kind="src" path="src_130_brys"/>
|
||||||
<classpathentry kind="src" path="src_140_list"/>
|
<classpathentry kind="src" path="src_140_list"/>
|
||||||
<classpathentry kind="src" path="src_150_text"/>
|
<classpathentry kind="src" path="src_150_text"/>
|
||||||
<classpathentry kind="src" path="src_160_hash"/>
|
<classpathentry kind="src" path="src_160_hash"/>
|
||||||
|
@ -27,7 +27,7 @@ public class Bry_rdr {
|
|||||||
public void Pos_add(int v) {pos += v;}
|
public void Pos_add(int v) {pos += v;}
|
||||||
public boolean Pos_is_eos() {return pos == src_len;}
|
public boolean Pos_is_eos() {return pos == src_len;}
|
||||||
public void Pos_add_one() {++pos;}
|
public void Pos_add_one() {++pos;}
|
||||||
public int Or_int() {return or_int;} public void Or_int_(int v) {or_int = v;} private int or_int = Int_.MinValue;
|
public int Or_int() {return or_int;} public void Or_int_(int v) {or_int = v;} private int or_int = Int_.Min_value;
|
||||||
public byte[] Or_bry() {return or_bry;} public void Or_bry_(byte[] v) {or_bry = v;} private byte[] or_bry;
|
public byte[] Or_bry() {return or_bry;} public void Or_bry_(byte[] v) {or_bry = v;} private byte[] or_bry;
|
||||||
public int Find_fwd(byte find) {return Bry_finder.Find_fwd(src, find, pos);}
|
public int Find_fwd(byte find) {return Bry_finder.Find_fwd(src, find, pos);}
|
||||||
public int Find_fwd_ws() {return Bry_finder.Find_fwd_until_ws(src, pos, src_len);}
|
public int Find_fwd_ws() {return Bry_finder.Find_fwd_until_ws(src, pos, src_len);}
|
||||||
@ -99,7 +99,7 @@ public class Bry_rdr {
|
|||||||
public double Read_double_to_pipe() {return Read_double_to(Byte_ascii.Pipe);}
|
public double Read_double_to_pipe() {return Read_double_to(Byte_ascii.Pipe);}
|
||||||
public double Read_double_to(byte to_char) {
|
public double Read_double_to(byte to_char) {
|
||||||
byte[] double_bry = Read_bry_to(to_char);
|
byte[] double_bry = Read_bry_to(to_char);
|
||||||
return Double_.parse_(String_.new_a7(double_bry)); // double will never have utf8
|
return Double_.parse(String_.new_a7(double_bry)); // double will never have utf8
|
||||||
}
|
}
|
||||||
@gplx.Virtual public Bry_rdr Skip_ws() {
|
@gplx.Virtual public Bry_rdr Skip_ws() {
|
||||||
while (pos < src_len) {
|
while (pos < src_len) {
|
||||||
|
@ -41,6 +41,7 @@ public class Btrie_slim_mgr implements Btrie_mgr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public Btrie_slim_mgr Add_bry_tid(byte[] bry, byte tid) {return (Btrie_slim_mgr)Add_obj(bry, Byte_obj_val.new_(tid));}
|
public Btrie_slim_mgr Add_bry_tid(byte[] bry, byte tid) {return (Btrie_slim_mgr)Add_obj(bry, Byte_obj_val.new_(tid));}
|
||||||
|
public Btrie_slim_mgr Add_bry_int(byte[] key, int val) {return (Btrie_slim_mgr)Add_obj(key, Int_obj_val.new_(val));}
|
||||||
public Btrie_slim_mgr Add_str_byte(String key, byte val) {return (Btrie_slim_mgr)Add_obj(Bry_.new_u8(key), Byte_obj_val.new_(val));}
|
public Btrie_slim_mgr Add_str_byte(String key, byte val) {return (Btrie_slim_mgr)Add_obj(Bry_.new_u8(key), Byte_obj_val.new_(val));}
|
||||||
public Btrie_slim_mgr Add_str_int(String key, int val) {return (Btrie_slim_mgr)Add_obj(Bry_.new_u8(key), Int_obj_val.new_(val));}
|
public Btrie_slim_mgr Add_str_int(String key, int val) {return (Btrie_slim_mgr)Add_obj(Bry_.new_u8(key), Int_obj_val.new_(val));}
|
||||||
public Btrie_slim_mgr Add_bry(String key, String val) {return (Btrie_slim_mgr)Add_obj(Bry_.new_u8(key), Bry_.new_u8(val));}
|
public Btrie_slim_mgr Add_bry(String key, String val) {return (Btrie_slim_mgr)Add_obj(Bry_.new_u8(key), Bry_.new_u8(val));}
|
||||||
@ -55,11 +56,12 @@ public class Btrie_slim_mgr implements Btrie_mgr {
|
|||||||
Add_obj(Bry_.new_u8(ary[i]), bval);
|
Add_obj(Bry_.new_u8(ary[i]), bval);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Btrie_slim_mgr Add_many_int(int val, String... ary) {
|
public Btrie_slim_mgr Add_many_int(int val, String... ary) {return Add_many_int(val, Bry_.Ary(ary));}
|
||||||
|
public Btrie_slim_mgr Add_many_int(int val, byte[]... ary) {
|
||||||
int len = ary.length;
|
int len = ary.length;
|
||||||
Int_obj_val obj = Int_obj_val.new_(val);
|
Int_obj_val obj = Int_obj_val.new_(val);
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
Add_obj(Bry_.new_u8(ary[i]), obj);
|
Add_obj(ary[i], obj);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Btrie_slim_mgr Add_stub(String key, byte val) {byte[] bry = Bry_.new_u8(key); return (Btrie_slim_mgr)Add_obj(bry, new Btrie_itm_stub(val, bry));}
|
public Btrie_slim_mgr Add_stub(String key, byte val) {byte[] bry = Bry_.new_u8(key); return (Btrie_slim_mgr)Add_obj(bry, new Btrie_itm_stub(val, bry));}
|
||||||
|
@ -47,7 +47,7 @@ public class Criteria_ {
|
|||||||
public static Criteria mte_(Comparable val) {return new Criteria_comp(CompareAble_.MoreOrSame, val);}
|
public static Criteria mte_(Comparable val) {return new Criteria_comp(CompareAble_.MoreOrSame, val);}
|
||||||
public static Criteria between_(Comparable lhs, Comparable rhs) {return new Criteria_between(false, lhs, rhs);}
|
public static Criteria between_(Comparable lhs, Comparable rhs) {return new Criteria_between(false, lhs, rhs);}
|
||||||
public static Criteria between_(boolean negated, Comparable lhs, Comparable rhs) {return new Criteria_between(negated, lhs, rhs);}
|
public static Criteria between_(boolean negated, Comparable lhs, Comparable rhs) {return new Criteria_between(negated, lhs, rhs);}
|
||||||
public static Criteria like_(String pattern) {return new Criteria_like(false, RegxPatn_cls_like_.parse_(pattern, RegxPatn_cls_like.EscapeDefault));}
|
public static Criteria like_(String pattern) {return new Criteria_like(false, RegxPatn_cls_like_.parse(pattern, RegxPatn_cls_like.EscapeDefault));}
|
||||||
public static Criteria liken_(String pattern) {return new Criteria_like(true, RegxPatn_cls_like_.parse_(pattern, RegxPatn_cls_like.EscapeDefault));}
|
public static Criteria liken_(String pattern) {return new Criteria_like(true, RegxPatn_cls_like_.parse(pattern, RegxPatn_cls_like.EscapeDefault));}
|
||||||
public static final byte Tid_custom = 0, Tid_const = 1, Tid_not = 2, Tid_and = 3, Tid_or = 4, Tid_eq = 5, Tid_between = 6, Tid_in = 7, Tid_like = 8, Tid_comp = 9, Tid_wrapper = 10, Tid_iomatch = 11, Tid_db_obj_ary = 12;
|
public static final byte Tid_custom = 0, Tid_const = 1, Tid_not = 2, Tid_and = 3, Tid_or = 4, Tid_eq = 5, Tid_between = 6, Tid_in = 7, Tid_like = 8, Tid_comp = 9, Tid_wrapper = 10, Tid_iomatch = 11, Tid_db_obj_ary = 12;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ class Criteria_const implements Criteria {
|
|||||||
public boolean Matches(Object comp) {return val;} private final boolean val;
|
public boolean Matches(Object comp) {return val;} private final boolean val;
|
||||||
public void Val_from_args(Hash_adp args) {;}
|
public void Val_from_args(Hash_adp args) {;}
|
||||||
public void Val_as_obj_(Object v) {throw Err_.new_unimplemented();}
|
public void Val_as_obj_(Object v) {throw Err_.new_unimplemented();}
|
||||||
public String To_str() {return String_.Concat(" IS ", Bool_.Xto_str_lower(val));}
|
public String To_str() {return String_.Concat(" IS ", Bool_.To_str_lower(val));}
|
||||||
}
|
}
|
||||||
class Criteria_not implements Criteria {
|
class Criteria_not implements Criteria {
|
||||||
private final Criteria criteria;
|
private final Criteria criteria;
|
||||||
|
@ -37,7 +37,7 @@ public class Criteria_ioItm_tst {
|
|||||||
tst_Match(false, crt, fil.ModifiedTime_(DateAdp_.parse_gplx("2000-12-31")));
|
tst_Match(false, crt, fil.ModifiedTime_(DateAdp_.parse_gplx("2000-12-31")));
|
||||||
}
|
}
|
||||||
@Test public void IoMatch() {
|
@Test public void IoMatch() {
|
||||||
Criteria crt = Criteria_ioMatch.parse_(true, "*.txt", false);
|
Criteria crt = Criteria_ioMatch.parse(true, "*.txt", false);
|
||||||
CriteriaFxt fx_crt = new CriteriaFxt();
|
CriteriaFxt fx_crt = new CriteriaFxt();
|
||||||
fx_crt.tst_Matches(crt, Io_url_.new_any_("file.txt"));
|
fx_crt.tst_Matches(crt, Io_url_.new_any_("file.txt"));
|
||||||
fx_crt.tst_MatchesNot(crt, Io_url_.new_any_("file.xml"));
|
fx_crt.tst_MatchesNot(crt, Io_url_.new_any_("file.xml"));
|
||||||
|
@ -33,5 +33,5 @@ public class Criteria_ioMatch implements Criteria { // EX: url IOMATCH '*.xml|*.
|
|||||||
|
|
||||||
public static final String TokenName = "IOMATCH";
|
public static final String TokenName = "IOMATCH";
|
||||||
public static Criteria_ioMatch as_(Object obj) {return obj instanceof Criteria_ioMatch ? (Criteria_ioMatch)obj : null;}
|
public static Criteria_ioMatch as_(Object obj) {return obj instanceof Criteria_ioMatch ? (Criteria_ioMatch)obj : null;}
|
||||||
public static Criteria_ioMatch parse_(boolean match, String raw, boolean caseSensitive) {return new Criteria_ioMatch(match, RegxPatn_cls_ioMatch_.parse_(raw, caseSensitive));}
|
public static Criteria_ioMatch parse(boolean match, String raw, boolean caseSensitive) {return new Criteria_ioMatch(match, RegxPatn_cls_ioMatch_.parse(raw, caseSensitive));}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public class Bool_obj_ref {
|
|||||||
public Bool_obj_ref Val_n_() {val = false; return this;}
|
public Bool_obj_ref Val_n_() {val = false; return this;}
|
||||||
public Bool_obj_ref Val_(boolean v) {val = v; return this;}
|
public Bool_obj_ref Val_(boolean v) {val = v; return this;}
|
||||||
public Bool_obj_ref Val_toggle_() {val = !val; return this;}
|
public Bool_obj_ref Val_toggle_() {val = !val; return this;}
|
||||||
@Override public String toString() {return Bool_.Xto_str_lower(val);}
|
@Override public String toString() {return Bool_.To_str_lower(val);}
|
||||||
public static Bool_obj_ref n_() {return new_(false);}
|
public static Bool_obj_ref n_() {return new_(false);}
|
||||||
public static Bool_obj_ref y_() {return new_(true);}
|
public static Bool_obj_ref y_() {return new_(true);}
|
||||||
public static Bool_obj_ref new_(boolean val) {
|
public static Bool_obj_ref new_(boolean val) {
|
||||||
|
@ -24,8 +24,8 @@ public class Bool_obj_val {
|
|||||||
, False = new Bool_obj_val(0)
|
, False = new Bool_obj_val(0)
|
||||||
, True = new Bool_obj_val(1)
|
, True = new Bool_obj_val(1)
|
||||||
;
|
;
|
||||||
public static Bool_obj_val read_(Object o) {String s = String_.as_(o); return s == null ? (Bool_obj_val)o : parse_(s);}
|
public static Bool_obj_val read_(Object o) {String s = String_.as_(o); return s == null ? (Bool_obj_val)o : parse(s);}
|
||||||
public static Bool_obj_val parse_(String raw) {
|
public static Bool_obj_val parse(String raw) {
|
||||||
if (String_.Eq(raw, "y")) return Bool_obj_val.True;
|
if (String_.Eq(raw, "y")) return Bool_obj_val.True;
|
||||||
else if (String_.Eq(raw, "n")) return Bool_obj_val.False;
|
else if (String_.Eq(raw, "n")) return Bool_obj_val.False;
|
||||||
else if (String_.Eq(raw, "")) return Bool_obj_val.Null;
|
else if (String_.Eq(raw, "")) return Bool_obj_val.Null;
|
||||||
|
@ -60,7 +60,7 @@ public class Regx_adp__tst implements TfdsEqListItmStr {
|
|||||||
rv[i] = match_(bgnAry[i]);
|
rv[i] = match_(bgnAry[i]);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
Regx_match match_(int bgn) {return match_(bgn, Int_.MinValue);}
|
Regx_match match_(int bgn) {return match_(bgn, Int_.Min_value);}
|
||||||
Regx_match match_(int bgn, int len) {return new Regx_match(true, bgn, bgn + len, Regx_group.Ary_empty);}
|
Regx_match match_(int bgn, int len) {return new Regx_match(true, bgn, bgn + len, Regx_group.Ary_empty);}
|
||||||
void tst_Matches(String find, String input, Regx_match... expd) {
|
void tst_Matches(String find, String input, Regx_match... expd) {
|
||||||
List_adp expdList = Array_.XtoList(expd);
|
List_adp expdList = Array_.XtoList(expd);
|
||||||
@ -87,7 +87,7 @@ public class Regx_adp__tst implements TfdsEqListItmStr {
|
|||||||
public String To_str(Object curObj, Object expdObj) {
|
public String To_str(Object curObj, Object expdObj) {
|
||||||
Regx_match cur = (Regx_match)curObj, expd = (Regx_match)expdObj;
|
Regx_match cur = (Regx_match)curObj, expd = (Regx_match)expdObj;
|
||||||
String rv = "bgn=" + cur.Find_bgn();
|
String rv = "bgn=" + cur.Find_bgn();
|
||||||
if (expd != null && expd.Find_len() != Int_.MinValue) rv += " len=" + cur.Find_len();
|
if (expd != null && expd.Find_len() != Int_.Min_value) rv += " len=" + cur.Find_len();
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
package gplx;
|
package gplx;
|
||||||
public class Gfo_msg_itm_ {
|
public class Gfo_msg_itm_ {
|
||||||
public static final byte Cmd_null = 0, Cmd_log = 1, Cmd_note = 2, Cmd_warn = 3, Cmd_stop = 4, Cmd_fail = 5;
|
public static final byte Cmd_null = 0, Cmd_log = 1, Cmd_note = 2, Cmd_warn = 3, Cmd_stop = 4, Cmd_fail = 5;
|
||||||
public static final byte[][] CmdBry = new byte[][] {Bry_.new_a7("null"), Bry_.new_a7("log"), Bry_.new_a7("note"), Bry_.new_a7("warn"), Bry_.new_a7("stop"), Bry_.new_a7("fail")};
|
public static final byte[][] CmdBry = new byte[][] {Object_.Bry__null, Bry_.new_a7("log"), Bry_.new_a7("note"), Bry_.new_a7("warn"), Bry_.new_a7("stop"), Bry_.new_a7("fail")};
|
||||||
public static Gfo_msg_itm new_note_(Gfo_msg_grp owner, String key) {return new_(owner, Cmd_note, key, key);}
|
public static Gfo_msg_itm new_note_(Gfo_msg_grp owner, String key) {return new_(owner, Cmd_note, key, key);}
|
||||||
public static Gfo_msg_itm new_fail_(Gfo_msg_grp owner, String key, String fmt) {return new_(owner, Cmd_warn, key, fmt);}
|
public static Gfo_msg_itm new_fail_(Gfo_msg_grp owner, String key, String fmt) {return new_(owner, Cmd_warn, key, fmt);}
|
||||||
public static Gfo_msg_itm new_warn_(Gfo_msg_grp owner, String key) {return new_(owner, Cmd_warn, key, key);}
|
public static Gfo_msg_itm new_warn_(Gfo_msg_grp owner, String key) {return new_(owner, Cmd_warn, key, key);}
|
||||||
|
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
package gplx;
|
package gplx;
|
||||||
public class RlsAble_ {
|
public class RlsAble_ {
|
||||||
public static RlsAble as_(Object obj) {return obj instanceof RlsAble ? (RlsAble)obj : null;}
|
public static RlsAble as_(Object obj) {return obj instanceof RlsAble ? (RlsAble)obj : null;}
|
||||||
public static RlsAble cast_(Object obj) {try {return (RlsAble)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, RlsAble.class, obj);}}
|
public static RlsAble cast(Object obj) {try {return (RlsAble)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, RlsAble.class, obj);}}
|
||||||
public static final RlsAble Null = new RlsAble__noop();
|
public static final RlsAble Null = new RlsAble__noop();
|
||||||
}
|
}
|
||||||
class RlsAble__noop implements RlsAble {
|
class RlsAble__noop implements RlsAble {
|
||||||
|
@ -22,28 +22,28 @@ public class Bool_ implements GfoInvkAble {
|
|||||||
public static final boolean N = false , Y = true;
|
public static final boolean N = false , Y = true;
|
||||||
public static final byte N_byte = 0 , Y_byte = 1 , __byte = 127;
|
public static final byte N_byte = 0 , Y_byte = 1 , __byte = 127;
|
||||||
public static final int N_int = 0 , Y_int = 1 , __int = -1;
|
public static final int N_int = 0 , Y_int = 1 , __int = -1;
|
||||||
public static final String N_str = "n" , Y_str = "y";
|
public static final byte[] N_bry = new byte[] {Byte_ascii.Ltr_n}, Y_bry = new byte[] {Byte_ascii.Ltr_y};
|
||||||
public static final byte[] Y_bry = new byte[] {Byte_ascii.Ltr_y}, N_bry = new byte[] {Byte_ascii.Ltr_n};
|
|
||||||
public static final String True_str = "true", False_str = "false";
|
public static final String True_str = "true", False_str = "false";
|
||||||
public static final byte[] True_bry = Bry_.new_a7(True_str), False_bry = Bry_.new_a7(False_str);
|
public static final byte[] True_bry = Bry_.new_a7(True_str), False_bry = Bry_.new_a7(False_str);
|
||||||
public static boolean cast_(Object obj) {try {return (Boolean)obj;} catch (Exception e) {throw Err_.new_type_mismatch_w_exc(e, boolean.class, obj);}}
|
public static boolean cast(Object obj) {try {return (Boolean)obj;} catch (Exception e) {throw Err_.new_type_mismatch_w_exc(e, boolean.class, obj);}}
|
||||||
public static boolean cast_or_(Object obj, boolean v) {try {return (Boolean)obj;} catch (Exception e) {Err_.Noop(e); return v;}}
|
public static boolean cast_or(Object obj, boolean v) {try {return (Boolean)obj;} catch (Exception e) {Err_.Noop(e); return v;}}
|
||||||
public static boolean By_int(int v) {return v != 0;}
|
public static boolean parse(String raw) {
|
||||||
public static boolean parse_(String raw) {
|
if ( String_.Eq(raw, True_str)
|
||||||
if ( String_.Eq(raw, "true")
|
|
||||||
|| String_.Eq(raw, "True") // needed for Store_Wtr(){boolVal.toString();}
|
|| String_.Eq(raw, "True") // needed for Store_Wtr(){boolVal.toString();}
|
||||||
)
|
)
|
||||||
return true;
|
return true;
|
||||||
else if ( String_.Eq(raw, "false")
|
else if ( String_.Eq(raw, "false")
|
||||||
|| String_.Eq(raw, "False")
|
|| String_.Eq(raw, False_str)
|
||||||
)
|
)
|
||||||
return false;
|
return false;
|
||||||
throw Err_.new_parse_type(boolean.class, raw);
|
throw Err_.new_parse_type(boolean.class, raw);
|
||||||
}
|
}
|
||||||
public static byte Xto_byte(boolean v) {return v ? Y_byte : N_byte;}
|
public static boolean By_int(int v) {return v == Y_int;}
|
||||||
public static int Xto_int(boolean v) {return v ? 1 : 0;}
|
public static int To_int(boolean v) {return v ? Y_int : N_int;}
|
||||||
public static String Xto_str_lower(boolean v) {return v ? "true" : "false";}
|
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 boolean[] Ary_empty = new boolean[0];
|
||||||
|
|
||||||
public static final Bool_ Gfs = new Bool_();
|
public static final Bool_ Gfs = new Bool_();
|
||||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||||
if (ctx.Match(k, Invk_to_str)) {
|
if (ctx.Match(k, Invk_to_str)) {
|
@ -24,13 +24,12 @@ public class Byte_ {
|
|||||||
, Min_value = Byte.MIN_VALUE
|
, Min_value = Byte.MIN_VALUE
|
||||||
, Max_value_127 = 127
|
, Max_value_127 = 127
|
||||||
;
|
;
|
||||||
public static byte cast_(Object o) {try {return (Byte)o;} catch (Exception e) {throw Err_.new_type_mismatch_w_exc(e, byte.class, o);}}
|
public static byte cast(Object o) {try {return (Byte)o;} catch (Exception e) {throw Err_.new_type_mismatch_w_exc(e, byte.class, o);}}
|
||||||
public static byte parse_(String raw) {return Byte.parseByte(raw);}
|
public static byte parse(String raw) {return Byte.parseByte(raw);}
|
||||||
public static byte parse_or_(String raw, byte or) {
|
public static byte parse_or(String raw, byte or) {
|
||||||
if (raw == null) return or;
|
if (raw == null) return or;
|
||||||
try {
|
try {return parse(raw);}
|
||||||
return parse_(raw);
|
catch (Exception e) {Err_.Noop(e); return or;}
|
||||||
} catch (Exception e) {Err_.Noop(e); return or;}
|
|
||||||
}
|
}
|
||||||
public static byte By_int(int v) {return v > 127 ? (byte)(v - 256) : (byte)v;} // PERF?: (byte)(v & 0xff)
|
public static byte By_int(int v) {return v > 127 ? (byte)(v - 256) : (byte)v;} // PERF?: (byte)(v & 0xff)
|
||||||
public static int Xto_int(byte v) {return v < 0 ? (int)v + 256 : v;}
|
public static int Xto_int(byte v) {return v < 0 ? (int)v + 256 : v;}
|
@ -72,6 +72,6 @@ public class Char_ {
|
|||||||
public static String To_str(int b) {return To_str((char)b);}
|
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 String To_str(char c) {return String.valueOf(c);}
|
||||||
public static byte XtoByte(char c) {return (byte)c;}
|
public static byte XtoByte(char c) {return (byte)c;}
|
||||||
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 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);}}
|
public static char parse(String raw) {try {return raw.charAt(0);} catch(Exception exc) {throw Err_.new_parse_exc(exc, char.class, raw);}}
|
||||||
}
|
}
|
@ -29,11 +29,11 @@ public class Double_ {
|
|||||||
, Inf_pos_bry = Bry_.new_a7("INF")
|
, Inf_pos_bry = Bry_.new_a7("INF")
|
||||||
;
|
;
|
||||||
public static boolean IsNaN(double v) {return Double.isNaN(v);}
|
public static boolean IsNaN(double v) {return Double.isNaN(v);}
|
||||||
public static double cast_(Object o) {try {return (Double)o;} catch(Exception e) {throw Err_.new_type_mismatch_w_exc(e, double.class, o);}}
|
public static double cast(Object o) {try {return (Double)o;} catch(Exception e) {throw Err_.new_type_mismatch_w_exc(e, double.class, o);}}
|
||||||
public static double parse_(String raw) {try {return Double.parseDouble(raw);} catch(Exception e) {throw Err_.new_parse_exc(e, double.class, raw);}}
|
public static double parse(String raw) {try {return Double.parseDouble(raw);} catch(Exception e) {throw Err_.new_parse_exc(e, double.class, raw);}}
|
||||||
public static double parse_or(String raw, double v) {try {return Double.parseDouble(raw);} catch(Exception e) {Err_.Noop(e); return v;}}
|
public static double parse_or(String raw, double v) {try {return Double.parseDouble(raw);} catch(Exception e) {Err_.Noop(e); return v;}}
|
||||||
public static double coerce_(Object v) {
|
public static double coerce_(Object v) {
|
||||||
try {String s = String_.as_(v); return s == null ? Double_.cast_(v) : Double_.parse_(s);}
|
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);}
|
catch (Exception e) {throw Err_.new_cast(e, double.class, v);}
|
||||||
}
|
}
|
||||||
public static String Xto_str(double v) {
|
public static String Xto_str(double v) {
|
@ -21,8 +21,8 @@ public class Float_ {
|
|||||||
public static final Class<?> Cls_ref_type = Float.class;
|
public static final Class<?> Cls_ref_type = Float.class;
|
||||||
public static final float NaN = Float.NaN;;
|
public static final float NaN = Float.NaN;;
|
||||||
public static boolean IsNaN(float v) {return Float.isNaN(v);}
|
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 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 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 Xto_str(float v) {
|
||||||
int v_int = (int)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_.Xto_str(v_int) : Float.toString(v);
|
@ -23,9 +23,9 @@ public class Int_ implements GfoInvkAble {
|
|||||||
public static final int Base1 = 1;
|
public static final int Base1 = 1;
|
||||||
public static final int Const_dlm_len = 1;
|
public static final int Const_dlm_len = 1;
|
||||||
public static final int Const_position_after_char = 1;
|
public static final int Const_position_after_char = 1;
|
||||||
public static final int Null = Int_.MinValue;
|
public static final int Null = Int_.Min_value;
|
||||||
public static int coerce_(Object v) {
|
public static int coerce_(Object v) {
|
||||||
try {String s = String_.as_(v); return s == null ? Int_.cast_(v) : Int_.parse_(s);}
|
try {String s = String_.as_(v); return s == null ? Int_.cast(v) : Int_.parse(s);}
|
||||||
catch (Exception e) {throw Err_.new_cast(e, int.class, v);}
|
catch (Exception e) {throw Err_.new_cast(e, int.class, v);}
|
||||||
}
|
}
|
||||||
public static int[] Ary_empty = new int[0];
|
public static int[] Ary_empty = new int[0];
|
||||||
@ -50,13 +50,7 @@ public class Int_ implements GfoInvkAble {
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
public static boolean Bounds_chk(int bgn, int end, int len) {return bgn > -1 && end < len;}
|
public static boolean Bounds_chk(int bgn, int end, int len) {return bgn > -1 && end < len;}
|
||||||
public static final int
|
public static int parse_or(String raw, int or) {
|
||||||
MinValue = Integer.MIN_VALUE
|
|
||||||
, MaxValue = Integer.MAX_VALUE
|
|
||||||
, Neg1 = -1
|
|
||||||
, Neg1_count = -1
|
|
||||||
;
|
|
||||||
public static int parse_or_(String raw, int or) {
|
|
||||||
if (raw == null) return or;
|
if (raw == null) return or;
|
||||||
int rawLen = String_.Len(raw); if (rawLen == 0) return or;
|
int rawLen = String_.Len(raw); if (rawLen == 0) return or;
|
||||||
int rv = 0, tmp = 0, factor = 1;
|
int rv = 0, tmp = 0, factor = 1;
|
||||||
@ -115,11 +109,11 @@ public class Int_ implements GfoInvkAble {
|
|||||||
if (v == 0) return 0;
|
if (v == 0) return 0;
|
||||||
int sign = 1;
|
int sign = 1;
|
||||||
if (v < 0) {
|
if (v < 0) {
|
||||||
if (v == Int_.MinValue) return -9; // NOTE: Int_.MinValue * -1 = Int_.MinValue
|
if (v == Int_.Min_value) return -9; // NOTE: Int_.Min_value * -1 = Int_.Min_value
|
||||||
v *= -1;
|
v *= -1;
|
||||||
sign = -1;
|
sign = -1;
|
||||||
}
|
}
|
||||||
int rv = Log10AryLen - 2; // rv will only happen when v == Int_.MaxValue
|
int rv = Log10AryLen - 2; // rv will only happen when v == Int_.Max_value
|
||||||
int bgn = 0;
|
int bgn = 0;
|
||||||
if (v > 1000) { // optimization to reduce number of ops to < 5
|
if (v > 1000) { // optimization to reduce number of ops to < 5
|
||||||
bgn = 3;
|
bgn = 3;
|
||||||
@ -129,7 +123,7 @@ public class Int_ implements GfoInvkAble {
|
|||||||
if (v < Log10Ary[i]) {rv = i - 1; break;}
|
if (v < Log10Ary[i]) {rv = i - 1; break;}
|
||||||
}
|
}
|
||||||
return rv * sign;
|
return rv * sign;
|
||||||
} public static int[] Log10Ary = new int[] {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, Int_.MaxValue}; public static int Log10AryLen = 11;
|
} public static int[] Log10Ary = new int[] {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, Int_.Max_value}; public static int Log10AryLen = 11;
|
||||||
public Int_ FailIfNeg1(String key, int val) {
|
public Int_ FailIfNeg1(String key, int val) {
|
||||||
if (val < 0) throw Err_.new_wo_type("key must be >= 0", "key", key, "val", val);
|
if (val < 0) throw Err_.new_wo_type("key must be >= 0", "key", key, "val", val);
|
||||||
return this;
|
return this;
|
||||||
@ -154,10 +148,10 @@ public class Int_ implements GfoInvkAble {
|
|||||||
if (bgn) bfr.Add_int_fixed(val, len); // NOTE: neg handled above
|
if (bgn) bfr.Add_int_fixed(val, len); // NOTE: neg handled above
|
||||||
return bfr.Xto_str();
|
return bfr.Xto_str();
|
||||||
}
|
}
|
||||||
public static int read_(Object o) {String s = String_.as_(o); return s != null ? Int_.parse_(s) : Int_.cast_(o);}
|
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 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(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 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 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(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 Xto_str_fmt(int v, String fmt) {return new java.text.DecimalFormat(fmt).format(v);}
|
||||||
@ -254,8 +248,14 @@ public class Int_ implements GfoInvkAble {
|
|||||||
int len = ary.length;
|
int len = ary.length;
|
||||||
int[] rv = new int[len];
|
int[] rv = new int[len];
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
rv[i] = Int_.parse_(ary[i]);
|
rv[i] = Int_.parse(ary[i]);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
public static byte[] Xto_bry(int v) {return Bry_.new_a7(Xto_str(v));}
|
public static byte[] Xto_bry(int v) {return Bry_.new_a7(Xto_str(v));}
|
||||||
|
public static final int
|
||||||
|
Min_value = Integer.MIN_VALUE
|
||||||
|
, Max_value = Integer.MAX_VALUE
|
||||||
|
, Neg1 = -1
|
||||||
|
, Neg1_count = -1
|
||||||
|
;
|
||||||
}
|
}
|
@ -31,7 +31,7 @@ public class Int__tst {
|
|||||||
tst_ParseOr("", -1); // empty
|
tst_ParseOr("", -1); // empty
|
||||||
tst_ParseOr("123", 123); // single
|
tst_ParseOr("123", 123); // single
|
||||||
tst_ParseOr("1a", -1); // fail
|
tst_ParseOr("1a", -1); // fail
|
||||||
} void tst_ParseOr(String raw, int expd) {Tfds.Eq(expd, Int_.parse_or_(raw, -1));}
|
} void tst_ParseOr(String raw, int expd) {Tfds.Eq(expd, Int_.parse_or(raw, -1));}
|
||||||
@Test public void Between() {
|
@Test public void Between() {
|
||||||
tst_Between(1, 0, 2, true); // simple true
|
tst_Between(1, 0, 2, true); // simple true
|
||||||
tst_Between(3, 0, 2, false); // simple false
|
tst_Between(3, 0, 2, false); // simple false
|
||||||
@ -53,7 +53,7 @@ public class Int__tst {
|
|||||||
tst_Log10(100, 2);
|
tst_Log10(100, 2);
|
||||||
tst_Log10(1000000, 6);
|
tst_Log10(1000000, 6);
|
||||||
tst_Log10(1000000000, 9);
|
tst_Log10(1000000000, 9);
|
||||||
tst_Log10(Int_.MaxValue, 9);
|
tst_Log10(Int_.Max_value, 9);
|
||||||
}
|
}
|
||||||
@Test public void Log10_neg() {
|
@Test public void Log10_neg() {
|
||||||
tst_Log10(-1, 0);
|
tst_Log10(-1, 0);
|
||||||
@ -61,8 +61,8 @@ public class Int__tst {
|
|||||||
tst_Log10(-100, -2);
|
tst_Log10(-100, -2);
|
||||||
tst_Log10(-1000000, -6);
|
tst_Log10(-1000000, -6);
|
||||||
tst_Log10(-1000000000, -9);
|
tst_Log10(-1000000000, -9);
|
||||||
tst_Log10(Int_.MinValue, -9);
|
tst_Log10(Int_.Min_value, -9);
|
||||||
tst_Log10(Int_.MinValue + 1, -9);
|
tst_Log10(Int_.Min_value + 1, -9);
|
||||||
}
|
}
|
||||||
void tst_Log10(int val, int expd) {Tfds.Eq(expd, Int_.Log10(val));}
|
void tst_Log10(int val, int expd) {Tfds.Eq(expd, Int_.Log10(val));}
|
||||||
@Test public void DigitCount() {
|
@Test public void DigitCount() {
|
||||||
@ -94,7 +94,7 @@ public class Int__tst {
|
|||||||
tst_Log10( 123456789, 8);
|
tst_Log10( 123456789, 8);
|
||||||
tst_Log10( 1000000000, 9);
|
tst_Log10( 1000000000, 9);
|
||||||
tst_Log10( 1234567890, 9);
|
tst_Log10( 1234567890, 9);
|
||||||
tst_Log10(Int_.MaxValue, 9);
|
tst_Log10(Int_.Max_value, 9);
|
||||||
}
|
}
|
||||||
@Test public void Xto_int_hex_tst() {
|
@Test public void Xto_int_hex_tst() {
|
||||||
Xto_int_hex("007C", 124);
|
Xto_int_hex("007C", 124);
|
||||||
@ -104,8 +104,8 @@ public class Int__tst {
|
|||||||
Ary_parse__tst("123,321,213" , 3, Int_.Ary_empty, 123, 321, 213);
|
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("-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_.MinValue) , 1, Int_.Ary_empty, Int_.MinValue);
|
Ary_parse__tst(Int_.Xto_str(Int_.Min_value) , 1, Int_.Ary_empty, Int_.Min_value);
|
||||||
Ary_parse__tst(Int_.Xto_str(Int_.MaxValue) , 1, Int_.Ary_empty, Int_.MaxValue);
|
Ary_parse__tst(Int_.Xto_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" , 1, Int_.Ary_empty);
|
||||||
Ary_parse__tst("1" , 2, Int_.Ary_empty);
|
Ary_parse__tst("1" , 2, Int_.Ary_empty);
|
||||||
Ary_parse__tst("a" , 1, Int_.Ary_empty);
|
Ary_parse__tst("a" , 1, Int_.Ary_empty);
|
@ -25,15 +25,15 @@ public class Int_ary_ {
|
|||||||
int pos = 0;
|
int pos = 0;
|
||||||
int num_bgn = -1, num_end = -1;
|
int num_bgn = -1, num_end = -1;
|
||||||
boolean itm_done = false, itm_is_rng = false;
|
boolean itm_done = false, itm_is_rng = false;
|
||||||
int rng_bgn = Int_.MinValue;
|
int rng_bgn = Int_.Min_value;
|
||||||
while (true) {
|
while (true) {
|
||||||
boolean pos_is_last = pos == raw_len;
|
boolean pos_is_last = pos == raw_len;
|
||||||
if ( itm_done
|
if ( itm_done
|
||||||
|| pos_is_last
|
|| pos_is_last
|
||||||
) {
|
) {
|
||||||
if (num_bgn == -1) return or; // empty itm; EX: "1,"; "1,,2"
|
if (num_bgn == -1) return or; // empty itm; EX: "1,"; "1,,2"
|
||||||
int num = Bry_.To_int_or(src, num_bgn, num_end, Int_.MinValue);
|
int num = Bry_.To_int_or(src, num_bgn, num_end, Int_.Min_value);
|
||||||
if (num == Int_.MinValue) return or; // not a number; parse failed
|
if (num == Int_.Min_value) return or; // not a number; parse failed
|
||||||
if (rv_len == 0) { // rv not init'd
|
if (rv_len == 0) { // rv not init'd
|
||||||
rv_len = (raw_len / 2) + 1; // default rv_len to len of String / 2; + 1 to avoid fraction rounding down
|
rv_len = (raw_len / 2) + 1; // default rv_len to len of String / 2; + 1 to avoid fraction rounding down
|
||||||
rv = new int[rv_len];
|
rv = new int[rv_len];
|
||||||
@ -56,7 +56,7 @@ public class Int_ary_ {
|
|||||||
}
|
}
|
||||||
num_bgn = num_end = -1;
|
num_bgn = num_end = -1;
|
||||||
itm_done = itm_is_rng = false;
|
itm_done = itm_is_rng = false;
|
||||||
rng_bgn = Int_.MinValue;
|
rng_bgn = Int_.Min_value;
|
||||||
if (pos_is_last) break;
|
if (pos_is_last) break;
|
||||||
}
|
}
|
||||||
byte b = src[pos];
|
byte b = src[pos];
|
||||||
@ -77,8 +77,8 @@ public class Int_ary_ {
|
|||||||
case Byte_ascii.Dash:
|
case Byte_ascii.Dash:
|
||||||
if (pos == raw_len -1) return or; // eos; EX: "1-"
|
if (pos == raw_len -1) return or; // eos; EX: "1-"
|
||||||
if (num_bgn == -1) return or; // no rng_bgn; EX: "-2"
|
if (num_bgn == -1) return or; // no rng_bgn; EX: "-2"
|
||||||
rng_bgn = Bry_.To_int_or(src, num_bgn, pos, Int_.MinValue);
|
rng_bgn = Bry_.To_int_or(src, num_bgn, pos, Int_.Min_value);
|
||||||
if (rng_bgn == Int_.MinValue) return or;
|
if (rng_bgn == Int_.Min_value) return or;
|
||||||
num_bgn = -1;
|
num_bgn = -1;
|
||||||
itm_is_rng = true;
|
itm_is_rng = true;
|
||||||
break;
|
break;
|
@ -19,36 +19,32 @@ package gplx;
|
|||||||
public class Long_ {
|
public class Long_ {
|
||||||
public static final String Cls_val_name = "long";
|
public static final String Cls_val_name = "long";
|
||||||
public static final Class<?> Cls_ref_type = Long.class;
|
public static final Class<?> Cls_ref_type = Long.class;
|
||||||
public static final long
|
|
||||||
MinValue = Long.MIN_VALUE
|
|
||||||
, MaxValue = Long.MAX_VALUE
|
|
||||||
;
|
|
||||||
public static final int Log10Ary_len = 21;
|
public static final int Log10Ary_len = 21;
|
||||||
public static long[] Log10Ary = new long[]
|
public static long[] Log10Ary = new long[]
|
||||||
{ 1, 10, 100, 1000, 10000
|
{ 1, 10, 100, 1000, 10000
|
||||||
, 100000, 1000000, 10000000, 100000000, 1000000000
|
, 100000, 1000000, 10000000, 100000000, 1000000000
|
||||||
, Long_.Pow(10, 10), Long_.Pow(10, 11), Long_.Pow(10, 12), Long_.Pow(10, 13), Long_.Pow(10, 14)
|
, Long_.Pow(10, 10), Long_.Pow(10, 11), Long_.Pow(10, 12), Long_.Pow(10, 13), Long_.Pow(10, 14)
|
||||||
, Long_.Pow(10, 15), Long_.Pow(10, 16), Long_.Pow(10, 17), Long_.Pow(10, 18), Long_.Pow(10, 19)
|
, Long_.Pow(10, 15), Long_.Pow(10, 16), Long_.Pow(10, 17), Long_.Pow(10, 18), Long_.Pow(10, 19)
|
||||||
, Long_.MaxValue
|
, Long_.Max_value
|
||||||
};
|
};
|
||||||
public static long parse_(String raw) {try {return Long.parseLong(raw);} catch(Exception e) {throw Err_.new_parse_exc(e, long.class, raw);}}
|
public static long parse(String raw) {try {return Long.parseLong(raw);} catch(Exception e) {throw Err_.new_parse_exc(e, long.class, raw);}}
|
||||||
public static long cast_(Object obj) {try {return (Long)obj;} catch(Exception e) {throw Err_.new_type_mismatch_w_exc(e, long.class, obj);}}
|
public static long cast(Object obj) {try {return (Long)obj;} catch(Exception e) {throw Err_.new_type_mismatch_w_exc(e, long.class, obj);}}
|
||||||
public static long coerce_(Object v) {
|
public static long coerce_(Object v) {
|
||||||
try {String s = String_.as_(v); return s == null ? Long_.cast_(v) : Long_.parse_(s);}
|
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);}
|
catch (Exception e) {throw Err_.new_cast(e, long.class, v);}
|
||||||
}
|
}
|
||||||
public static long Xby_int(int v) {return (long)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(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 Xto_str_PadBgn(long v, int reqdPlaces) {return String_.Pad(Xto_str(v), reqdPlaces, "0", true);} // ex: 1, 3 returns 001
|
||||||
public static long parse_or_(String raw, long or) {
|
public static long parse_or(String raw, long or) {
|
||||||
if (raw == null) return or;
|
if (raw == null) return or;
|
||||||
try {
|
try {
|
||||||
int rawLen = String_.Len(raw);
|
int rawLen = String_.Len(raw);
|
||||||
if (raw == null || rawLen == 0) return or;
|
if (raw == null || rawLen == 0) return or;
|
||||||
long rv = 0, factor = 1; int tmp = 0;
|
long rv = 0, factor = 1; int tmp = 0;
|
||||||
for (int i = rawLen; i > 0; i--) {
|
for (int i = rawLen; i > 0; i--) {
|
||||||
tmp = Char_.To_int_or(String_.CharAt(raw, i - 1), Int_.MinValue);
|
tmp = Char_.To_int_or(String_.CharAt(raw, i - 1), Int_.Min_value);
|
||||||
if (tmp == Int_.MinValue) return or;
|
if (tmp == Int_.Min_value) return or;
|
||||||
rv += (tmp * factor);
|
rv += (tmp * factor);
|
||||||
factor *= 10;
|
factor *= 10;
|
||||||
}
|
}
|
||||||
@ -90,7 +86,7 @@ public class Long_ {
|
|||||||
public static int DigitCount(long v) {
|
public static int DigitCount(long v) {
|
||||||
int adj = Int_.Base1;
|
int adj = Int_.Base1;
|
||||||
if (v < 0) {
|
if (v < 0) {
|
||||||
if (v == Long_.MinValue) return 19; // NOTE: Long_.MinValue * -1 = Long_.MinValue
|
if (v == Long_.Min_value) return 19; // NOTE: Long_.Min_value * -1 = Long_.Min_value
|
||||||
v *= -1;
|
v *= -1;
|
||||||
++adj;
|
++adj;
|
||||||
}
|
}
|
||||||
@ -105,6 +101,10 @@ public class Long_ {
|
|||||||
public static long Int_merge(int hi, int lo) {return (long)hi << 32 | (lo & 0xFFFFFFFFL);}
|
public static long Int_merge(int hi, int lo) {return (long)hi << 32 | (lo & 0xFFFFFFFFL);}
|
||||||
public static int Int_split_lo(long v) {return (int)(v);}
|
public static int Int_split_lo(long v) {return (int)(v);}
|
||||||
public static int Int_split_hi(long v) {return (int)(v >> 32);}
|
public static int Int_split_hi(long v) {return (int)(v >> 32);}
|
||||||
|
public static final long
|
||||||
|
Min_value = Long.MIN_VALUE
|
||||||
|
, Max_value = Long.MAX_VALUE
|
||||||
|
;
|
||||||
}
|
}
|
||||||
/* alternate for Int_merge; does not work in java
|
/* alternate for Int_merge; does not work in java
|
||||||
public static long MergeInts(int lo, int hi) {return (uint)(hi << 32) | (lo & 0xffffffff);}
|
public static long MergeInts(int lo, int hi) {return (uint)(hi << 32) | (lo & 0xffffffff);}
|
@ -42,8 +42,8 @@ public class Long__tst {
|
|||||||
Tfds.Eq(hi, Long_.Int_split_hi(expd));
|
Tfds.Eq(hi, Long_.Int_split_hi(expd));
|
||||||
Tfds.Eq(lo, Long_.Int_split_lo(expd));
|
Tfds.Eq(lo, Long_.Int_split_lo(expd));
|
||||||
}
|
}
|
||||||
@Test public void parse_or_() {
|
@Test public void parse_or() {
|
||||||
parse_or_tst("10000000000", 10000000000L);
|
parse_or_tst("10000000000", 10000000000L);
|
||||||
}
|
}
|
||||||
void parse_or_tst(String raw, long expd) {Tfds.Eq(expd, Long_.parse_or_(raw, -1));}
|
void parse_or_tst(String raw, long expd) {Tfds.Eq(expd, Long_.parse_or(raw, -1));}
|
||||||
}
|
}
|
@ -18,5 +18,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
package gplx;
|
package gplx;
|
||||||
public class Short_ {
|
public class Short_ {
|
||||||
public static final Class<?> Cls_ref_type = Short.class;
|
public static final Class<?> Cls_ref_type = Short.class;
|
||||||
public static short cast_(Object obj) {try {return (Short)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, short.class, obj);}}
|
public static short cast(Object obj) {try {return (Short)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, short.class, obj);}}
|
||||||
}
|
}
|
@ -23,14 +23,14 @@ public class Yn {
|
|||||||
else if (String_.Eq(v, N)) return false;
|
else if (String_.Eq(v, N)) return false;
|
||||||
else return or;
|
else return or;
|
||||||
}
|
}
|
||||||
public static boolean parse_or_n_(String v) {return parse_or_(v, false);}
|
public static boolean parse_or_n_(String v) {return parse_or(v, false);}
|
||||||
public static int parse_as_int(String v) {
|
public static int parse_as_int(String v) {
|
||||||
if (v == null) return Bool_.__int;
|
if (v == null) return Bool_.__int;
|
||||||
else if (String_.Eq(v, "y")) return Bool_.Y_int;
|
else if (String_.Eq(v, "y")) return Bool_.Y_int;
|
||||||
else if (String_.Eq(v, "n")) return Bool_.N_int;
|
else if (String_.Eq(v, "n")) return Bool_.N_int;
|
||||||
else return Bool_.__int;
|
else return Bool_.__int;
|
||||||
}
|
}
|
||||||
public static boolean parse_or_(String v, boolean or) {
|
public static boolean parse_or(String v, boolean or) {
|
||||||
int v_int = parse_as_int(v);
|
int v_int = parse_as_int(v);
|
||||||
switch (v_int) {
|
switch (v_int) {
|
||||||
case Bool_.N_int: return false;
|
case Bool_.N_int: return false;
|
||||||
@ -39,7 +39,7 @@ public class Yn {
|
|||||||
default: throw Err_.new_unhandled(v_int);
|
default: throw Err_.new_unhandled(v_int);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static boolean parse_(String v) {
|
public static boolean parse(String v) {
|
||||||
int v_int = parse_as_int(v);
|
int v_int = parse_as_int(v);
|
||||||
if (v_int == Bool_.__int) Err_.new_unhandled(v);
|
if (v_int == Bool_.__int) Err_.new_unhandled(v);
|
||||||
return v_int == Bool_.Y_int;
|
return v_int == Bool_.Y_int;
|
||||||
@ -66,13 +66,13 @@ public class Yn {
|
|||||||
}
|
}
|
||||||
public static boolean store_bool_or(SrlMgr mgr, String key, boolean or) {
|
public static boolean store_bool_or(SrlMgr mgr, String key, boolean or) {
|
||||||
String v = mgr.SrlStrOr(key, "");
|
String v = mgr.SrlStrOr(key, "");
|
||||||
return mgr.Type_rdr() ? parse_or_(v, or) : or;
|
return mgr.Type_rdr() ? parse_or(v, or) : or;
|
||||||
}
|
}
|
||||||
public static boolean coerce_(Object o) {String s = String_.as_(o); return s != null ? parse_or_(s, false) : Bool_.cast_(o);}
|
public static boolean coerce_(Object o) {String s = String_.as_(o); return s != null ? parse_or(s, false) : Bool_.cast(o);}
|
||||||
public static boolean readOrFalse_(DataRdr rdr, String key) {return read_(rdr, key, false);}
|
public static boolean readOrFalse_(DataRdr rdr, String key) {return read_(rdr, key, false);}
|
||||||
public static boolean readOrTrue_(DataRdr rdr, String key) {return read_(rdr, key, true);}
|
public static boolean readOrTrue_(DataRdr rdr, String key) {return read_(rdr, key, true);}
|
||||||
static boolean read_(DataRdr rdr, String key, boolean or) {
|
static boolean read_(DataRdr rdr, String key, boolean or) {
|
||||||
String v = rdr.ReadStrOr(key, null);
|
String v = rdr.ReadStrOr(key, null);
|
||||||
return parse_or_(v, or);
|
return parse_or(v, or);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,7 +22,6 @@ import java.math.RoundingMode;
|
|||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
public class Decimal_adp implements CompareAble {
|
public class Decimal_adp implements CompareAble {
|
||||||
public int compareTo(Object obj) {Decimal_adp comp = (Decimal_adp)obj; return under.compareTo(comp.under);}
|
public int compareTo(Object obj) {Decimal_adp comp = (Decimal_adp)obj; return under.compareTo(comp.under);}
|
||||||
|
|
||||||
protected Decimal_adp(BigDecimal v) {this.under = v;} private final BigDecimal under;
|
protected Decimal_adp(BigDecimal v) {this.under = v;} private final BigDecimal under;
|
||||||
protected Decimal_adp(int v) {this.under = new BigDecimal(v);}
|
protected Decimal_adp(int v) {this.under = new BigDecimal(v);}
|
||||||
public Object Under() {return under;}
|
public Object Under() {return under;}
|
@ -32,7 +32,7 @@ import java.math.BigDecimal;
import java.math.MathContext;
import java.math.Roun
|
|||||||
int pow10 = XtoPow10(frc);
|
int pow10 = XtoPow10(frc);
|
||||||
return divide_((num * (pow10)) + frc, pow10);
|
return divide_((num * (pow10)) + frc, pow10);
|
||||||
}
|
}
|
||||||
public static Decimal_adp cast_(Object obj) {return (Decimal_adp)obj;}
|
public static Decimal_adp cast(Object obj) {return (Decimal_adp)obj;}
|
||||||
static int XtoPow10(int v) {
|
static int XtoPow10(int v) {
|
||||||
if (v > -1 && v < 10) return 10;
|
if (v > -1 && v < 10) return 10;
|
||||||
else if (v > 9 && v < 100) return 100;
|
else if (v > 9 && v < 100) return 100;
|
||||||
@ -53,5 +53,5 @@ import java.math.BigDecimal;
import java.math.MathContext;
import java.math.Roun
|
|||||||
public static Decimal_adp divide_(long lhs, long rhs) {
return new Decimal_adp(new BigDecimal(lhs).divide(new BigDecimal(rhs), Gplx_rounding_context));
}
public static Decimal_adp int_(int v) {return new Decimal_adp(new BigDecimal(v));}
public static Decimal_adp long_(long v) {return new Decimal_adp(new BigDecimal(v));}
|
public static Decimal_adp divide_(long lhs, long rhs) {
return new Decimal_adp(new BigDecimal(lhs).divide(new BigDecimal(rhs), Gplx_rounding_context));
}
public static Decimal_adp int_(int v) {return new Decimal_adp(new BigDecimal(v));}
public static Decimal_adp long_(long v) {return new Decimal_adp(new BigDecimal(v));}
|
||||||
public static Decimal_adp float_(float v) {return new Decimal_adp(new BigDecimal(v));}
public static Decimal_adp double_(double v) {return new Decimal_adp(new BigDecimal(v));}
|
public static Decimal_adp float_(float v) {return new Decimal_adp(new BigDecimal(v));}
public static Decimal_adp double_(double v) {return new Decimal_adp(new BigDecimal(v));}
|
||||||
public static Decimal_adp double_thru_str_(double v) {return new Decimal_adp(BigDecimal.valueOf(v));}
|
public static Decimal_adp double_thru_str_(double v) {return new Decimal_adp(BigDecimal.valueOf(v));}
|
||||||
public static Decimal_adp db_(Object v) {return new Decimal_adp((BigDecimal)v);}
public static Decimal_adp parse_(String raw) {return new Decimal_adp(new BigDecimal(raw));}
public static Decimal_adp pow_10_(int v) {return new Decimal_adp(new BigDecimal(1).scaleByPowerOfTen(v));}
|
public static Decimal_adp db_(Object v) {return new Decimal_adp((BigDecimal)v);}
public static Decimal_adp parse(String raw) {return new Decimal_adp(new BigDecimal(raw));}
public static Decimal_adp pow_10_(int v) {return new Decimal_adp(new BigDecimal(1).scaleByPowerOfTen(v));}
|
||||||
public static final MathContext RoundDownContext = new MathContext(0, RoundingMode.DOWN);
public static final MathContext Gplx_rounding_context = new MathContext(14, RoundingMode.HALF_UP); // changed from 28 to 14; DATE:2015-07-31
}
|
public static final MathContext RoundDownContext = new MathContext(0, RoundingMode.DOWN);
public static final MathContext Gplx_rounding_context = new MathContext(14, RoundingMode.HALF_UP); // changed from 28 to 14; DATE:2015-07-31
}
|
@ -35,7 +35,7 @@ public class Decimal_adp__tst {
|
|||||||
fxt.Test_parts(1, 23, "1.23");
|
fxt.Test_parts(1, 23, "1.23");
|
||||||
fxt.Test_parts(123, 4567, "123.4567");
|
fxt.Test_parts(123, 4567, "123.4567");
|
||||||
}
|
}
|
||||||
@Test public void parse_() {
|
@Test public void parse() {
|
||||||
fxt.Test_parse("1", "1");
|
fxt.Test_parse("1", "1");
|
||||||
fxt.Test_parse("1.2", "1.2");
|
fxt.Test_parse("1.2", "1.2");
|
||||||
fxt.Test_parse("0.1", "0.1");
|
fxt.Test_parse("0.1", "0.1");
|
||||||
@ -78,10 +78,10 @@ class Decimal_adp__fxt {
|
|||||||
public void Test_divide(int lhs, int rhs, String expd) {Tfds.Eq(expd, Decimal_adp_.divide_(lhs, rhs).To_str());}
|
public void Test_divide(int lhs, int rhs, String expd) {Tfds.Eq(expd, Decimal_adp_.divide_(lhs, rhs).To_str());}
|
||||||
public void Test_base_1000(int val, String expd) {Tfds.Eq(expd, Decimal_adp_.base1000_(val).To_str());}
|
public void Test_base_1000(int val, String expd) {Tfds.Eq(expd, Decimal_adp_.base1000_(val).To_str());}
|
||||||
public void Test_parts(int num, int fracs, String expd) {Tfds.Eq(expd, Decimal_adp_.parts_(num, fracs).To_str());}
|
public void Test_parts(int num, int fracs, String expd) {Tfds.Eq(expd, Decimal_adp_.parts_(num, fracs).To_str());}
|
||||||
public void Test_parse(String raw, String expd) {Tfds.Eq(expd, Decimal_adp_.parse_(raw).To_str());}
|
public void Test_parse(String raw, String expd) {Tfds.Eq(expd, Decimal_adp_.parse(raw).To_str());}
|
||||||
public void Test_truncate_decimal(String raw, String expd) {Tfds.Eq(Decimal_adp_.parse_(expd).To_str(), Decimal_adp_.parse_(raw).Truncate().To_str());}
|
public void Test_truncate_decimal(String raw, String expd) {Tfds.Eq(Decimal_adp_.parse(expd).To_str(), Decimal_adp_.parse(raw).Truncate().To_str());}
|
||||||
public void Test_frac_1000(int lhs, int rhs, int expd) {Tfds.Eq(expd, Decimal_adp_.divide_(lhs, rhs).Frac_1000());}
|
public void Test_frac_1000(int lhs, int rhs, int expd) {Tfds.Eq(expd, Decimal_adp_.divide_(lhs, rhs).Frac_1000());}
|
||||||
public void Test_comp_lt(int lhsNum, int lhsFrc, int rhs, boolean expd) {Tfds.Eq(expd, Decimal_adp_.parts_(lhsNum, lhsFrc).Comp_lt(rhs));}
|
public void Test_comp_lt(int lhsNum, int lhsFrc, int rhs, boolean expd) {Tfds.Eq(expd, Decimal_adp_.parts_(lhsNum, lhsFrc).Comp_lt(rhs));}
|
||||||
public void Test_to_str_fmt(int l, int r, String fmt, String expd) {Tfds.Eq(expd, Decimal_adp_.divide_(l, r).To_str(fmt));}
|
public void Test_to_str_fmt(int l, int r, String fmt, String expd) {Tfds.Eq(expd, Decimal_adp_.divide_(l, r).To_str(fmt));}
|
||||||
public void Test_round(String raw, int places, String expd) {Tfds.Eq_str(expd, Decimal_adp_.parse_(raw).Round(places).To_str(), "round");}
|
public void Test_round(String raw, int places, String expd) {Tfds.Eq_str(expd, Decimal_adp_.parse(raw).Round(places).To_str(), "round");}
|
||||||
}
|
}
|
@ -17,6 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
*/
|
*/
|
||||||
package gplx;
|
package gplx;
|
||||||
public class Guid_adp {
|
public class Guid_adp {
|
||||||
public String To_str() {return guid.toString();}
|
|
||||||
public Guid_adp(java.util.UUID guid) {this.guid = guid;} java.util.UUID guid;
|
public Guid_adp(java.util.UUID guid) {this.guid = guid;} java.util.UUID guid;
|
||||||
|
public String To_str() {return guid.toString();}
|
||||||
}
|
}
|
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
package gplx;
|
package gplx;
|
||||||
public class Guid_adp_ {
|
public class Guid_adp_ {
|
||||||
public static final String Cls_ref_name = "Guid";
|
public static final String Cls_ref_name = "Guid";
|
||||||
public static final Guid_adp Empty = parse_("00000000-0000-0000-0000-000000000000");
|
public static final Guid_adp Empty = parse("00000000-0000-0000-0000-000000000000");
|
||||||
public static Guid_adp new_() {return new Guid_adp(java.util.UUID.randomUUID());}
|
public static Guid_adp new_() {return new Guid_adp(java.util.UUID.randomUUID());}
|
||||||
public static Guid_adp parse_(String s) {return new Guid_adp(java.util.UUID.fromString(s));}
|
public static Guid_adp parse(String s) {return new Guid_adp(java.util.UUID.fromString(s));}
|
||||||
}
|
}
|
@ -18,11 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
package gplx;
|
package gplx;
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
public class Guid_adp__tst {
|
public class Guid_adp__tst {
|
||||||
@Test public void parse_() {
|
@Test public void parse() {
|
||||||
tst_parse_("467ffb41-cdfe-402f-b22b-be855425784b");
|
tst_parse_("467ffb41-cdfe-402f-b22b-be855425784b");
|
||||||
}
|
}
|
||||||
void tst_parse_(String s) {
|
void tst_parse_(String s) {
|
||||||
Guid_adp uuid = Guid_adp_.parse_(s);
|
Guid_adp uuid = Guid_adp_.parse(s);
|
||||||
Tfds.Eq(uuid.To_str(), s);
|
Tfds.Eq(uuid.To_str(), s);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -39,8 +39,9 @@ public class Object_ {
|
|||||||
Class<?> c = Type_adp_.ClassOf_obj(v);
|
Class<?> c = Type_adp_.ClassOf_obj(v);
|
||||||
if (Type_adp_.Eq(c, String_.Cls_ref_type)) return (String)v;
|
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, 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, 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_.Xto_str_loose(Double_.cast(v));
|
||||||
else return v.toString();
|
else return v.toString();
|
||||||
}
|
}
|
||||||
|
public static final byte[] Bry__null = Bry_.new_a7("null");
|
||||||
}
|
}
|
@ -23,7 +23,7 @@ public class String_ implements GfoInvkAble {
|
|||||||
public static final String Cls_val_name = "str" + "ing";
|
public static final String Cls_val_name = "str" + "ing";
|
||||||
public static final int Find_none = -1, Pos_neg1 = -1;
|
public static final int Find_none = -1, Pos_neg1 = -1;
|
||||||
public static final String Null = null, Empty = "", Null_mark = "<<NULL>>", Tab = "\t", Lf = "\n", CrLf = "\r\n";
|
public static final String Null = null, Empty = "", Null_mark = "<<NULL>>", Tab = "\t", Lf = "\n", CrLf = "\r\n";
|
||||||
public static String cast_(Object v) {return (String)v;}
|
public static String cast(Object v) {return (String)v;}
|
||||||
public static String as_(Object obj) {return obj instanceof String ? (String)obj : null;}
|
public static String as_(Object obj) {return obj instanceof String ? (String)obj : null;}
|
||||||
public static String new_a7(byte[] v) {return v == null ? null : new_a7(v, 0, v.length);}
|
public static String new_a7(byte[] v) {return v == null ? null : new_a7(v, 0, v.length);}
|
||||||
public static String new_a7(byte[] v, int bgn, int end) {
|
public static String new_a7(byte[] v, int bgn, int end) {
|
||||||
@ -385,8 +385,8 @@ public class String_ implements GfoInvkAble {
|
|||||||
numberStr = "";
|
numberStr = "";
|
||||||
}
|
}
|
||||||
else if (c == bracketEnd) {
|
else if (c == bracketEnd) {
|
||||||
int aryIdx = Int_.parse_or_(numberStr, Int_.MinValue);
|
int aryIdx = Int_.parse_or(numberStr, Int_.Min_value);
|
||||||
if (aryIdx != Int_.MinValue && Int_.Between(aryIdx, 0, aryLength - 1)) // check (a) aryIdx is num; (b) aryIdx is in bounds
|
if (aryIdx != Int_.Min_value && Int_.Between(aryIdx, 0, aryLength - 1)) // check (a) aryIdx is num; (b) aryIdx is in bounds
|
||||||
aryVal = Object_.Xto_str_strict_or_empty(ary[aryIdx]);
|
aryVal = Object_.Xto_str_strict_or_empty(ary[aryIdx]);
|
||||||
else
|
else
|
||||||
aryVal = String_.Concat_any(bracketBgn, numberStr, bracketEnd); // not valid, just add String
|
aryVal = String_.Concat_any(bracketBgn, numberStr, bracketEnd); // not valid, just add String
|
||||||
@ -488,9 +488,9 @@ public class String_ implements GfoInvkAble {
|
|||||||
public static String Replace_by_pos(String v, int del_bgn, int del_end, String repl) {
|
public static String Replace_by_pos(String v, int del_bgn, int del_end, String repl) {
|
||||||
return String_.Mid(v, 0, del_bgn) + repl + String_.Mid(v, del_end, String_.Len(v));
|
return String_.Mid(v, 0, del_bgn) + repl + String_.Mid(v, del_end, String_.Len(v));
|
||||||
}
|
}
|
||||||
public static String read_(Object obj) {// NOTE: same as cast_; for consistent readability only
|
public static String read_(Object obj) {// NOTE: same as cast; for consistent readability only
|
||||||
String rv = as_(obj);
|
String rv = as_(obj);
|
||||||
if (rv == null && obj != null) throw Err_.new_type_mismatch(String.class, obj); // NOTE: obj != null needed; EX: cast_(null) --> null
|
if (rv == null && obj != null) throw Err_.new_type_mismatch(String.class, obj); // NOTE: obj != null needed; EX: cast(null) --> null
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
public static String[] Ary(byte[]... ary) {
|
public static String[] Ary(byte[]... ary) {
|
@ -69,7 +69,7 @@ public class DateAdp implements CompareAble, GfoInvkAble {
|
|||||||
public String XtoStr_fmt_yyyy_MM_dd_HH_mm() {return XtoStr_fmt("yyyy-MM-dd HH:mm");}
|
public String XtoStr_fmt_yyyy_MM_dd_HH_mm() {return XtoStr_fmt("yyyy-MM-dd HH:mm");}
|
||||||
public String XtoStr_fmt_yyyy_MM_dd_HH_mm_ss() {return XtoStr_fmt("yyyy-MM-dd HH:mm:ss");}
|
public String XtoStr_fmt_yyyy_MM_dd_HH_mm_ss() {return XtoStr_fmt("yyyy-MM-dd HH:mm:ss");}
|
||||||
public String XtoStr_fmt_iso_8561() {return XtoStr_fmt("yyyy-MM-dd HH:mm:ss");}
|
public String XtoStr_fmt_iso_8561() {return XtoStr_fmt("yyyy-MM-dd HH:mm:ss");}
|
||||||
public static int Timezone_offset_test = Int_.MinValue;
|
public static int Timezone_offset_test = Int_.Min_value;
|
||||||
public Calendar UnderDateTime() {return under;} Calendar under;
|
public Calendar UnderDateTime() {return under;} Calendar under;
|
||||||
public int Year() {return under.get(Calendar.YEAR);}
|
public int Year() {return under.get(Calendar.YEAR);}
|
||||||
public int Month() {return under.get(Calendar.MONTH) + Month_base0adj;}
|
public int Month() {return under.get(Calendar.MONTH) + Month_base0adj;}
|
||||||
@ -80,7 +80,7 @@ public class DateAdp implements CompareAble, GfoInvkAble {
|
|||||||
public int DayOfWeek() {return under.get(Calendar.DAY_OF_WEEK) - 1;} // -1 : Base0; NOTE: dotnet/php is also Sunday=0
|
public int DayOfWeek() {return under.get(Calendar.DAY_OF_WEEK) - 1;} // -1 : Base0; NOTE: dotnet/php is also Sunday=0
|
||||||
public int DayOfYear() {return under.get(Calendar.DAY_OF_YEAR);}
|
public int DayOfYear() {return under.get(Calendar.DAY_OF_YEAR);}
|
||||||
public int Timezone_offset() {
|
public int Timezone_offset() {
|
||||||
return Timezone_offset_test == Int_.MinValue // Timezone_offset_test not over-ridden
|
return Timezone_offset_test == Int_.Min_value // Timezone_offset_test not over-ridden
|
||||||
? 0
|
? 0
|
||||||
// ? under.getTimeZone().getOffset(this.Timestamp_unix()) / 1000 // divide by 1000 to convert from ms to seconds
|
// ? under.getTimeZone().getOffset(this.Timestamp_unix()) / 1000 // divide by 1000 to convert from ms to seconds
|
||||||
: Timezone_offset_test
|
: Timezone_offset_test
|
||||||
|
@ -46,7 +46,7 @@ public class DateAdp_ implements GfoInvkAble {
|
|||||||
int f = ary_len > 6 ? ary[6] : 0;
|
int f = ary_len > 6 ? ary[6] : 0;
|
||||||
return new DateAdp(y, M, d, h, m, s, f);
|
return new DateAdp(y, M, d, h, m, s, f);
|
||||||
}
|
}
|
||||||
public static DateAdp cast_(Object arg) {try {return (DateAdp)arg;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, DateAdp.class, arg);}}
|
public static DateAdp cast(Object arg) {try {return (DateAdp)arg;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, DateAdp.class, arg);}}
|
||||||
public static DateAdp parse_iso8561_or(String raw, DateAdp or) {
|
public static DateAdp parse_iso8561_or(String raw, DateAdp or) {
|
||||||
try {return parse_iso8561(raw);}
|
try {return parse_iso8561(raw);}
|
||||||
catch (Exception e) {Err_.Noop(e); return or;}
|
catch (Exception e) {Err_.Noop(e); return or;}
|
||||||
|
@ -21,7 +21,7 @@ public class EnmMgr {
|
|||||||
public String BitRngSpr() {return bitRngSpr;} public EnmMgr BitRngSpr_(String val) {bitRngSpr = val; return this;} private String bitRngSpr = "+";
|
public String BitRngSpr() {return bitRngSpr;} public EnmMgr BitRngSpr_(String val) {bitRngSpr = val; return this;} private String bitRngSpr = "+";
|
||||||
public String Prefix() {return prefix;} public EnmMgr Prefix_(String val) {prefix = val; return this;} private String prefix;
|
public String Prefix() {return prefix;} public EnmMgr Prefix_(String val) {prefix = val; return this;} private String prefix;
|
||||||
public int BitRngBgn() {return bitRngBgn;} public EnmMgr BitRngBgn_(int val) {bitRngBgn = val; return this;} int bitRngBgn = 1;
|
public int BitRngBgn() {return bitRngBgn;} public EnmMgr BitRngBgn_(int val) {bitRngBgn = val; return this;} int bitRngBgn = 1;
|
||||||
public int BitRngEnd() {return bitRngEnd;} public EnmMgr BitRngEnd_(int val) {bitRngEnd = val; return this;} int bitRngEnd = Int_.MaxValue;
|
public int BitRngEnd() {return bitRngEnd;} public EnmMgr BitRngEnd_(int val) {bitRngEnd = val; return this;} int bitRngEnd = Int_.Max_value;
|
||||||
public void RegObj(int val, String raw, Object o) {
|
public void RegObj(int val, String raw, Object o) {
|
||||||
rawRegy.Add(raw, val);
|
rawRegy.Add(raw, val);
|
||||||
valRegy.Add(val, raw);
|
valRegy.Add(val, raw);
|
||||||
@ -36,9 +36,9 @@ public class EnmMgr {
|
|||||||
if (prefix != null) term = String_.Replace(term, prefix, "");
|
if (prefix != null) term = String_.Replace(term, prefix, "");
|
||||||
int cur = -1;
|
int cur = -1;
|
||||||
if (String_.Has_at_bgn(term, "#"))
|
if (String_.Has_at_bgn(term, "#"))
|
||||||
cur = Int_.parse_(String_.Mid(term, 1));
|
cur = Int_.parse(String_.Mid(term, 1));
|
||||||
else
|
else
|
||||||
cur = Int_.cast_(rawRegy.Get_by(term));
|
cur = Int_.cast(rawRegy.Get_by(term));
|
||||||
rv |= cur;
|
rv |= cur;
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -22,7 +22,7 @@ public class Io_url_ {
|
|||||||
public static final Io_url NullPtr = null;
|
public static final Io_url NullPtr = null;
|
||||||
public static final Io_url Parser = new Io_url("", IoUrlInfo_.Nil);
|
public static final Io_url Parser = new Io_url("", IoUrlInfo_.Nil);
|
||||||
public static Io_url as_(Object obj) {return obj instanceof Io_url ? (Io_url)obj : null;}
|
public static Io_url as_(Object obj) {return obj instanceof Io_url ? (Io_url)obj : null;}
|
||||||
public static Io_url cast_(Object obj) {try {return (Io_url)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, Io_url.class, obj);}}
|
public static Io_url cast(Object obj) {try {return (Io_url)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, Io_url.class, obj);}}
|
||||||
public static Io_url Usr() {
|
public static Io_url Usr() {
|
||||||
if (usr_dir == null) {
|
if (usr_dir == null) {
|
||||||
switch (Op_sys.Cur().Tid()) {
|
switch (Op_sys.Cur().Tid()) {
|
||||||
|
@ -17,15 +17,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
*/
|
*/
|
||||||
package gplx;
|
package gplx;
|
||||||
public class KeyVal implements To_str_able {
|
public class KeyVal implements To_str_able {
|
||||||
@gplx.Internal protected KeyVal(byte key_tid, Object k, Object v) {this.key_tid = key_tid; key = k; val = v;}
|
@gplx.Internal protected KeyVal(int key_tid, Object key, Object val) {this.key_tid = key_tid; this.key = key; this.val = val;}
|
||||||
public String Key() {return Object_.Xto_str_strict_or_null(key);}
|
public String Key() {return Object_.Xto_str_strict_or_null(key);}
|
||||||
public byte Key_tid() {return key_tid;} private byte key_tid;
|
public int Key_tid() {return key_tid;} private int key_tid;
|
||||||
public Object Key_as_obj() {return key;} private Object key;
|
public Object Key_as_obj() {return key;} private Object key;
|
||||||
public KeyVal Key_(Object v) {this.key = v; return this;}
|
public Object Val() {return val;} private Object val;
|
||||||
public Object Val() {return val;} public KeyVal Val_(Object v) {val = v; return this;} private Object val;
|
|
||||||
public String Val_to_str_or_empty() {return Object_.Xto_str_strict_or_empty(val);}
|
public String Val_to_str_or_empty() {return Object_.Xto_str_strict_or_empty(val);}
|
||||||
public String Val_to_str_or_null() {return Object_.Xto_str_strict_or_null(val);}
|
public String Val_to_str_or_null() {return Object_.Xto_str_strict_or_null(val);}
|
||||||
public byte[] Val_to_bry() {return Bry_.new_u8(Object_.Xto_str_strict_or_null(val));}
|
public byte[] Val_to_bry() {return Bry_.new_u8(Object_.Xto_str_strict_or_null(val));}
|
||||||
|
public KeyVal Key_(Object v) {this.key = v; return this;}
|
||||||
|
public KeyVal Val_(Object v) {this.val = v; return this;}
|
||||||
@Override public String toString() {return To_str();}
|
@Override public String toString() {return To_str();}
|
||||||
public String To_str() {return Key() + "=" + Object_.Xto_str_strict_or_null_mark(val);}
|
public String To_str() {return Key() + "=" + Object_.Xto_str_strict_or_null_mark(val);}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class KeyVal_ {
|
|||||||
rv[i] = vals[i - vals_bgn];
|
rv[i] = vals[i - vals_bgn];
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
public static String Ary_x_to_str(KeyVal... ary) {
|
public static String Ary_to_str(KeyVal... ary) {
|
||||||
String_bldr sb = String_bldr_.new_();
|
String_bldr sb = String_bldr_.new_();
|
||||||
int len = ary.length;
|
int len = ary.length;
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
@ -48,7 +48,7 @@ public class KeyVal_ {
|
|||||||
sb.Add(itm.Key()).Add("=");
|
sb.Add(itm.Key()).Add("=");
|
||||||
Object itm_val = itm.Val();
|
Object itm_val = itm.Val();
|
||||||
if (Type_adp_.Eq_typeSafe(itm_val, KeyVal[].class))
|
if (Type_adp_.Eq_typeSafe(itm_val, KeyVal[].class))
|
||||||
sb.Add(Ary_x_to_str((KeyVal[])itm_val));
|
sb.Add(Ary_to_str((KeyVal[])itm_val));
|
||||||
else
|
else
|
||||||
sb.Add(Object_.Xto_str_strict_or_null_mark(itm_val));
|
sb.Add(Object_.Xto_str_strict_or_null_mark(itm_val));
|
||||||
sb.Add_char_nl();
|
sb.Add_char_nl();
|
||||||
@ -63,12 +63,12 @@ public class KeyVal_ {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public static String Ary_xto_str_nested(KeyVal... ary) {
|
public static String Ary_to_str_nested(KeyVal... ary) {
|
||||||
Bry_bfr bfr = Bry_bfr.new_();
|
Bry_bfr bfr = Bry_bfr.new_();
|
||||||
Ary_xto_str_nested(bfr, 0, ary);
|
Ary_to_str_nested(bfr, 0, ary);
|
||||||
return bfr.Xto_str_and_clear();
|
return bfr.Xto_str_and_clear();
|
||||||
}
|
}
|
||||||
private static void Ary_xto_str_nested(Bry_bfr bfr, int indent, KeyVal[] ary) {
|
private static void Ary_to_str_nested(Bry_bfr bfr, int indent, KeyVal[] ary) {
|
||||||
int len = ary.length;
|
int len = ary.length;
|
||||||
for (int i = 0; i < len; ++i) {
|
for (int i = 0; i < len; ++i) {
|
||||||
KeyVal itm = ary[i];
|
KeyVal itm = ary[i];
|
||||||
@ -82,11 +82,11 @@ public class KeyVal_ {
|
|||||||
Class<?> val_type = Type_adp_.ClassOf_obj(val);
|
Class<?> val_type = Type_adp_.ClassOf_obj(val);
|
||||||
if (Type_adp_.Eq(val_type, KeyVal[].class)) { // val is KeyVal[]; recurse
|
if (Type_adp_.Eq(val_type, KeyVal[].class)) { // val is KeyVal[]; recurse
|
||||||
bfr.Add_byte_nl(); // add nl : "\n"
|
bfr.Add_byte_nl(); // add nl : "\n"
|
||||||
Ary_xto_str_nested(bfr, indent + 1, (KeyVal[])val);
|
Ary_to_str_nested(bfr, indent + 1, (KeyVal[])val);
|
||||||
continue; // don't add \n below
|
continue; // don't add \n below
|
||||||
}
|
}
|
||||||
else if (Type_adp_.Eq(val_type, Bool_.Cls_ref_type)) { // val is boolean
|
else if (Type_adp_.Eq(val_type, Bool_.Cls_ref_type)) { // val is boolean
|
||||||
boolean val_as_bool = Bool_.cast_(val);
|
boolean val_as_bool = Bool_.cast(val);
|
||||||
bfr.Add(val_as_bool ? Bool_.True_bry : Bool_.False_bry); // add "true" or "false"; don't call toString
|
bfr.Add(val_as_bool ? Bool_.True_bry : Bool_.False_bry); // add "true" or "false"; don't call toString
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -96,9 +96,8 @@ public class KeyVal_ {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static KeyVal as_(Object obj) {return obj instanceof KeyVal ? (KeyVal)obj : null;}
|
public static KeyVal as_(Object obj) {return obj instanceof KeyVal ? (KeyVal)obj : null;}
|
||||||
public static KeyVal new_(String key) {return new KeyVal(KeyVal_.Key_tid_str, key, key);}
|
public static KeyVal new_(String key) {return new KeyVal(Type_adp_.Tid__str, key, key);}
|
||||||
public static KeyVal new_(String key, Object val) {return new KeyVal(KeyVal_.Key_tid_str, key, val);}
|
public static KeyVal new_(String key, Object val) {return new KeyVal(Type_adp_.Tid__str, key, val);}
|
||||||
public static KeyVal int_(int key, Object val) {return new KeyVal(KeyVal_.Key_tid_int, key, val);}
|
public static KeyVal int_(int key, Object val) {return new KeyVal(Type_adp_.Tid__int, key, val);}
|
||||||
public static KeyVal obj_(Object key, Object val) {return new KeyVal(KeyVal_.Key_tid_obj, key, val);}
|
public static KeyVal obj_(Object key, Object val) {return new KeyVal(Type_adp_.Tid__obj, key, val);}
|
||||||
public static final byte Key_tid_obj = 0, Key_tid_str = 1, Key_tid_int = 2;
|
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class Math_ {
|
|||||||
public static float Abs(float val) {return val > 0 ? val : val * -1;}
|
public static float Abs(float val) {return val > 0 ? val : val * -1;}
|
||||||
public static double Abs_double(double val) {return val > 0 ? val : val * -1;}
|
public static double Abs_double(double val) {return val > 0 ? val : val * -1;}
|
||||||
public static int Log10(int val) {
|
public static int Log10(int val) {
|
||||||
if (val <= 0) return Int_.MinValue;
|
if (val <= 0) return Int_.Min_value;
|
||||||
int rv = -1, baseVal = 10;
|
int rv = -1, baseVal = 10;
|
||||||
while (val != 0) {
|
while (val != 0) {
|
||||||
val = (val / baseVal);
|
val = (val / baseVal);
|
||||||
|
@ -24,7 +24,7 @@ public class Math__tst {
|
|||||||
tst_Abs(0, 0);
|
tst_Abs(0, 0);
|
||||||
} void tst_Abs(int val, int expd) {Tfds.Eq(expd, Math_.Abs(val));}
|
} void tst_Abs(int val, int expd) {Tfds.Eq(expd, Math_.Abs(val));}
|
||||||
@Test public void Log10() {
|
@Test public void Log10() {
|
||||||
tst_Log10(0, Int_.MinValue);
|
tst_Log10(0, Int_.Min_value);
|
||||||
tst_Log10(9, 0);
|
tst_Log10(9, 0);
|
||||||
tst_Log10(10, 1);
|
tst_Log10(10, 1);
|
||||||
tst_Log10(99, 1);
|
tst_Log10(99, 1);
|
||||||
|
@ -41,13 +41,13 @@ public class TimeSpanAdp implements CompareAble, EqAble {
|
|||||||
}
|
}
|
||||||
public TimeSpanAdp Subtract(TimeSpanAdp val) {return new TimeSpanAdp(fracs - val.fracs);}
|
public TimeSpanAdp Subtract(TimeSpanAdp val) {return new TimeSpanAdp(fracs - val.fracs);}
|
||||||
|
|
||||||
public int compareTo(Object obj) {TimeSpanAdp comp = TimeSpanAdp_.cast_(obj); return CompareAble_.Compare_obj(fracs, comp.fracs);}
|
public int compareTo(Object obj) {TimeSpanAdp comp = TimeSpanAdp_.cast(obj); return CompareAble_.Compare_obj(fracs, comp.fracs);}
|
||||||
public boolean Eq(Object o) {
|
public boolean Eq(Object o) {
|
||||||
TimeSpanAdp comp = TimeSpanAdp_.cast_(o); if (comp == null) return false;
|
TimeSpanAdp comp = TimeSpanAdp_.cast(o); if (comp == null) return false;
|
||||||
return fracs == comp.fracs;
|
return fracs == comp.fracs;
|
||||||
}
|
}
|
||||||
@Override public String toString() {return To_str(TimeSpanAdp_.Fmt_Default);}
|
@Override public String toString() {return To_str(TimeSpanAdp_.Fmt_Default);}
|
||||||
@Override public boolean equals(Object obj) {TimeSpanAdp comp = TimeSpanAdp_.cast_(obj); return Object_.Eq(fracs, comp.fracs);}
|
@Override public boolean equals(Object obj) {TimeSpanAdp comp = TimeSpanAdp_.cast(obj); return Object_.Eq(fracs, comp.fracs);}
|
||||||
@Override public int hashCode() {return super.hashCode();}
|
@Override public int hashCode() {return super.hashCode();}
|
||||||
|
|
||||||
public String To_str() {return TimeSpanAdp_.To_str(fracs, TimeSpanAdp_.Fmt_Default);}
|
public String To_str() {return TimeSpanAdp_.To_str(fracs, TimeSpanAdp_.Fmt_Default);}
|
||||||
|
@ -34,8 +34,8 @@ public class TimeSpanAdp_ {
|
|||||||
return TimeSpanAdp_.fracs_(fracs);
|
return TimeSpanAdp_.fracs_(fracs);
|
||||||
}
|
}
|
||||||
public static TimeSpanAdp from_(long bgn) {return TimeSpanAdp_.fracs_(Env_.TickCount() - bgn);}
|
public static TimeSpanAdp from_(long bgn) {return TimeSpanAdp_.fracs_(Env_.TickCount() - bgn);}
|
||||||
public static final long parse_null = Long_.MinValue;
|
public static final long parse_null = Long_.Min_value;
|
||||||
public static TimeSpanAdp parse_(String raw) {
|
public static TimeSpanAdp parse(String raw) {
|
||||||
byte[] bry = Bry_.new_u8(raw);
|
byte[] bry = Bry_.new_u8(raw);
|
||||||
long fracs = parse_to_fracs(bry, 0, bry.length, false);
|
long fracs = parse_to_fracs(bry, 0, bry.length, false);
|
||||||
return fracs == parse_null ? null : TimeSpanAdp_.fracs_(fracs);
|
return fracs == parse_null ? null : TimeSpanAdp_.fracs_(fracs);
|
||||||
@ -157,6 +157,6 @@ public class TimeSpanAdp_ {
|
|||||||
@gplx.Internal protected static final int Idx_Hour = 3;
|
@gplx.Internal protected static final int Idx_Hour = 3;
|
||||||
static int[] ZeroPadding = {3, 2, 2, 2,};
|
static int[] ZeroPadding = {3, 2, 2, 2,};
|
||||||
static String[] Sprs = {".", MajorDelimiter, MajorDelimiter, "",};
|
static String[] Sprs = {".", MajorDelimiter, MajorDelimiter, "",};
|
||||||
public static TimeSpanAdp cast_(Object arg) {try {return (TimeSpanAdp)arg;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, TimeSpanAdp.class, arg);}}
|
public static TimeSpanAdp cast(Object arg) {try {return (TimeSpanAdp)arg;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, TimeSpanAdp.class, arg);}}
|
||||||
public static final double Ratio_f_to_s = 1000;
|
public static final double Ratio_f_to_s = 1000;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public class TimeSpanAdp__parse_tst {
|
|||||||
tst_Parse(" 01 : 02 : 03 . 987", 3723987); // whitespace
|
tst_Parse(" 01 : 02 : 03 . 987", 3723987); // whitespace
|
||||||
}
|
}
|
||||||
void tst_Parse(String text, long expd) {
|
void tst_Parse(String text, long expd) {
|
||||||
TimeSpanAdp val = TimeSpanAdp_.parse_(text);
|
TimeSpanAdp val = TimeSpanAdp_.parse(text);
|
||||||
Tfds.Eq(expd, val.Fracs());
|
Tfds.Eq(expd, val.Fracs());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,14 +68,14 @@ public class TimeSpanAdp_basic_tst {
|
|||||||
tst_XtoStrUiAbbrv("00:00:03.000", "3s 0f");
|
tst_XtoStrUiAbbrv("00:00:03.000", "3s 0f");
|
||||||
tst_XtoStrUiAbbrv("11:22:33.444", "11h 22m 33s 444f");
|
tst_XtoStrUiAbbrv("11:22:33.444", "11h 22m 33s 444f");
|
||||||
tst_XtoStrUiAbbrv("00:00:00.000", "0f");
|
tst_XtoStrUiAbbrv("00:00:00.000", "0f");
|
||||||
} void tst_XtoStrUiAbbrv(String raw, String expd) {Tfds.Eq(expd, TimeSpanAdp_.parse_(raw).XtoStrUiAbbrv());}
|
} void tst_XtoStrUiAbbrv(String raw, String expd) {Tfds.Eq(expd, TimeSpanAdp_.parse(raw).XtoStrUiAbbrv());}
|
||||||
void tst_AddUnit(String valRaw, int unitIdx, int delta, String expdRaw) {
|
void tst_AddUnit(String valRaw, int unitIdx, int delta, String expdRaw) {
|
||||||
TimeSpanAdp val = TimeSpanAdp_.parse_(valRaw);
|
TimeSpanAdp val = TimeSpanAdp_.parse(valRaw);
|
||||||
TimeSpanAdp actl = val.Add_unit(unitIdx, delta);
|
TimeSpanAdp actl = val.Add_unit(unitIdx, delta);
|
||||||
Tfds.Eq(TimeSpanAdp_.parse_(expdRaw), actl);
|
Tfds.Eq(TimeSpanAdp_.parse(expdRaw), actl);
|
||||||
}
|
}
|
||||||
void tst_Units(String text, int... expd) {
|
void tst_Units(String text, int... expd) {
|
||||||
TimeSpanAdp val = TimeSpanAdp_.parse_(text);
|
TimeSpanAdp val = TimeSpanAdp_.parse(text);
|
||||||
int hour = 0, min = 0, sec = 0, frac = 0;
|
int hour = 0, min = 0, sec = 0, frac = 0;
|
||||||
int[] ary = val.Units();
|
int[] ary = val.Units();
|
||||||
hour = ary[TimeSpanAdp_.Idx_Hour]; min = ary[TimeSpanAdp_.Idx_Min]; sec = ary[TimeSpanAdp_.Idx_Sec]; frac = ary[TimeSpanAdp_.Idx_Frac];
|
hour = ary[TimeSpanAdp_.Idx_Hour]; min = ary[TimeSpanAdp_.Idx_Min]; sec = ary[TimeSpanAdp_.Idx_Sec]; frac = ary[TimeSpanAdp_.Idx_Frac];
|
||||||
|
@ -52,7 +52,7 @@ public class TimeSpanAdp_xtoStr_tst {
|
|||||||
Tfds.Eq(expd, actl);
|
Tfds.Eq(expd, actl);
|
||||||
}
|
}
|
||||||
void tst_ZeroPadding(String val, String expd) {
|
void tst_ZeroPadding(String val, String expd) {
|
||||||
TimeSpanAdp timeSpan = TimeSpanAdp_.parse_(val);
|
TimeSpanAdp timeSpan = TimeSpanAdp_.parse(val);
|
||||||
String actl = timeSpan.To_str(TimeSpanAdp_.Fmt_PadZeros);
|
String actl = timeSpan.To_str(TimeSpanAdp_.Fmt_PadZeros);
|
||||||
Tfds.Eq(expd, actl);
|
Tfds.Eq(expd, actl);
|
||||||
}
|
}
|
||||||
|
@ -606,7 +606,7 @@ public class Bry_ {
|
|||||||
else return new byte[] {b3};
|
else return new byte[] {b3};
|
||||||
}
|
}
|
||||||
public static boolean To_bool_by_int(byte[] ary) {
|
public static boolean To_bool_by_int(byte[] ary) {
|
||||||
int rv = To_int_or(ary, null, 0, ary.length, Int_.MinValue);
|
int rv = To_int_or(ary, null, 0, ary.length, Int_.Min_value);
|
||||||
switch (rv) {
|
switch (rv) {
|
||||||
case 0: return false;
|
case 0: return false;
|
||||||
case 1: return true;
|
case 1: return true;
|
||||||
@ -615,8 +615,8 @@ public class Bry_ {
|
|||||||
}
|
}
|
||||||
public static byte To_int_as_byte(byte[] ary, int bgn, int end, byte or) {return (byte)To_int_or(ary, bgn, end, or);}
|
public static byte To_int_as_byte(byte[] ary, int bgn, int end, byte or) {return (byte)To_int_or(ary, bgn, end, or);}
|
||||||
public static int To_int(byte[] ary) {
|
public static int To_int(byte[] ary) {
|
||||||
int rv = To_int_or(ary, null, 0, ary.length, Int_.MinValue);
|
int rv = To_int_or(ary, null, 0, ary.length, Int_.Min_value);
|
||||||
if (rv == Int_.MinValue) throw Err_.new_wo_type("could not parse to int", "val", String_.new_u8(ary));
|
if (rv == Int_.Min_value) throw Err_.new_wo_type("could not parse to int", "val", String_.new_u8(ary));
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
public static int To_int_or_neg1(byte[] ary) {return To_int_or(ary, null, 0, ary.length, -1);}
|
public static int To_int_or_neg1(byte[] ary) {return To_int_or(ary, null, 0, ary.length, -1);}
|
||||||
@ -741,10 +741,10 @@ public class Bry_ {
|
|||||||
}
|
}
|
||||||
return To_int_or(ary, bgn, end_num, or);
|
return To_int_or(ary, bgn, end_num, or);
|
||||||
}
|
}
|
||||||
public static double To_double(byte[] ary, int bgn, int end) {return Double_.parse_(String_.new_u8(ary, bgn, end));}
|
public static double To_double(byte[] ary, int bgn, int end) {return Double_.parse(String_.new_u8(ary, bgn, end));}
|
||||||
public static double To_double_or(byte[] bry, double or) {return Double_.parse_or(String_.new_u8(bry, 0, bry.length), or);}
|
public static double To_double_or(byte[] bry, double or) {return Double_.parse_or(String_.new_u8(bry, 0, bry.length), or);}
|
||||||
public static double To_double_or(byte[] ary, int bgn, int end, double or) {return Double_.parse_or(String_.new_u8(ary, bgn, end), or);}
|
public static double To_double_or(byte[] ary, int bgn, int end, double or) {return Double_.parse_or(String_.new_u8(ary, bgn, end), or);}
|
||||||
public static Decimal_adp To_decimal(byte[] ary, int bgn, int end) {return Decimal_adp_.parse_(String_.new_u8(ary, bgn, end));}
|
public static Decimal_adp To_decimal(byte[] ary, int bgn, int end) {return Decimal_adp_.parse(String_.new_u8(ary, bgn, end));}
|
||||||
public static final byte Dlm_fld = (byte)'|', Dlm_row = (byte)'\n', Dlm_quote = (byte)'"', Dlm_null = 0, Ascii_zero = 48;
|
public static final byte Dlm_fld = (byte)'|', Dlm_row = (byte)'\n', Dlm_quote = (byte)'"', Dlm_null = 0, Ascii_zero = 48;
|
||||||
public static final String Fmt_csvDte = "yyyyMMdd HHmmss.fff";
|
public static final String Fmt_csvDte = "yyyyMMdd HHmmss.fff";
|
||||||
public static DateAdp ReadCsvDte(byte[] ary, Int_obj_ref posRef, byte lkp) {// ASSUME: fmt = yyyyMMdd HHmmss.fff
|
public static DateAdp ReadCsvDte(byte[] ary, Int_obj_ref posRef, byte lkp) {// ASSUME: fmt = yyyyMMdd HHmmss.fff
|
||||||
@ -880,7 +880,7 @@ public class Bry_ {
|
|||||||
return Replace(bfr, src, find, repl, 0, src.length);
|
return Replace(bfr, src, find, repl, 0, src.length);
|
||||||
}
|
}
|
||||||
public static byte[] Replace(Bry_bfr bfr, byte[] src, byte[] find, byte[] repl) {return Replace(bfr, src, find, repl, 0, src.length);}
|
public static byte[] Replace(Bry_bfr bfr, byte[] src, byte[] find, byte[] repl) {return Replace(bfr, src, find, repl, 0, src.length);}
|
||||||
public static byte[] Replace(Bry_bfr bfr, byte[] src, byte[] find, byte[] repl, int src_bgn, int src_end) {return Replace(bfr, src, find, repl, src_bgn, src_end, Int_.MaxValue);}
|
public static byte[] Replace(Bry_bfr bfr, byte[] src, byte[] find, byte[] repl, int src_bgn, int src_end) {return Replace(bfr, src, find, repl, src_bgn, src_end, Int_.Max_value);}
|
||||||
public static byte[] Replace(Bry_bfr bfr, byte[] src, byte[] find, byte[] repl, int src_bgn, int src_end, int limit) {
|
public static byte[] Replace(Bry_bfr bfr, byte[] src, byte[] find, byte[] repl, int src_bgn, int src_end, int limit) {
|
||||||
int pos = src_bgn;
|
int pos = src_bgn;
|
||||||
boolean dirty = false;
|
boolean dirty = false;
|
@ -37,7 +37,7 @@ public class Bry__tst {
|
|||||||
tst_XtoStrBytesByInt(10, 1, 0);
|
tst_XtoStrBytesByInt(10, 1, 0);
|
||||||
tst_XtoStrBytesByInt(321, 3, 2, 1);
|
tst_XtoStrBytesByInt(321, 3, 2, 1);
|
||||||
tst_XtoStrBytesByInt(-321, Bry_.Byte_NegSign, 3, 2, 1);
|
tst_XtoStrBytesByInt(-321, Bry_.Byte_NegSign, 3, 2, 1);
|
||||||
tst_XtoStrBytesByInt(Int_.MaxValue, 2,1,4,7,4,8,3,6,4,7);
|
tst_XtoStrBytesByInt(Int_.Max_value, 2,1,4,7,4,8,3,6,4,7);
|
||||||
}
|
}
|
||||||
void tst_XtoStrBytesByInt(int val, int... expdAryAsInt) {
|
void tst_XtoStrBytesByInt(int val, int... expdAryAsInt) {
|
||||||
byte[] expd = new byte[expdAryAsInt.length];
|
byte[] expd = new byte[expdAryAsInt.length];
|
||||||
@ -101,11 +101,11 @@ public class Bry__tst {
|
|||||||
@Test public void XtoInt() {
|
@Test public void XtoInt() {
|
||||||
tst_XtoInt("1", 1);
|
tst_XtoInt("1", 1);
|
||||||
tst_XtoInt("123", 123);
|
tst_XtoInt("123", 123);
|
||||||
tst_XtoInt("a", Int_.MinValue, Int_.MinValue);
|
tst_XtoInt("a", Int_.Min_value, Int_.Min_value);
|
||||||
tst_XtoInt("-1", Int_.MinValue, -1);
|
tst_XtoInt("-1", Int_.Min_value, -1);
|
||||||
tst_XtoInt("-123", Int_.MinValue, -123);
|
tst_XtoInt("-123", Int_.Min_value, -123);
|
||||||
tst_XtoInt("123-1", Int_.MinValue, Int_.MinValue);
|
tst_XtoInt("123-1", Int_.Min_value, Int_.Min_value);
|
||||||
tst_XtoInt("+123", Int_.MinValue, 123);
|
tst_XtoInt("+123", Int_.Min_value, 123);
|
||||||
tst_XtoInt("", -1);
|
tst_XtoInt("", -1);
|
||||||
}
|
}
|
||||||
void tst_XtoInt(String val, int expd) {tst_XtoInt(val, -1, expd);}
|
void tst_XtoInt(String val, int expd) {tst_XtoInt(val, -1, expd);}
|
||||||
@ -135,7 +135,7 @@ public class Bry__tst {
|
|||||||
} void tst_ReadCsvDte(String raw) {Tfds.Eq_date(DateAdp_.parse_fmt(raw, Bry_.Fmt_csvDte), Bry_.ReadCsvDte(Bry_.new_u8(raw + "|"), Int_obj_ref.zero_(), (byte)'|'));}
|
} void tst_ReadCsvDte(String raw) {Tfds.Eq_date(DateAdp_.parse_fmt(raw, Bry_.Fmt_csvDte), Bry_.ReadCsvDte(Bry_.new_u8(raw + "|"), Int_obj_ref.zero_(), (byte)'|'));}
|
||||||
@Test public void ReadCsvInt() {
|
@Test public void ReadCsvInt() {
|
||||||
tst_ReadCsvInt("1234567890");
|
tst_ReadCsvInt("1234567890");
|
||||||
} void tst_ReadCsvInt(String raw) {Tfds.Eq(Int_.parse_(raw), Bry_.ReadCsvInt(Bry_.new_u8(raw + "|"), Int_obj_ref.zero_(), (byte)'|'));}
|
} void tst_ReadCsvInt(String raw) {Tfds.Eq(Int_.parse(raw), Bry_.ReadCsvInt(Bry_.new_u8(raw + "|"), Int_obj_ref.zero_(), (byte)'|'));}
|
||||||
@Test public void Trim() {
|
@Test public void Trim() {
|
||||||
Trim_tst("a b c", 1, 4, "b");
|
Trim_tst("a b c", 1, 4, "b");
|
||||||
Trim_tst("a c", 1, 3, "");
|
Trim_tst("a c", 1, 3, "");
|
@ -218,7 +218,7 @@ public class Bry_bfr {
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < arySlots; i++) {
|
for (int i = 0; i < arySlots; i++) {
|
||||||
int logIdx = arySlots - i - 1;
|
int logIdx = arySlots - i - 1;
|
||||||
int div = logIdx < Int_.Log10AryLen ? Int_.Log10Ary[logIdx] : Int_.MaxValue;
|
int div = logIdx < Int_.Log10AryLen ? Int_.Log10Ary[logIdx] : Int_.Max_value;
|
||||||
bfr[aryBgn + i] = (byte)((val / div) + 48);
|
bfr[aryBgn + i] = (byte)((val / div) + 48);
|
||||||
val %= div;
|
val %= div;
|
||||||
}
|
}
|
||||||
@ -240,7 +240,7 @@ public class Bry_bfr {
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < arySlots; i++) {
|
for (int i = 0; i < arySlots; i++) {
|
||||||
int logIdx = arySlots - i - 1;
|
int logIdx = arySlots - i - 1;
|
||||||
long div = logIdx < Long_.Log10Ary_len ? Long_.Log10Ary[logIdx] : Long_.MaxValue;
|
long div = logIdx < Long_.Log10Ary_len ? Long_.Log10Ary[logIdx] : Long_.Max_value;
|
||||||
bfr[aryBgn + i] = (byte)((val / div) + 48);
|
bfr[aryBgn + i] = (byte)((val / div) + 48);
|
||||||
val %= div;
|
val %= div;
|
||||||
}
|
}
|
||||||
@ -393,16 +393,16 @@ public class Bry_bfr {
|
|||||||
if (o == null) return this; // treat null as empty String;
|
if (o == null) return this; // treat null as empty String;
|
||||||
Class<?> o_type = o.getClass();
|
Class<?> o_type = o.getClass();
|
||||||
if (o_type == byte[].class) Add((byte[])o);
|
if (o_type == byte[].class) Add((byte[])o);
|
||||||
else if (o_type == Integer.class) Add_int_variable(Int_.cast_(o));
|
else if (o_type == Integer.class) Add_int_variable(Int_.cast(o));
|
||||||
else if (o_type == Byte.class) Add_byte(Byte_.cast_(o));
|
else if (o_type == Byte.class) Add_byte(Byte_.cast(o));
|
||||||
else if (o_type == Long.class) Add_long_variable(Long_.cast_(o));
|
else if (o_type == Long.class) Add_long_variable(Long_.cast(o));
|
||||||
else if (o_type == String.class) Add_str((String)o);
|
else if (o_type == String.class) Add_str((String)o);
|
||||||
else if (o_type == Bry_bfr.class) Add_bfr_and_preserve((Bry_bfr)o);
|
else if (o_type == Bry_bfr.class) Add_bfr_and_preserve((Bry_bfr)o);
|
||||||
else if (o_type == DateAdp.class) Add_dte((DateAdp)o);
|
else if (o_type == DateAdp.class) Add_dte((DateAdp)o);
|
||||||
else if (o_type == Io_url.class) Add(((Io_url)o).RawBry());
|
else if (o_type == Io_url.class) Add(((Io_url)o).RawBry());
|
||||||
else if (o_type == Boolean.class) Add_yn(Bool_.cast_(o));
|
else if (o_type == Boolean.class) Add_yn(Bool_.cast(o));
|
||||||
else if (o_type == Double.class) Add_double(Double_.cast_(o));
|
else if (o_type == Double.class) Add_double(Double_.cast(o));
|
||||||
else if (o_type == Float.class) Add_float(Float_.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).XferAry(this, 0);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -410,16 +410,16 @@ public class Bry_bfr {
|
|||||||
if (o == null) return this; // treat null as empty String;
|
if (o == null) return this; // treat null as empty String;
|
||||||
Class<?> o_type = o.getClass();
|
Class<?> o_type = o.getClass();
|
||||||
if (o_type == byte[].class) Add((byte[])o);
|
if (o_type == byte[].class) Add((byte[])o);
|
||||||
else if (o_type == Integer.class) Add_int_variable(Int_.cast_(o));
|
else if (o_type == Integer.class) Add_int_variable(Int_.cast(o));
|
||||||
else if (o_type == Byte.class) Add_byte(Byte_.cast_(o));
|
else if (o_type == Byte.class) Add_byte(Byte_.cast(o));
|
||||||
else if (o_type == Long.class) Add_long_variable(Long_.cast_(o));
|
else if (o_type == Long.class) Add_long_variable(Long_.cast(o));
|
||||||
else if (o_type == String.class) Add_str((String)o);
|
else if (o_type == String.class) Add_str((String)o);
|
||||||
else if (o_type == Bry_bfr.class) Add_bfr_and_preserve((Bry_bfr)o);
|
else if (o_type == Bry_bfr.class) Add_bfr_and_preserve((Bry_bfr)o);
|
||||||
else if (o_type == DateAdp.class) Add_dte((DateAdp)o);
|
else if (o_type == DateAdp.class) Add_dte((DateAdp)o);
|
||||||
else if (o_type == Io_url.class) Add(((Io_url)o).RawBry());
|
else if (o_type == Io_url.class) Add(((Io_url)o).RawBry());
|
||||||
else if (o_type == Boolean.class) Add_bool(Bool_.cast_(o));
|
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 == Double.class) Add_double(Double_.cast(o));
|
||||||
else if (o_type == Float.class) Add_float(Float_.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).XferAry(this, 0);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -533,7 +533,7 @@ public class Bry_bfr {
|
|||||||
if (!Byte_ascii.Is_num(b)) return or;
|
if (!Byte_ascii.Is_num(b)) return or;
|
||||||
long dif = (b - Byte_ascii.Num_0 ) * mult;
|
long dif = (b - Byte_ascii.Num_0 ) * mult;
|
||||||
long new_val = rv + dif;
|
long new_val = rv + dif;
|
||||||
if (new_val > Int_.MaxValue) return or; // if number is > 2^32 consider error (int overflow); return or; DATE:2014-06-10
|
if (new_val > Int_.Max_value) return or; // if number is > 2^32 consider error (int overflow); return or; DATE:2014-06-10
|
||||||
rv = new_val;
|
rv = new_val;
|
||||||
mult *= 10;
|
mult *= 10;
|
||||||
}
|
}
|
@ -64,12 +64,12 @@ public class Bry_bfr_tst {
|
|||||||
}
|
}
|
||||||
void tst_Add_float(float v) {
|
void tst_Add_float(float v) {
|
||||||
bb.Add_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.Xto_bry())));
|
||||||
}
|
}
|
||||||
void Add_int_variable(int val) {
|
void Add_int_variable(int val) {
|
||||||
bb.Clear();
|
bb.Clear();
|
||||||
bb.Add_int_variable(val);
|
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.Xto_bry())));
|
||||||
}
|
}
|
||||||
@Test public void Add_int_fixed_len3() {tst_Add_int_fixed(123, 3, "123");}
|
@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");}
|
@Test public void Add_int_fixed_pad_1() {tst_Add_int_fixed(2, 1, "2");}
|
||||||
@ -137,12 +137,12 @@ public class Bry_bfr_tst {
|
|||||||
}
|
}
|
||||||
@Test public void XtoInt() {
|
@Test public void XtoInt() {
|
||||||
tst_XtoInt("123", 123);
|
tst_XtoInt("123", 123);
|
||||||
tst_XtoInt("a", Int_.MinValue);
|
tst_XtoInt("a", Int_.Min_value);
|
||||||
tst_XtoInt("9999999999", Int_.MinValue);
|
tst_XtoInt("9999999999", Int_.Min_value);
|
||||||
}
|
}
|
||||||
void tst_XtoInt(String raw, int expd) {
|
void tst_XtoInt(String raw, int expd) {
|
||||||
bb.Add_str(raw);
|
bb.Add_str(raw);
|
||||||
Tfds.Eq(expd, bb.XtoIntAndClear(Int_.MinValue));
|
Tfds.Eq(expd, bb.XtoIntAndClear(Int_.Min_value));
|
||||||
}
|
}
|
||||||
static long Pow38_to(int year, int month, int day, int hour, int minute, int second, int frac) {
|
static long Pow38_to(int year, int month, int day, int hour, int minute, int second, int frac) {
|
||||||
return ((long)year) << 26
|
return ((long)year) << 26
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
*/
|
*/
|
||||||
package gplx.brys; import gplx.*;
|
package gplx.brys; import gplx.*;
|
||||||
public class Bry_fmtr_arg_int implements Bry_fmtr_arg {
|
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 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 XferAry(Bry_bfr trg, int idx) {trg.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;
|
public Bry_fmtr_arg_int(int v) {this.val = v; this.val_digits = Int_.DigitCount(v);} int val, val_digits;
|
||||||
}
|
}
|
@ -161,7 +161,7 @@ public class List_adp_tst {
|
|||||||
list.Shuffle();
|
list.Shuffle();
|
||||||
int hasMovedCount = 0;
|
int hasMovedCount = 0;
|
||||||
for (int i = 0; i < list.Count(); i++) {
|
for (int i = 0; i < list.Count(); i++) {
|
||||||
int val = Int_.cast_(list.Get_at(i));
|
int val = Int_.cast(list.Get_at(i));
|
||||||
if (val != i) hasMovedCount++;
|
if (val != i) hasMovedCount++;
|
||||||
}
|
}
|
||||||
Tfds.Eq_true(hasMovedCount > 0, "all documents have the same index"); // NOTE: may still fail occasionally (1%)
|
Tfds.Eq_true(hasMovedCount > 0, "all documents have the same index"); // NOTE: may still fail occasionally (1%)
|
||||||
|
@ -53,8 +53,8 @@ public class Utf16_ {
|
|||||||
public static byte[] Encode_hex_to_bry(String raw) {return Encode_hex_to_bry(Bry_.new_a7(raw));}
|
public static byte[] Encode_hex_to_bry(String raw) {return Encode_hex_to_bry(Bry_.new_a7(raw));}
|
||||||
public static byte[] Encode_hex_to_bry(byte[] raw) {
|
public static byte[] Encode_hex_to_bry(byte[] raw) {
|
||||||
if (raw == null) return null;
|
if (raw == null) return null;
|
||||||
int int_val = gplx.texts.HexDecUtl.parse_or_(raw, Int_.MinValue);
|
int int_val = gplx.texts.HexDecUtl.parse_or(raw, Int_.Min_value);
|
||||||
return int_val == Int_.MinValue ? null : Encode_int_to_bry(int_val);
|
return int_val == Int_.Min_value ? null : Encode_int_to_bry(int_val);
|
||||||
}
|
}
|
||||||
public static byte[] Encode_int_to_bry(int c) {
|
public static byte[] Encode_int_to_bry(int c) {
|
||||||
int bry_len = Len_by_int(c);
|
int bry_len = Len_by_int(c);
|
||||||
|
@ -75,7 +75,7 @@ public class Utf8_ {
|
|||||||
}
|
}
|
||||||
int cur_char = Utf16_.Decode_to_int(bry, cur_char_pos0);
|
int cur_char = Utf16_.Decode_to_int(bry, cur_char_pos0);
|
||||||
nxt_char = Increment_char(cur_char);
|
nxt_char = Increment_char(cur_char);
|
||||||
if (nxt_char != Int_.MinValue) {
|
if (nxt_char != Int_.Min_value) {
|
||||||
byte[] nxt_char_as_bry = Utf16_.Encode_int_to_bry(nxt_char);
|
byte[] nxt_char_as_bry = Utf16_.Encode_int_to_bry(nxt_char);
|
||||||
bry = Bry_.Add(Bry_.Mid(bry, 0, cur_char_pos0), nxt_char_as_bry);
|
bry = Bry_.Add(Bry_.Mid(bry, 0, cur_char_pos0), nxt_char_as_bry);
|
||||||
return bry;
|
return bry;
|
||||||
@ -104,7 +104,7 @@ public class Utf8_ {
|
|||||||
if (!Codepoint_valid(cur)) continue;
|
if (!Codepoint_valid(cur)) continue;
|
||||||
return cur;
|
return cur;
|
||||||
}
|
}
|
||||||
return Int_.MinValue;
|
return Int_.Min_value;
|
||||||
}
|
}
|
||||||
private static boolean Codepoint_valid(int v) {
|
private static boolean Codepoint_valid(int v) {
|
||||||
return Character.isDefined(v);
|
return Character.isDefined(v);
|
||||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
*/
|
*/
|
||||||
package gplx.texts; import gplx.*;
|
package gplx.texts; import gplx.*;
|
||||||
public class HexDecUtl {
|
public class HexDecUtl {
|
||||||
public static int parse_or_(String raw, int or) {
|
public static int parse_or(String raw, int or) {
|
||||||
int rv = 0; int digit; int factor = 1, rawLen = String_.Len(raw);
|
int rv = 0; int digit; int factor = 1, rawLen = String_.Len(raw);
|
||||||
for (int i = rawLen - 1; i >= 0; i--) {
|
for (int i = rawLen - 1; i >= 0; i--) {
|
||||||
digit = XtoInt(String_.CharAt(raw, i));
|
digit = XtoInt(String_.CharAt(raw, i));
|
||||||
@ -27,8 +27,8 @@ public class HexDecUtl {
|
|||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
public static int parse_or_(byte[] raw, int or) {return parse_or_(raw, 0, raw.length, or);}
|
public static int parse_or(byte[] raw, int or) {return parse_or(raw, 0, raw.length, or);}
|
||||||
public static int parse_or_(byte[] raw, int bgn, int end, int or) {
|
public static int parse_or(byte[] raw, int bgn, int end, int or) {
|
||||||
int rv = 0; int factor = 1;
|
int rv = 0; int factor = 1;
|
||||||
byte b = Byte_.Max_value_127;
|
byte b = Byte_.Max_value_127;
|
||||||
for (int i = end - 1; i >= bgn; i--) {
|
for (int i = end - 1; i >= bgn; i--) {
|
||||||
@ -45,8 +45,8 @@ public class HexDecUtl {
|
|||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
public static int parse_(String raw) {
|
public static int parse(String raw) {
|
||||||
int rv = parse_or_(raw, -1); if (rv == -1) throw Err_.new_parse("HexDec", "raw");
|
int rv = parse_or(raw, -1); if (rv == -1) throw Err_.new_parse("HexDec", "raw");
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
public static String To_str(int val, int pad) {
|
public static String To_str(int val, int pad) {
|
||||||
|
@ -27,7 +27,7 @@ public class HexDecUtl_tst {
|
|||||||
tst_XtoInt("FF", 255);
|
tst_XtoInt("FF", 255);
|
||||||
tst_XtoInt("100", 256);
|
tst_XtoInt("100", 256);
|
||||||
tst_XtoInt("0a", 10);
|
tst_XtoInt("0a", 10);
|
||||||
tst_XtoInt("7FFFFFFF", Int_.MaxValue);
|
tst_XtoInt("7FFFFFFF", Int_.Max_value);
|
||||||
tst_XtoInt_bry("100", 256);
|
tst_XtoInt_bry("100", 256);
|
||||||
}
|
}
|
||||||
@Test public void To_str() {
|
@Test public void To_str() {
|
||||||
@ -36,7 +36,7 @@ public class HexDecUtl_tst {
|
|||||||
tst_XtoStr(16, "10");
|
tst_XtoStr(16, "10");
|
||||||
tst_XtoStr(32, "20");
|
tst_XtoStr(32, "20");
|
||||||
tst_XtoStr(255, "FF");
|
tst_XtoStr(255, "FF");
|
||||||
tst_XtoStr(Int_.MaxValue, "7FFFFFFF");
|
tst_XtoStr(Int_.Max_value, "7FFFFFFF");
|
||||||
|
|
||||||
tst_XtoStr(15, 2, "0F");
|
tst_XtoStr(15, 2, "0F");
|
||||||
tst_XtoStr(15, 3, "00F");
|
tst_XtoStr(15, 3, "00F");
|
||||||
@ -51,10 +51,10 @@ public class HexDecUtl_tst {
|
|||||||
Tfds.Eq(expd, String_.new_a7(bry));
|
Tfds.Eq(expd, String_.new_a7(bry));
|
||||||
}
|
}
|
||||||
private void tst_XtoInt(String raw, int expd) {
|
private void tst_XtoInt(String raw, int expd) {
|
||||||
int actl = HexDecUtl.parse_(raw);
|
int actl = HexDecUtl.parse(raw);
|
||||||
Tfds.Eq(expd, actl);
|
Tfds.Eq(expd, actl);
|
||||||
}
|
}
|
||||||
private void tst_XtoInt_bry(String raw, int expd) {Tfds.Eq(expd, HexDecUtl.parse_or_(Bry_.new_a7(raw), -1));}
|
private void tst_XtoInt_bry(String raw, int expd) {Tfds.Eq(expd, HexDecUtl.parse_or(Bry_.new_a7(raw), -1));}
|
||||||
private void tst_XtoStr(int val, String expd) {tst_XtoStr(val, 0, expd);}
|
private void tst_XtoStr(int val, String expd) {tst_XtoStr(val, 0, expd);}
|
||||||
private void tst_XtoStr(int val, int pad, String expd) {
|
private void tst_XtoStr(int val, int pad, String expd) {
|
||||||
String actl = HexDecUtl.To_str(val, pad);
|
String actl = HexDecUtl.To_str(val, pad);
|
||||||
|
@ -20,11 +20,11 @@ import gplx.core.strings.*; import gplx.core.regxs.*;
|
|||||||
public class RegxPatn_cls_ioMatch_ {
|
public class RegxPatn_cls_ioMatch_ {
|
||||||
public static final String Wildcard = "*";
|
public static final String Wildcard = "*";
|
||||||
public static final String OrDelimiter = "|";
|
public static final String OrDelimiter = "|";
|
||||||
public static final RegxPatn_cls_ioMatch All = RegxPatn_cls_ioMatch_.parse_(Wildcard, false);
|
public static final RegxPatn_cls_ioMatch All = RegxPatn_cls_ioMatch_.parse(Wildcard, false);
|
||||||
public static final String ImpossiblePath = "<>"; //"<>" should be an impossible url; NOTE: do not pick * or | or : or \
|
public static final String ImpossiblePath = "<>"; //"<>" should be an impossible url; NOTE: do not pick * or | or : or \
|
||||||
public static final RegxPatn_cls_ioMatch None = RegxPatn_cls_ioMatch_.parse_(RegxPatn_cls_ioMatch_.ImpossiblePath, false);
|
public static final RegxPatn_cls_ioMatch None = RegxPatn_cls_ioMatch_.parse(RegxPatn_cls_ioMatch_.ImpossiblePath, false);
|
||||||
public static RegxPatn_cls_ioMatch cast_(Object obj) {try {return (RegxPatn_cls_ioMatch)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, RegxPatn_cls_ioMatch.class, obj);}}
|
public static RegxPatn_cls_ioMatch cast(Object obj) {try {return (RegxPatn_cls_ioMatch)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, RegxPatn_cls_ioMatch.class, obj);}}
|
||||||
public static RegxPatn_cls_ioMatch parse_(String raw, boolean caseSensitive) {
|
public static RegxPatn_cls_ioMatch parse(String raw, boolean caseSensitive) {
|
||||||
String compiled = RegxPatn_cls_ioMatch_.Compile(raw);
|
String compiled = RegxPatn_cls_ioMatch_.Compile(raw);
|
||||||
return new RegxPatn_cls_ioMatch(raw, compiled, caseSensitive);
|
return new RegxPatn_cls_ioMatch(raw, compiled, caseSensitive);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public class RegxPatn_cls_ioMatch_tst {
|
|||||||
tst_Matches("file.cs", "File.cS", true); // pass: diff case
|
tst_Matches("file.cs", "File.cS", true); // pass: diff case
|
||||||
}
|
}
|
||||||
void tst_Matches(String regx, String raw, boolean expd) {
|
void tst_Matches(String regx, String raw, boolean expd) {
|
||||||
RegxPatn_cls_ioMatch pattern = RegxPatn_cls_ioMatch_.parse_(regx, false);
|
RegxPatn_cls_ioMatch pattern = RegxPatn_cls_ioMatch_.parse(regx, false);
|
||||||
boolean actl = pattern.Matches(raw);
|
boolean actl = pattern.Matches(raw);
|
||||||
Tfds.Eq(expd, actl);
|
Tfds.Eq(expd, actl);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
package gplx.texts; import gplx.*;
|
package gplx.texts; import gplx.*;
|
||||||
import gplx.core.strings.*; import gplx.core.regxs.*;
|
import gplx.core.strings.*; import gplx.core.regxs.*;
|
||||||
public class RegxPatn_cls_like_ {
|
public class RegxPatn_cls_like_ {
|
||||||
public static RegxPatn_cls_like parse_(String regxRaw, char escape) {
|
public static RegxPatn_cls_like parse(String regxRaw, char escape) {
|
||||||
String regx = Compile(regxRaw, escape);
|
String regx = Compile(regxRaw, escape);
|
||||||
return new RegxPatn_cls_like(regxRaw, regx, escape);
|
return new RegxPatn_cls_like(regxRaw, regx, escape);
|
||||||
}
|
}
|
||||||
|
@ -74,12 +74,12 @@ public class RegxPatn_cls_like_tst {
|
|||||||
}
|
}
|
||||||
void tst_Match(String raw, String regx, boolean expd) {tst_Match(raw, regx, RegxPatn_cls_like.EscapeDefault, expd);}
|
void tst_Match(String raw, String regx, boolean expd) {tst_Match(raw, regx, RegxPatn_cls_like.EscapeDefault, expd);}
|
||||||
void tst_Match(String raw, String regx, char escape, boolean expd) {
|
void tst_Match(String raw, String regx, char escape, boolean expd) {
|
||||||
RegxPatn_cls_like like = RegxPatn_cls_like_.parse_(regx, escape);
|
RegxPatn_cls_like like = RegxPatn_cls_like_.parse(regx, escape);
|
||||||
boolean actl = like.Matches(raw);
|
boolean actl = like.Matches(raw);
|
||||||
Tfds.Eq(expd, actl, "raw={0} regx={1} expd={2}", raw, regx, expd);
|
Tfds.Eq(expd, actl, "raw={0} regx={1} expd={2}", raw, regx, expd);
|
||||||
}
|
}
|
||||||
void tst_EscapeRegxChar(char regexChar) {
|
void tst_EscapeRegxChar(char regexChar) {
|
||||||
RegxPatn_cls_like like = RegxPatn_cls_like_.parse_(Object_.Xto_str_strict_or_empty(regexChar), '|');
|
RegxPatn_cls_like like = RegxPatn_cls_like_.parse(Object_.Xto_str_strict_or_empty(regexChar), '|');
|
||||||
Tfds.Eq(true, like.Matches(Object_.Xto_str_strict_or_empty(regexChar)));
|
Tfds.Eq(true, like.Matches(Object_.Xto_str_strict_or_empty(regexChar)));
|
||||||
Tfds.Eq(false, like.Matches("a")); // catches errors for improper escaping of wildcard
|
Tfds.Eq(false, like.Matches("a")); // catches errors for improper escaping of wildcard
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
package gplx.texts; import gplx.*;
|
package gplx.texts; import gplx.*;
|
||||||
public class StringTableCol {
|
public class StringTableCol {
|
||||||
public StringTableColAlign Halign() {return halign;} public StringTableCol Halign_(StringTableColAlign val) {halign = val; return this;} StringTableColAlign halign = StringTableColAlign.Left;
|
public StringTableColAlign Halign() {return halign;} public StringTableCol Halign_(StringTableColAlign val) {halign = val; return this;} StringTableColAlign halign = StringTableColAlign.Left;
|
||||||
public int LengthMax() {return lengthMax;} int lengthMax = Int_.MinValue;
|
public int LengthMax() {return lengthMax;} int lengthMax = Int_.Min_value;
|
||||||
public int LengthMin() {return lengthMin;} int lengthMin = Int_.MaxValue;
|
public int LengthMin() {return lengthMin;} int lengthMin = Int_.Max_value;
|
||||||
public void AdjustFor(String s) {
|
public void AdjustFor(String s) {
|
||||||
int length = String_.Len(s);
|
int length = String_.Len(s);
|
||||||
if (length > lengthMax) lengthMax = length;
|
if (length > lengthMax) lengthMax = length;
|
||||||
@ -35,5 +35,5 @@ public class StringTableCol {
|
|||||||
}
|
}
|
||||||
public static StringTableCol new_() {return new StringTableCol();} StringTableCol() {}
|
public static StringTableCol new_() {return new StringTableCol();} StringTableCol() {}
|
||||||
public static StringTableCol as_(Object obj) {return obj instanceof StringTableCol ? (StringTableCol)obj : null;}
|
public static StringTableCol as_(Object obj) {return obj instanceof StringTableCol ? (StringTableCol)obj : null;}
|
||||||
public static StringTableCol cast_(Object obj) {try {return (StringTableCol)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, StringTableCol.class, obj);}}
|
public static StringTableCol cast(Object obj) {try {return (StringTableCol)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, StringTableCol.class, obj);}}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class HashAlgo_ {
|
|||||||
public static final HashAlgo Md5 = HashAlgo_md5.new_();
|
public static final HashAlgo Md5 = HashAlgo_md5.new_();
|
||||||
public static final HashAlgo Tth192 = HashAlgo_tth192.new_();
|
public static final HashAlgo Tth192 = HashAlgo_tth192.new_();
|
||||||
public static HashAlgo as_(Object obj) {return obj instanceof HashAlgo ? (HashAlgo)obj : null;}
|
public static HashAlgo as_(Object obj) {return obj instanceof HashAlgo ? (HashAlgo)obj : null;}
|
||||||
public static HashAlgo cast_(Object obj) {if (obj == null) return null; HashAlgo rv = as_(obj); if (rv == null) throw Err_.new_type_mismatch(HashAlgo.class, obj); return rv;}
|
public static HashAlgo cast(Object obj) {if (obj == null) return null; HashAlgo rv = as_(obj); if (rv == null) throw Err_.new_type_mismatch(HashAlgo.class, obj); return rv;}
|
||||||
public static HashAlgo fetch_(String key) {
|
public static HashAlgo fetch_(String key) {
|
||||||
if (key == HashAlgo_md5.KEY) return Md5;
|
if (key == HashAlgo_md5.KEY) return Md5;
|
||||||
else if (key == HashAlgo_sha1.KEY) return Sha1;
|
else if (key == HashAlgo_sha1.KEY) return Sha1;
|
||||||
|
@ -407,7 +407,7 @@ public class IoEngine_system extends IoEngine_base {
|
|||||||
src_conn = (HttpURLConnection)src_url.openConnection();
|
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
|
// src_conn.setReadTimeout(5000); // do not set; if file does not exist, will wait 5 seconds before timing out; want to fail immediately
|
||||||
String user_agent = xrg.User_agent(); if (user_agent != null) src_conn.setRequestProperty("User-Agent", user_agent);
|
String user_agent = xrg.User_agent(); if (user_agent != null) src_conn.setRequestProperty("User-Agent", user_agent);
|
||||||
long content_length = Long_.parse_or_(src_conn.getHeaderField("Content-Length"), IoItmFil.Size_invalid_int);
|
long content_length = Long_.parse_or(src_conn.getHeaderField("Content-Length"), IoItmFil.Size_invalid_int);
|
||||||
xrg.Src_content_length_(content_length);
|
xrg.Src_content_length_(content_length);
|
||||||
if (xrg.Src_last_modified_query()) // NOTE: only files will have last modified (api calls will not); if no last_modified, then src_conn will throw get nullRef; avoid nullRef
|
if (xrg.Src_last_modified_query()) // NOTE: only files will have last modified (api calls will not); if no last_modified, then src_conn will throw get nullRef; avoid nullRef
|
||||||
xrg.Src_last_modified_(DateAdp_.unixtime_lcl_ms_(src_conn.getLastModified()));
|
xrg.Src_last_modified_(DateAdp_.unixtime_lcl_ms_(src_conn.getLastModified()));
|
||||||
@ -558,7 +558,7 @@ class Io_stream_rdr_http implements Io_stream_rdr {
|
|||||||
String user_agent = xrg.User_agent();
|
String user_agent = xrg.User_agent();
|
||||||
if (user_agent != null) src_conn.setRequestProperty("User-Agent", user_agent); // NOTE: must be set right after openConnection
|
if (user_agent != null) src_conn.setRequestProperty("User-Agent", user_agent); // NOTE: must be set right after openConnection
|
||||||
// src_conn.setReadTimeout(5000); // do not set; if file does not exist, will wait 5 seconds before timing out; want to fail immediately
|
// src_conn.setReadTimeout(5000); // do not set; if file does not exist, will wait 5 seconds before timing out; want to fail immediately
|
||||||
long content_length = Long_.parse_or_(src_conn.getHeaderField("Content-Length"), IoItmFil.Size_invalid_int);
|
long content_length = Long_.parse_or(src_conn.getHeaderField("Content-Length"), IoItmFil.Size_invalid_int);
|
||||||
xrg.Src_content_length_(content_length);
|
xrg.Src_content_length_(content_length);
|
||||||
this.len = content_length;
|
this.len = content_length;
|
||||||
if (xrg.Src_last_modified_query()) // NOTE: only files will have last modified (api calls will not); if no last_modified, then src_conn will throw get nullRef; avoid nullRef
|
if (xrg.Src_last_modified_query()) // NOTE: only files will have last modified (api calls will not); if no last_modified, then src_conn will throw get nullRef; avoid nullRef
|
||||||
|
@ -32,7 +32,7 @@ public class IoEngine_xrg_queryDir {
|
|||||||
|
|
||||||
public Console_adp UsrDlg() {return usrDlg;} public IoEngine_xrg_queryDir UsrDlg_(Console_adp val) {usrDlg = val; return this;} Console_adp usrDlg = Console_adp_.Noop;
|
public Console_adp UsrDlg() {return usrDlg;} public IoEngine_xrg_queryDir UsrDlg_(Console_adp val) {usrDlg = val; return this;} Console_adp usrDlg = Console_adp_.Noop;
|
||||||
public IoEngine_xrg_queryDir FilPath_(String val) {
|
public IoEngine_xrg_queryDir FilPath_(String val) {
|
||||||
Criteria_ioMatch crt = Criteria_ioMatch.parse_(true, val, url.Info().CaseSensitive());
|
Criteria_ioMatch crt = Criteria_ioMatch.parse(true, val, url.Info().CaseSensitive());
|
||||||
filCrt = Criteria_fld.new_(IoItm_base_.Prop_Path, crt);
|
filCrt = Criteria_fld.new_(IoItm_base_.Prop_Path, crt);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,6 @@ public class IoItmClassXtn extends ClassXtn_base implements ClassXtn {
|
|||||||
else if (String_.Eq(rawLower, "fil")) return IoItmFil.Type_Fil;
|
else if (String_.Eq(rawLower, "fil")) return IoItmFil.Type_Fil;
|
||||||
else throw Err_.new_unhandled(raw);
|
else throw Err_.new_unhandled(raw);
|
||||||
}
|
}
|
||||||
@Override public Object XtoDb(Object obj) {return Int_.cast_(obj);}
|
@Override public Object XtoDb(Object obj) {return Int_.cast(obj);}
|
||||||
public static final IoItmClassXtn _ = new IoItmClassXtn(); IoItmClassXtn() {}
|
public static final IoItmClassXtn _ = new IoItmClassXtn(); IoItmClassXtn() {}
|
||||||
}
|
}
|
||||||
|
@ -35,13 +35,13 @@ public class Io_size_ {
|
|||||||
String[] unit = Io_size_.Units[exp_1024];
|
String[] unit = Io_size_.Units[exp_1024];
|
||||||
return val_as_decimal.To_str(val_fmt) + " " + String_.PadBgn(unit[0], 2, unit_pad);
|
return val_as_decimal.To_str(val_fmt) + " " + String_.PadBgn(unit[0], 2, unit_pad);
|
||||||
}
|
}
|
||||||
public static long parse_or_(String raw, long or) {
|
public static long parse_or(String raw, long or) {
|
||||||
if (raw == null || raw == String_.Empty) return or;
|
if (raw == null || raw == String_.Empty) return or;
|
||||||
String[] terms = String_.Split(raw, " ");
|
String[] terms = String_.Split(raw, " ");
|
||||||
int termsLen = Array_.Len(terms); if (termsLen > 2) return or;
|
int termsLen = Array_.Len(terms); if (termsLen > 2) return or;
|
||||||
|
|
||||||
Decimal_adp val = null;
|
Decimal_adp val = null;
|
||||||
try {val = Decimal_adp_.parse_(terms[0]);} catch (Exception exc) {Err_.Noop(exc); return or;}
|
try {val = Decimal_adp_.parse(terms[0]);} catch (Exception exc) {Err_.Noop(exc); return or;}
|
||||||
|
|
||||||
int unitPow = 0;
|
int unitPow = 0;
|
||||||
if (termsLen > 1) {
|
if (termsLen > 1) {
|
||||||
@ -88,14 +88,14 @@ public class Io_size_ {
|
|||||||
public static int Load_int_(GfoMsg m) {return (int)Load_long_(m);}
|
public static int Load_int_(GfoMsg m) {return (int)Load_long_(m);}
|
||||||
public static long Load_long_(GfoMsg m) {
|
public static long Load_long_(GfoMsg m) {
|
||||||
String v = m.ReadStr("v");
|
String v = m.ReadStr("v");
|
||||||
long rv = parse_or_(v, Long_.MinValue); if (rv == Long_.MinValue) throw Err_.new_wo_type("invalid val", "val", v);
|
long rv = parse_or(v, Long_.Min_value); if (rv == Long_.Min_value) throw Err_.new_wo_type("invalid val", "val", v);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
public static String To_str_mb(long v) {return Long_.Xto_str(v / Io_mgr.Len_mb_long);}
|
public static String To_str_mb(long v) {return Long_.Xto_str(v / Io_mgr.Len_mb_long);}
|
||||||
public static long To_long_by_int_mb(int v) {return (long)v * Io_mgr.Len_mb_long;}
|
public static long To_long_by_int_mb(int v) {return (long)v * Io_mgr.Len_mb_long;}
|
||||||
public static long To_long_by_msg_mb(GfoMsg m, long cur) {
|
public static long To_long_by_msg_mb(GfoMsg m, long cur) {
|
||||||
long val = m.ReadLongOr("v", Int_.MinValue);
|
long val = m.ReadLongOr("v", Int_.Min_value);
|
||||||
return val == Int_.MinValue ? cur : (val * Io_mgr.Len_mb_long);
|
return val == Int_.Min_value ? cur : (val * Io_mgr.Len_mb_long);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class Io_size_fmtr_arg implements Bry_fmtr_arg {
|
class Io_size_fmtr_arg implements Bry_fmtr_arg {
|
||||||
|
@ -58,12 +58,12 @@ public class Io_size__tst {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
class Io_size__fxt {
|
class Io_size__fxt {
|
||||||
public void Test_XtoLong(String raw, long expd) {Tfds.Eq(expd, Io_size_.parse_or_(raw, Long_.MinValue));}
|
public void Test_XtoLong(String raw, long expd) {Tfds.Eq(expd, Io_size_.parse_or(raw, Long_.Min_value));}
|
||||||
public void Test_XtoLongFail(String raw) {
|
public void Test_XtoLongFail(String raw) {
|
||||||
long val = Io_size_.parse_or_(raw, Long_.MinValue);
|
long val = Io_size_.parse_or(raw, Long_.Min_value);
|
||||||
if (val != Long_.MinValue) Tfds.Fail("expd parse failure; raw=" + raw);
|
if (val != Long_.Min_value) Tfds.Fail("expd parse failure; raw=" + raw);
|
||||||
}
|
}
|
||||||
public void Test_Equals(String lhs, String rhs) {Tfds.Eq(Io_size_.parse_or_(lhs, Long_.MinValue), Io_size_.parse_or_(rhs, Long_.MinValue));}
|
public void Test_Equals(String lhs, String rhs) {Tfds.Eq(Io_size_.parse_or(lhs, Long_.Min_value), Io_size_.parse_or(rhs, Long_.Min_value));}
|
||||||
public void Test_XtoStr(long val, String expd) {Tfds.Eq(expd, Io_size_.To_str(val));}
|
public void Test_XtoStr(long val, String expd) {Tfds.Eq(expd, Io_size_.To_str(val));}
|
||||||
public void Test_Xto_str(long val, int exp_1024, String val_fmt, String unit_pad, boolean round_0_to_1, String expd) {Tfds.Eq(expd, Io_size_.To_str(val, exp_1024, val_fmt, unit_pad, round_0_to_1));}
|
public void Test_Xto_str(long val, int exp_1024, String val_fmt, String unit_pad, boolean round_0_to_1, String expd) {Tfds.Eq(expd, Io_size_.To_str(val, exp_1024, val_fmt, unit_pad, round_0_to_1));}
|
||||||
}
|
}
|
||||||
|
@ -34,9 +34,9 @@ class Io_stream_rdr_fxt {
|
|||||||
private java.io.InputStream stream;
|
private java.io.InputStream stream;
|
||||||
private int stream_bry_len;
|
private int stream_bry_len;
|
||||||
public void Clear() {
|
public void Clear() {
|
||||||
expd_bytes_read = Int_.MinValue;
|
expd_bytes_read = Int_.Min_value;
|
||||||
}
|
}
|
||||||
public Io_stream_rdr_fxt Expd_bytes_read(int v) {expd_bytes_read = v; return this;} private int expd_bytes_read = Int_.MinValue;
|
public Io_stream_rdr_fxt Expd_bytes_read(int v) {expd_bytes_read = v; return this;} private int expd_bytes_read = Int_.Min_value;
|
||||||
public Io_stream_rdr_fxt Init_stream(String v) {
|
public Io_stream_rdr_fxt Init_stream(String v) {
|
||||||
byte[] stream_bry = Bry_.new_a7(v);
|
byte[] stream_bry = Bry_.new_a7(v);
|
||||||
stream_bry_len = stream_bry.length;
|
stream_bry_len = stream_bry.length;
|
||||||
|
@ -42,9 +42,12 @@ public class Type_adp_ {
|
|||||||
public static String FullNameOf_type(Class<?> type) {return type.getCanonicalName();}
|
public static String FullNameOf_type(Class<?> type) {return type.getCanonicalName();}
|
||||||
public static String NameOf_type(Class<?> type) {return type.getName();}
|
public static String NameOf_type(Class<?> type) {return type.getName();}
|
||||||
public static String NameOf_obj(Object obj) {return obj == null ? String_.Null_mark : obj.getClass().getName();}
|
public static String NameOf_obj(Object obj) {return obj == null ? String_.Null_mark : obj.getClass().getName();}
|
||||||
public static int To_tid(Object o) {
|
public static int To_tid_obj(Object o) {
|
||||||
if (o == null) return Tid__null;
|
if (o == null) return Tid__null;
|
||||||
Class<?> type = o.getClass();
|
Class<?> type = o.getClass();
|
||||||
|
return To_tid_type(type);
|
||||||
|
}
|
||||||
|
public static int To_tid_type(Class<?> type) {
|
||||||
if (Type_adp_.Eq(type, Int_.Cls_ref_type)) return Tid__int;
|
if (Type_adp_.Eq(type, Int_.Cls_ref_type)) return Tid__int;
|
||||||
else if (Type_adp_.Eq(type, String_.Cls_ref_type)) return Tid__str;
|
else if (Type_adp_.Eq(type, String_.Cls_ref_type)) return Tid__str;
|
||||||
else if (Type_adp_.Eq(type, byte[].class)) return Tid__bry;
|
else if (Type_adp_.Eq(type, byte[].class)) return Tid__bry;
|
||||||
@ -55,6 +58,7 @@ public class Type_adp_ {
|
|||||||
else if (Type_adp_.Eq(type, Decimal_adp_.Cls_ref_type)) return Tid__decimal;
|
else if (Type_adp_.Eq(type, Decimal_adp_.Cls_ref_type)) return Tid__decimal;
|
||||||
else if (Type_adp_.Eq(type, DateAdp_.Cls_ref_type)) return Tid__date;
|
else if (Type_adp_.Eq(type, DateAdp_.Cls_ref_type)) return Tid__date;
|
||||||
else if (Type_adp_.Eq(type, Float_.Cls_ref_type)) return Tid__float;
|
else if (Type_adp_.Eq(type, Float_.Cls_ref_type)) return Tid__float;
|
||||||
|
else if (Type_adp_.Eq(type, Short_.Cls_ref_type)) return Tid__short;
|
||||||
else if (Type_adp_.Eq(type, Char_.Cls_ref_type)) return Tid__char;
|
else if (Type_adp_.Eq(type, Char_.Cls_ref_type)) return Tid__char;
|
||||||
else return Tid__obj;
|
else return Tid__obj;
|
||||||
}
|
}
|
||||||
@ -63,14 +67,15 @@ public class Type_adp_ {
|
|||||||
, Tid__null = 1
|
, Tid__null = 1
|
||||||
, Tid__bool = 2
|
, Tid__bool = 2
|
||||||
, Tid__byte = 3
|
, Tid__byte = 3
|
||||||
, Tid__int = 4
|
, Tid__short = 4
|
||||||
, Tid__long = 5
|
, Tid__int = 5
|
||||||
, Tid__float = 6
|
, Tid__long = 6
|
||||||
, Tid__double = 7
|
, Tid__float = 7
|
||||||
, Tid__char = 8
|
, Tid__double = 8
|
||||||
, Tid__str = 9
|
, Tid__char = 9
|
||||||
, Tid__date = 10
|
, Tid__str = 10
|
||||||
, Tid__decimal = 11
|
, Tid__bry = 11
|
||||||
, Tid__bry = 12
|
, Tid__date = 12
|
||||||
|
, Tid__decimal = 13
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user