mirror of https://github.com/gnosygnu/xowa
parent
96636f3161
commit
d4e8590345
@ -1,45 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
public class GfoEvMgr_ {
|
||||
public static void Sub(GfoEvMgrOwner pub, String pubEvt, GfoEvObj sub, String subEvt) {pub.EvMgr().AddSub(pub, pubEvt, sub, subEvt);}
|
||||
public static void SubSame(GfoEvMgrOwner pub, String evt, GfoEvObj sub) {pub.EvMgr().AddSub(pub, evt, sub, evt);}
|
||||
public static void SubSame_many(GfoEvMgrOwner pub, GfoEvObj sub, String... evts) {
|
||||
int len = evts.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
String evt = evts[i];
|
||||
pub.EvMgr().AddSub(pub, evt, sub, evt);
|
||||
}
|
||||
}
|
||||
public static void Pub(GfoEvMgrOwner pub, String pubEvt) {pub.EvMgr().Pub(GfsCtx.new_(), pubEvt, GfoMsg_.new_cast_(pubEvt));}
|
||||
public static void PubObj(GfoEvMgrOwner pub, String pubEvt, String key, Object v) {pub.EvMgr().Pub(GfsCtx.new_(), pubEvt, msg_(pubEvt, Keyval_.new_(key, v)));}
|
||||
public static void PubVal(GfoEvMgrOwner pub, String pubEvt, Object v) {pub.EvMgr().Pub(GfsCtx.new_(), pubEvt, msg_(pubEvt, Keyval_.new_("v", v)));}
|
||||
public static void PubVals(GfoEvMgrOwner pub, String pubEvt, Keyval... ary) {pub.EvMgr().Pub(GfsCtx.new_(), pubEvt, msg_(pubEvt, ary));}
|
||||
public static void PubMsg(GfoEvMgrOwner pub, GfsCtx ctx, String pubEvt, GfoMsg m) {pub.EvMgr().Pub(ctx, pubEvt, m);}
|
||||
public static void Lnk(GfoEvMgrOwner pub, GfoEvMgrOwner sub) {sub.EvMgr().Lnk(pub);}
|
||||
public static void RlsPub(GfoEvMgrOwner pub) {pub.EvMgr().RlsPub(pub);}
|
||||
public static void RlsSub(GfoEvMgrOwner sub) {sub.EvMgr().RlsSub(sub);}
|
||||
static GfoMsg msg_(String evt, Keyval... kvAry) {
|
||||
GfoMsg m = GfoMsg_.new_cast_(evt);
|
||||
for (int i = 0; i < kvAry.length; i++) {
|
||||
Keyval kv = kvAry[i];
|
||||
m.Add(kv.Key(), kv.Val());
|
||||
}
|
||||
return m;
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
public class GfoInvkAbleCmd {
|
||||
private GfoMsg m;
|
||||
public GfoInvkAble InvkAble() {return invkAble;} private GfoInvkAble invkAble;
|
||||
public String Cmd() {return cmd;} private String cmd;
|
||||
public Object Arg() {return arg;} private Object arg;
|
||||
public Object Invk() {
|
||||
return invkAble.Invk(GfsCtx.Instance, 0, cmd, m);
|
||||
}
|
||||
public static final GfoInvkAbleCmd Null = new GfoInvkAbleCmd();
|
||||
public static GfoInvkAbleCmd new_(GfoInvkAble invkAble, String cmd) {return arg_(invkAble, cmd, null);}
|
||||
public static GfoInvkAbleCmd arg_(GfoInvkAble invkAble, String cmd, Object arg) {
|
||||
GfoInvkAbleCmd rv = new GfoInvkAbleCmd();
|
||||
rv.invkAble = invkAble; rv.cmd = cmd; rv.arg = arg;
|
||||
rv.m = (arg == null) ? GfoMsg_.Null : GfoMsg_.new_parse_(cmd).Add("v", arg);
|
||||
return rv;
|
||||
} GfoInvkAbleCmd() {}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
import gplx.core.primitives.*;
|
||||
public class GfoInvkAble_ {
|
||||
public static GfoInvkAble as_(Object obj) {return obj instanceof GfoInvkAble ? (GfoInvkAble)obj : null;}
|
||||
public static GfoInvkAble cast(Object obj) {try {return (GfoInvkAble)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfoInvkAble.class, obj);}}
|
||||
public static final String_obj_val Rv_unhandled = String_obj_val.new_("Unhandled"), Rv_handled = String_obj_val.new_("Handled"), Rv_host = String_obj_val.new_("Host")
|
||||
, Rv_cancel = String_obj_val.new_("Cancel"), Rv_error = String_obj_val.new_("Error");
|
||||
|
||||
public static Object InvkCmd(GfoInvkAble invk, String k) {return InvkCmd_msg(invk, k, GfoMsg_.Null);}
|
||||
public static Object InvkCmd_val(GfoInvkAble invk, String k, Object v) {return InvkCmd_msg(invk, k, GfoMsg_.new_cast_(k).Add("v", v));}
|
||||
public static Object InvkCmd_msg(GfoInvkAble invk, String k, GfoMsg m) {
|
||||
Object rv = invk.Invk(GfsCtx.Instance, 0, k, m);
|
||||
if (rv == GfoInvkAble_.Rv_unhandled) throw Err_.new_wo_type("invkable did not handle message", "key", k);
|
||||
return rv;
|
||||
}
|
||||
public static final GfoInvkAble Null = new GfoInvkAble_null();
|
||||
public static Object Invk(GfoInvkAble itm) {return itm.Invk(null, -1, null, null);}
|
||||
public static Object Invk(GfoInvkAble itm, String key) {return itm.Invk(null, -1, key , null);}
|
||||
public static final String Mutator_suffix = "_";
|
||||
}
|
||||
class GfoInvkAble_null implements GfoInvkAble {
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {return this;}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
public class Gfo_evt_mgr_ {
|
||||
public static void Sub(Gfo_evt_mgr_owner pub, String pubEvt, Gfo_evt_itm sub, String subEvt) {pub.Evt_mgr().AddSub(pub, pubEvt, sub, subEvt);}
|
||||
public static void Sub_same(Gfo_evt_mgr_owner pub, String evt, Gfo_evt_itm sub) {pub.Evt_mgr().AddSub(pub, evt, sub, evt);}
|
||||
public static void Sub_same_many(Gfo_evt_mgr_owner pub, Gfo_evt_itm sub, String... evts) {
|
||||
int len = evts.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
String evt = evts[i];
|
||||
pub.Evt_mgr().AddSub(pub, evt, sub, evt);
|
||||
}
|
||||
}
|
||||
public static void Pub(Gfo_evt_mgr_owner pub, String pubEvt) {pub.Evt_mgr().Pub(GfsCtx.new_(), pubEvt, GfoMsg_.new_cast_(pubEvt));}
|
||||
public static void Pub_obj(Gfo_evt_mgr_owner pub, String pubEvt, String key, Object v) {pub.Evt_mgr().Pub(GfsCtx.new_(), pubEvt, msg_(pubEvt, Keyval_.new_(key, v)));}
|
||||
public static void Pub_val(Gfo_evt_mgr_owner pub, String pubEvt, Object v) {pub.Evt_mgr().Pub(GfsCtx.new_(), pubEvt, msg_(pubEvt, Keyval_.new_("v", v)));}
|
||||
public static void Pub_vals(Gfo_evt_mgr_owner pub, String pubEvt, Keyval... ary) {pub.Evt_mgr().Pub(GfsCtx.new_(), pubEvt, msg_(pubEvt, ary));}
|
||||
public static void Pub_msg(Gfo_evt_mgr_owner pub, GfsCtx ctx, String pubEvt, GfoMsg m) {pub.Evt_mgr().Pub(ctx, pubEvt, m);}
|
||||
public static void Lnk(Gfo_evt_mgr_owner pub, Gfo_evt_mgr_owner sub) {sub.Evt_mgr().Lnk(pub);}
|
||||
public static void Rls_pub(Gfo_evt_mgr_owner pub) {pub.Evt_mgr().RlsPub(pub);}
|
||||
public static void Rls_sub(Gfo_evt_mgr_owner sub) {sub.Evt_mgr().RlsSub(sub);}
|
||||
static GfoMsg msg_(String evt, Keyval... kvAry) {
|
||||
GfoMsg m = GfoMsg_.new_cast_(evt);
|
||||
for (int i = 0; i < kvAry.length; i++) {
|
||||
Keyval kv = kvAry[i];
|
||||
m.Add(kv.Key(), kv.Val());
|
||||
}
|
||||
return m;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
import gplx.core.primitives.*;
|
||||
public class Gfo_invk_ {
|
||||
public static final String Mutator_suffix = "_";
|
||||
public static final Gfo_invk Noop = new Gfo_invk__noop();
|
||||
public static final String_obj_val
|
||||
Rv_unhandled = String_obj_val.new_("Unhandled")
|
||||
, Rv_handled = String_obj_val.new_("Handled")
|
||||
, Rv_host = String_obj_val.new_("Host")
|
||||
, Rv_cancel = String_obj_val.new_("Cancel")
|
||||
, Rv_error = String_obj_val.new_("Error");
|
||||
|
||||
public static Gfo_invk as_(Object obj) {return obj instanceof Gfo_invk ? (Gfo_invk)obj : null;}
|
||||
|
||||
public static Object Invk_no_key(Gfo_invk invk) {return Invk_by_msg(invk, "", GfoMsg_.Null);}
|
||||
public static Object Invk_by_key(Gfo_invk invk, String k) {return Invk_by_msg(invk, k , GfoMsg_.Null);}
|
||||
public static Object Invk_by_val(Gfo_invk invk, String k, Object v) {return Invk_by_msg(invk, k , GfoMsg_.new_cast_(k).Add("v", v));}
|
||||
public static Object Invk_by_msg(Gfo_invk invk, String k, GfoMsg m) {
|
||||
Object rv = invk.Invk(GfsCtx.Instance, 0, k, m);
|
||||
if (rv == Gfo_invk_.Rv_unhandled) throw Err_.new_wo_type("invkable did not handle message", "key", k);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Gfo_invk__noop implements Gfo_invk {
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {return this;}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
public class Gfo_invk_cmd {
|
||||
private final Gfo_invk itm; private final String cmd; private final GfoMsg msg;
|
||||
public Gfo_invk_cmd(Gfo_invk itm, String cmd, GfoMsg msg) {
|
||||
this.itm = itm; this.cmd = cmd; this.msg = msg;
|
||||
}
|
||||
public Object Exec() {return itm.Invk(GfsCtx.Instance, 0, cmd, msg);}
|
||||
public Object Exec_by_ctx(GfsCtx ctx, GfoMsg msg) {return itm.Invk(ctx, 0, cmd, msg);}
|
||||
|
||||
public static final Gfo_invk_cmd Noop = new Gfo_invk_cmd(Gfo_invk_.Noop, "", GfoMsg_.Null);
|
||||
public static Gfo_invk_cmd New_by_key(Gfo_invk itm, String cmd) {return New_by_val(itm, cmd, null);}
|
||||
public static Gfo_invk_cmd New_by_val(Gfo_invk itm, String cmd, Object val) {
|
||||
return new Gfo_invk_cmd(itm, cmd, (val == null) ? GfoMsg_.Null : GfoMsg_.new_parse_(cmd).Add("v", val));
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
public interface Gfo_log {
|
||||
List_adp Itms();
|
||||
Gfo_log Itms_(List_adp v);
|
||||
void Warn(String msg, Object... args);
|
||||
void Note(String msg, Object... args);
|
||||
void Info(String msg, Object... args);
|
||||
void Prog(String msg, Object... args);
|
||||
void Flush();
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
import gplx.core.logs.*;
|
||||
public class Gfo_log_ {
|
||||
public static Gfo_log Instance = new Gfo_log__mem();
|
||||
public static Gfo_log Instance__set(Gfo_log v) {
|
||||
v.Itms_(Instance.Itms());
|
||||
Instance = v;
|
||||
return v;
|
||||
}
|
||||
public static final String File__fmt = "yyyyMMdd_HHmmss", File__ext = ".log";
|
||||
public static Io_url New_url(Io_url dir) {
|
||||
return dir.GenSubFil(DateAdp_.Now().XtoUtc().XtoStr_fmt(Gfo_log_.File__fmt) + Gfo_log_.File__ext);
|
||||
}
|
||||
public static Gfo_log New_file(Io_url dir) {
|
||||
Io_url url = dir.GenSubFil(DateAdp_.Now().XtoStr_fmt(File__fmt) + File__ext);
|
||||
return new Gfo_log__file(url, new Gfo_log_itm_wtr__csv());
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue