mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.5.1.1'
This commit is contained in:
46
400_xowa/src/gplx/core/gfobjs/Gfobj_ary.java
Normal file
46
400_xowa/src/gplx/core/gfobjs/Gfobj_ary.java
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.gfobjs; import gplx.*; import gplx.core.*;
|
||||
public interface Gfobj_ary extends Gfobj_grp {
|
||||
byte Ary_tid();
|
||||
int Len();
|
||||
}
|
||||
class Gfo_ary_str implements Gfobj_ary {
|
||||
public Gfo_ary_str(String[] ary) {this.ary = ary;}
|
||||
public byte Grp_tid() {return Gfobj_grp_.Grp_tid__ary;}
|
||||
public byte Ary_tid() {return Gfobj_ary_.Ary_tid__str;}
|
||||
public int Len() {return ary.length;}
|
||||
public Object Get_at(int i) {return ary[i];}
|
||||
public String[] Ary_str() {return ary;} private final String[] ary;
|
||||
}
|
||||
class Gfo_ary_int implements Gfobj_ary {
|
||||
public Gfo_ary_int(int[] ary) {this.ary = ary;}
|
||||
public byte Grp_tid() {return Gfobj_grp_.Grp_tid__ary;}
|
||||
public byte Ary_tid() {return Gfobj_ary_.Ary_tid__int;}
|
||||
public int Len() {return ary.length;}
|
||||
public Object Get_at(int i) {return ary[i];}
|
||||
public int[] Ary_int() {return ary;} private final int[] ary;
|
||||
}
|
||||
class Gfo_ary_ary implements Gfobj_ary {
|
||||
public Gfo_ary_ary(Gfobj_ary[] ary) {this.ary = ary;}
|
||||
public byte Grp_tid() {return Gfobj_grp_.Grp_tid__ary;}
|
||||
public byte Ary_tid() {return Gfobj_ary_.Ary_tid__ary;}
|
||||
public int Len() {return ary.length;}
|
||||
public Object Get_at(int i) {return ary[i];}
|
||||
public Gfobj_ary[] Ary_ary() {return ary;} private Gfobj_ary[] ary;
|
||||
}
|
||||
26
400_xowa/src/gplx/core/gfobjs/Gfobj_ary_.java
Normal file
26
400_xowa/src/gplx/core/gfobjs/Gfobj_ary_.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.gfobjs; import gplx.*; import gplx.core.*;
|
||||
public class Gfobj_ary_ {
|
||||
public static final byte
|
||||
Ary_tid__ary = 0
|
||||
, Ary_tid__nde = 1
|
||||
, Ary_tid__str = 2
|
||||
, Ary_tid__int = 3
|
||||
;
|
||||
}
|
||||
27
400_xowa/src/gplx/core/gfobjs/Gfobj_ary_nde.java
Normal file
27
400_xowa/src/gplx/core/gfobjs/Gfobj_ary_nde.java
Normal file
@@ -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.core.gfobjs; import gplx.*; import gplx.core.*;
|
||||
public class Gfobj_ary_nde implements Gfobj_ary {
|
||||
public Gfobj_ary_nde(Gfobj_nde[] ary) {this.ary = ary;}
|
||||
public byte Grp_tid() {return Gfobj_grp_.Grp_tid__ary;}
|
||||
public byte Ary_tid() {return Gfobj_ary_.Ary_tid__nde;}
|
||||
public int Len() {return ary.length;}
|
||||
public Object Get_at(int i) {return ary[i];}
|
||||
public Gfobj_nde[] Ary_nde() {return ary;} private Gfobj_nde[] ary;
|
||||
public void Ary_nde_(Gfobj_nde[] v) {this.ary = v;}
|
||||
}
|
||||
67
400_xowa/src/gplx/core/gfobjs/Gfobj_fld.java
Normal file
67
400_xowa/src/gplx/core/gfobjs/Gfobj_fld.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.gfobjs; import gplx.*; import gplx.core.*;
|
||||
public interface Gfobj_fld {
|
||||
byte Fld_tid();
|
||||
String Key();
|
||||
Object As_obj();
|
||||
}
|
||||
class Gfobj_fld_ {
|
||||
public static final byte
|
||||
Fld_tid__ary = 0
|
||||
, Fld_tid__nde = 1
|
||||
, Fld_tid__int = 2
|
||||
, Fld_tid__long = 3
|
||||
, Fld_tid__str = 4
|
||||
;
|
||||
}
|
||||
class Gfobj_fld_str implements Gfobj_fld {
|
||||
public Gfobj_fld_str(String key, String val) {this.key = key; this.val = val;}
|
||||
public String Key() {return key;} private final String key;
|
||||
public byte Fld_tid() {return Gfobj_fld_.Fld_tid__str;}
|
||||
public Object As_obj() {return val;}
|
||||
public String As_str() {return val;} private String val;
|
||||
}
|
||||
class Gfobj_fld_int implements Gfobj_fld {
|
||||
public Gfobj_fld_int(String key, int val) {this.key = key; this.val = val;}
|
||||
public String Key() {return key;} private final String key;
|
||||
public byte Fld_tid() {return Gfobj_fld_.Fld_tid__int;}
|
||||
public Object As_obj() {return val;}
|
||||
public int As_int() {return val;} private int val;
|
||||
}
|
||||
class Gfobj_fld_long implements Gfobj_fld {
|
||||
public Gfobj_fld_long(String key, long val) {this.key = key; this.val = val;}
|
||||
public String Key() {return key;} private final String key;
|
||||
public byte Fld_tid() {return Gfobj_fld_.Fld_tid__long;}
|
||||
public Object As_obj() {return val;}
|
||||
public long As_long() {return val;} private long val;
|
||||
}
|
||||
class Gfobj_fld_nde implements Gfobj_fld {
|
||||
public Gfobj_fld_nde(String key, Gfobj_nde val) {this.key = key; this.val = val;}
|
||||
public String Key() {return key;} private final String key;
|
||||
public byte Fld_tid() {return Gfobj_fld_.Fld_tid__nde;}
|
||||
public Object As_obj() {return val;}
|
||||
public Gfobj_nde As_nde() {return val;} private Gfobj_nde val;
|
||||
}
|
||||
class Gfobj_fld_ary implements Gfobj_fld {
|
||||
public Gfobj_fld_ary(String key, Gfobj_ary val) {this.key = key; this.val = val;}
|
||||
public String Key() {return key;} private final String key;
|
||||
public byte Fld_tid() {return Gfobj_fld_.Fld_tid__ary;}
|
||||
public Object As_obj() {return val;}
|
||||
public Gfobj_ary As_ary() {return val;} private Gfobj_ary val;
|
||||
}
|
||||
21
400_xowa/src/gplx/core/gfobjs/Gfobj_grp.java
Normal file
21
400_xowa/src/gplx/core/gfobjs/Gfobj_grp.java
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.gfobjs; import gplx.*; import gplx.core.*;
|
||||
public interface Gfobj_grp {
|
||||
byte Grp_tid();
|
||||
}
|
||||
24
400_xowa/src/gplx/core/gfobjs/Gfobj_grp_.java
Normal file
24
400_xowa/src/gplx/core/gfobjs/Gfobj_grp_.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.gfobjs; import gplx.*; import gplx.core.*;
|
||||
class Gfobj_grp_ {
|
||||
public static final byte
|
||||
Grp_tid__ary = 0
|
||||
, Grp_tid__nde = 1
|
||||
;
|
||||
}
|
||||
34
400_xowa/src/gplx/core/gfobjs/Gfobj_nde.java
Normal file
34
400_xowa/src/gplx/core/gfobjs/Gfobj_nde.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.gfobjs; import gplx.*; import gplx.core.*;
|
||||
public class Gfobj_nde implements Gfobj_grp {
|
||||
private Ordered_hash subs;
|
||||
public byte Grp_tid() {return Gfobj_grp_.Grp_tid__nde;}
|
||||
public int Len() {return subs == null ? 0 : subs.Len();}
|
||||
public Gfobj_fld Get_at(int i) {return subs == null ? null : (Gfobj_fld)subs.Get_at(i);}
|
||||
public Gfobj_fld Get_by(String k) {return subs == null ? null : (Gfobj_fld)subs.Get_by(k);}
|
||||
public Gfobj_nde Add_fld(Gfobj_fld fld) {if (subs == null) subs = Ordered_hash_.New(); subs.Add(fld.Key(), fld); return this;}
|
||||
public Gfobj_nde Add_int(String key, int val) {return Add_fld(new Gfobj_fld_int(key, val));}
|
||||
public Gfobj_nde Add_long(String key, long val) {return Add_fld(new Gfobj_fld_long(key, val));}
|
||||
public Gfobj_nde Add_str(String key, String val) {return Add_fld(new Gfobj_fld_str(key, val));}
|
||||
public Gfobj_nde Add_nde(String key, Gfobj_nde val) {return Add_fld(new Gfobj_fld_nde(key, val));}
|
||||
public Gfobj_nde Add_ary(String key, Gfobj_ary val) {return Add_fld(new Gfobj_fld_ary(key, val));}
|
||||
public Gfobj_nde New_nde(String key) {Gfobj_nde rv = new Gfobj_nde(); Add_fld(new Gfobj_fld_nde(key, rv)); return rv;}
|
||||
public Gfobj_ary_nde New_ary_nde(String key) {Gfobj_ary_nde rv = new Gfobj_ary_nde(null); Add_fld(new Gfobj_fld_ary(key, rv)); return rv;}
|
||||
public static Gfobj_nde New() {return new Gfobj_nde();}
|
||||
}
|
||||
92
400_xowa/src/gplx/core/gfobjs/Gfobj_wtr__json.java
Normal file
92
400_xowa/src/gplx/core/gfobjs/Gfobj_wtr__json.java
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.gfobjs; import gplx.*; import gplx.core.*;
|
||||
import gplx.langs.jsons.*;
|
||||
public class Gfobj_wtr__json {
|
||||
private final Json_wtr wtr = new Json_wtr();
|
||||
public Gfobj_wtr__json Opt_ws_(boolean v) {wtr.Opt_ws_(v); return this;}
|
||||
public Bry_bfr Bfr() {return wtr.Bfr();}
|
||||
public String To_str() {return wtr.To_str_and_clear();}
|
||||
public Gfobj_wtr__json Write(Gfobj_grp root) {
|
||||
switch (root.Grp_tid()) {
|
||||
case Gfobj_grp_.Grp_tid__nde:
|
||||
wtr.Doc_nde_bgn();
|
||||
Write_nde((Gfobj_nde)root);
|
||||
wtr.Doc_nde_end();
|
||||
break;
|
||||
case Gfobj_grp_.Grp_tid__ary:
|
||||
wtr.Doc_ary_bgn();
|
||||
Write_ary((Gfobj_ary)root);
|
||||
wtr.Doc_ary_end();
|
||||
break;
|
||||
default:
|
||||
throw Err_.new_unhandled_default(root.Grp_tid());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
private void Write_nde(Gfobj_nde nde) {
|
||||
int len = nde.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Gfobj_fld fld = (Gfobj_fld)nde.Get_at(i);
|
||||
Write_fld(fld);
|
||||
}
|
||||
}
|
||||
private void Write_fld(Gfobj_fld itm) {
|
||||
switch (itm.Fld_tid()) {
|
||||
case Gfobj_fld_.Fld_tid__str: wtr.Kv_str(itm.Key() , ((Gfobj_fld_str)itm).As_str()); break;
|
||||
case Gfobj_fld_.Fld_tid__int: wtr.Kv_int(itm.Key() , ((Gfobj_fld_int)itm).As_int()); break;
|
||||
case Gfobj_fld_.Fld_tid__long: wtr.Kv_long(itm.Key() , ((Gfobj_fld_long)itm).As_long()); break;
|
||||
case Gfobj_fld_.Fld_tid__nde: wtr.Nde_bgn(itm.Key()); Write_nde(((Gfobj_fld_nde)itm).As_nde()); wtr.Nde_end();break;
|
||||
case Gfobj_fld_.Fld_tid__ary: wtr.Ary_bgn(itm.Key()); Write_ary(((Gfobj_fld_ary)itm).As_ary()); wtr.Ary_end();break;
|
||||
default: throw Err_.new_unhandled_default(itm.Fld_tid());
|
||||
}
|
||||
}
|
||||
private void Write_ary(Gfobj_ary ary) {
|
||||
int len = ary.Len();
|
||||
byte ary_tid = ary.Ary_tid();
|
||||
switch (ary_tid) {
|
||||
case Gfobj_ary_.Ary_tid__str:
|
||||
String[] ary_str = ((Gfo_ary_str)ary).Ary_str();
|
||||
for (int i = 0; i < len; ++i)
|
||||
wtr.Ary_itm_str(ary_str[i]);
|
||||
break;
|
||||
case Gfobj_ary_.Ary_tid__int:
|
||||
int[] ary_int = ((Gfo_ary_int)ary).Ary_int();
|
||||
for (int i = 0; i < len; ++i)
|
||||
wtr.Ary_itm_obj(ary_int[i]);
|
||||
break;
|
||||
case Gfobj_ary_.Ary_tid__nde:
|
||||
Gfobj_nde[] ary_nde = ((Gfobj_ary_nde)ary).Ary_nde();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
wtr.Nde_bgn_ary();
|
||||
Write_nde(ary_nde[i]);
|
||||
wtr.Nde_end();
|
||||
}
|
||||
break;
|
||||
case Gfobj_ary_.Ary_tid__ary:
|
||||
Gfobj_ary[] ary_ary = ((Gfo_ary_ary)ary).Ary_ary();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
wtr.Ary_bgn_ary();
|
||||
Write_ary(ary_ary[i]);
|
||||
wtr.Ary_end();
|
||||
}
|
||||
break;
|
||||
default: throw Err_.new_unhandled_default(ary_tid);
|
||||
}
|
||||
}
|
||||
}
|
||||
49
400_xowa/src/gplx/core/gfobjs/Gfobj_wtr__json_fxt.java
Normal file
49
400_xowa/src/gplx/core/gfobjs/Gfobj_wtr__json_fxt.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.gfobjs; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.tests.*; import gplx.langs.jsons.*;
|
||||
public class Gfobj_wtr__json_fxt {
|
||||
protected final Gfobj_wtr__json mgr = new Gfobj_wtr__json();
|
||||
public Gfobj_nde Make__nde(Gfobj_fld... ary) {return Make__nde(Gfobj_nde.New(), ary);}
|
||||
private Gfobj_nde Make__nde(Gfobj_nde nde, Gfobj_fld[] ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Gfobj_fld fld = (Gfobj_fld)ary[i];
|
||||
nde.Add_fld(fld);
|
||||
}
|
||||
return nde;
|
||||
}
|
||||
public Gfobj_fld Make__fld_str(String key, String val) {return new Gfobj_fld_str(key, val);}
|
||||
public Gfobj_fld Make__fld_int(String key, int val) {return new Gfobj_fld_int(key, val);}
|
||||
public Gfobj_fld Make__fld_long(String key, long val) {return new Gfobj_fld_long(key, val);}
|
||||
public Gfobj_fld Make__fld_nde(String key, Gfobj_fld... ary) {
|
||||
Gfobj_nde nde = Make__nde(Gfobj_nde.New(), ary);
|
||||
Gfobj_fld_nde rv = new Gfobj_fld_nde(key, nde);
|
||||
return rv;
|
||||
}
|
||||
public Gfobj_fld Make__fld_ary_str(String key, String... ary) {return new Gfobj_fld_ary(key, new Gfo_ary_str(ary));}
|
||||
public Gfobj_fld Make__fld_ary_int(String key, int... ary) {return new Gfobj_fld_ary(key, new Gfo_ary_int(ary));}
|
||||
public Gfobj_fld Make__fld_ary_ary(String key, Gfobj_ary... ary) {return new Gfobj_fld_ary(key, new Gfo_ary_ary(ary));}
|
||||
public Gfobj_fld Make__fld_ary_nde(String key, Gfobj_nde... ary) {return new Gfobj_fld_ary(key, new Gfobj_ary_nde(ary));}
|
||||
public Gfobj_ary Make__ary_int(int... ary) {return new Gfo_ary_int(ary);}
|
||||
public Gfobj_wtr__json_fxt Test__write(Gfobj_grp root, String... lines) {
|
||||
String[] expd = Json_doc.Make_str_ary_by_apos(lines);
|
||||
Gftest.Eq__ary(expd, Bry_.Ary(String_.SplitLines_nl(mgr.Write(root).To_str())), "json_write");
|
||||
return this;
|
||||
}
|
||||
}
|
||||
155
400_xowa/src/gplx/core/gfobjs/Gfobj_wtr__json_tst.java
Normal file
155
400_xowa/src/gplx/core/gfobjs/Gfobj_wtr__json_tst.java
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.gfobjs; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
import gplx.langs.jsons.*;
|
||||
public class Gfobj_wtr__json_tst {
|
||||
private final Gfobj_wtr__json_fxt fxt = new Gfobj_wtr__json_fxt();
|
||||
@Test public void Flds() {
|
||||
fxt.Test__write
|
||||
( fxt.Make__nde
|
||||
( fxt.Make__fld_str ("k1", "v1")
|
||||
, fxt.Make__fld_long ("k2", 2)
|
||||
, fxt.Make__fld_int ("k3", 3)
|
||||
)
|
||||
, "{ 'k1':'v1'"
|
||||
, ", 'k2':2"
|
||||
, ", 'k3':3"
|
||||
, "}"
|
||||
, ""
|
||||
);
|
||||
}
|
||||
@Test public void Sub_ndes() {
|
||||
fxt.Test__write
|
||||
( fxt.Make__nde
|
||||
( fxt.Make__fld_str ("k1", "v1")
|
||||
, fxt.Make__fld_nde ("k2"
|
||||
, fxt.Make__fld_str ("k2a", "v2a")
|
||||
, fxt.Make__fld_int ("k2b", 2)
|
||||
)
|
||||
, fxt.Make__fld_int ("k3", 3)
|
||||
)
|
||||
, "{ 'k1':'v1'"
|
||||
, ", 'k2':"
|
||||
, " { 'k2a':'v2a'"
|
||||
, " , 'k2b':2"
|
||||
, " }"
|
||||
, ", 'k3':3"
|
||||
, "}"
|
||||
, ""
|
||||
);
|
||||
}
|
||||
@Test public void Ary_str() {
|
||||
fxt.Test__write
|
||||
( fxt.Make__nde
|
||||
( fxt.Make__fld_str ("k1", "v1")
|
||||
, fxt.Make__fld_ary_str ("k2", "a1", "a2", "a3")
|
||||
, fxt.Make__fld_int ("k3", 3)
|
||||
)
|
||||
, "{ 'k1':'v1'"
|
||||
, ", 'k2':"
|
||||
, " [ 'a1'"
|
||||
, " , 'a2'"
|
||||
, " , 'a3'"
|
||||
, " ]"
|
||||
, ", 'k3':3"
|
||||
, "}"
|
||||
, ""
|
||||
);
|
||||
}
|
||||
@Test public void Ary_int() {
|
||||
fxt.Test__write
|
||||
( fxt.Make__nde
|
||||
( fxt.Make__fld_str ("k1", "v1")
|
||||
, fxt.Make__fld_ary_int ("k2", 1, 2, 3)
|
||||
, fxt.Make__fld_int ("k3", 3)
|
||||
)
|
||||
, "{ 'k1':'v1'"
|
||||
, ", 'k2':"
|
||||
, " [ 1"
|
||||
, " , 2"
|
||||
, " , 3"
|
||||
, " ]"
|
||||
, ", 'k3':3"
|
||||
, "}"
|
||||
, ""
|
||||
);
|
||||
}
|
||||
@Test public void Ary_nde() {
|
||||
fxt.Test__write
|
||||
( fxt.Make__nde
|
||||
( fxt.Make__fld_str ("k1", "v1")
|
||||
, fxt.Make__fld_ary_nde ("k2"
|
||||
, fxt.Make__nde (fxt.Make__fld_str("k21", "v21"))
|
||||
, fxt.Make__nde (fxt.Make__fld_str("k22", "v22"))
|
||||
)
|
||||
, fxt.Make__fld_int ("k3", 3)
|
||||
)
|
||||
, "{ 'k1':'v1'"
|
||||
, ", 'k2':"
|
||||
, " ["
|
||||
, " { 'k21':'v21'"
|
||||
, " }"
|
||||
, " ,"
|
||||
, " { 'k22':'v22'"
|
||||
, " }"
|
||||
, " ]"
|
||||
, ", 'k3':3"
|
||||
, "}"
|
||||
, ""
|
||||
);
|
||||
}
|
||||
@Test public void Ary_ary() {
|
||||
fxt.Test__write
|
||||
( fxt.Make__nde
|
||||
( fxt.Make__fld_str ("k1", "v1")
|
||||
, fxt.Make__fld_ary_ary ("k2"
|
||||
, fxt.Make__ary_int (1, 2, 3)
|
||||
, fxt.Make__ary_int (4, 5, 6)
|
||||
)
|
||||
, fxt.Make__fld_int ("k3", 3)
|
||||
)
|
||||
, "{ 'k1':'v1'"
|
||||
, ", 'k2':"
|
||||
, " ["
|
||||
, " [ 1"
|
||||
, " , 2"
|
||||
, " , 3"
|
||||
, " ]"
|
||||
, " ,"
|
||||
, " [ 4"
|
||||
, " , 5"
|
||||
, " , 6"
|
||||
, " ]"
|
||||
, " ]"
|
||||
, ", 'k3':3"
|
||||
, "}"
|
||||
, ""
|
||||
);
|
||||
}
|
||||
@Test public void Root_ary() {
|
||||
fxt.Test__write
|
||||
( fxt.Make__ary_int(1, 2, 3)
|
||||
, "[ 1"
|
||||
, ", 2"
|
||||
, ", 3"
|
||||
, "]"
|
||||
, ""
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -27,16 +27,37 @@ public class Gftest {
|
||||
public static void Eq__ary(byte[][] expd_bry_ary, byte[][] actl_bry_ary, String msg_fmt, Object... msg_args) {
|
||||
boolean[] failures = Calc__failures(Type_adp_.Tid__bry, expd_bry_ary, actl_bry_ary);
|
||||
if (failures != null) {
|
||||
bfr.Add(Bry__line_bgn);
|
||||
if (msg_fmt != null) {
|
||||
bfr.Add_str_u8(String_.Format(msg_fmt, msg_args));
|
||||
bfr.Add(Bry__line_mid);
|
||||
}
|
||||
Write__failures(bfr, failures, Type_adp_.Tid__bry, expd_bry_ary, actl_bry_ary);
|
||||
Write_fail_head(bfr, msg_fmt, msg_args);
|
||||
Write_fail_ary(bfr, failures, Type_adp_.Tid__bry, expd_bry_ary, actl_bry_ary);
|
||||
throw Err_.new_wo_type(bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
private static void Write__failures(Bry_bfr bfr, boolean[] failures, int type_id, Object expd_ary, Object actl_ary) {
|
||||
public static void Eq__str(String expd, String actl) {Eq__str(expd, actl, null);}
|
||||
public static void Eq__str(String expd, String actl, String msg_fmt, Object... msg_args) {
|
||||
if (String_.Eq(expd, actl)) return;
|
||||
Write_fail_head(bfr, msg_fmt, msg_args);
|
||||
bfr.Add_str_a7("expd: ").Add_str_u8(expd).Add_byte_nl();
|
||||
bfr.Add_str_a7("actl: ").Add_str_u8(actl).Add_byte_nl();
|
||||
bfr.Add(Bry__line_end);
|
||||
throw Err_.new_wo_type(bfr.To_str_and_clear());
|
||||
}
|
||||
public static void Eq__bry(byte[] expd, byte[] actl) {Eq__bry(expd, actl, null);}
|
||||
public static void Eq__bry(byte[] expd, byte[] actl, String msg_fmt, Object... msg_args) {
|
||||
if (Bry_.Eq(expd, actl)) return;
|
||||
Write_fail_head(bfr, msg_fmt, msg_args);
|
||||
bfr.Add_str_a7("expd: ").Add(expd).Add_byte_nl();
|
||||
bfr.Add_str_a7("actl: ").Add(actl).Add_byte_nl();
|
||||
bfr.Add(Bry__line_end);
|
||||
throw Err_.new_wo_type(bfr.To_str_and_clear());
|
||||
}
|
||||
private static void Write_fail_head(Bry_bfr bfr, String msg_fmt, Object[] msg_args) {
|
||||
bfr.Add(Bry__line_bgn);
|
||||
if (msg_fmt != null) {
|
||||
bfr.Add_str_u8(String_.Format(msg_fmt, msg_args));
|
||||
bfr.Add(Bry__line_mid);
|
||||
}
|
||||
}
|
||||
private static void Write_fail_ary(Bry_bfr bfr, boolean[] failures, int type_id, Object expd_ary, Object actl_ary) {
|
||||
int len = failures.length;
|
||||
int expd_len = Array_.Len(expd_ary);
|
||||
int actl_len = Array_.Len(actl_ary);
|
||||
|
||||
Reference in New Issue
Block a user