XOMW: Consolidate XophpArray_ into XophpArray [#632]

staging
gnosygnu 4 years ago
parent ee68162a4a
commit a9367eaca8

@ -20,17 +20,20 @@ import gplx.Bry_bfr;
import gplx.Bry_bfr_;
import gplx.Char_;
import gplx.Int_;
import gplx.List_adp;
import gplx.List_adp_;
import gplx.Object_;
import gplx.Ordered_hash;
import gplx.Ordered_hash_;
import gplx.Type_;
import gplx.core.brys.*;
import gplx.core.brys.Bry_bfr_able;
import gplx.core.strings.String_bldr;
import gplx.core.strings.String_bldr_;
import java.util.Iterator;
import java.util.function.Consumer;
// REF.PHP: https://www.php.net/manual/en/language.types.array.php
// Will also will have static functions but "array_" will be stripped; REF.PHP: https://www.php.net/manual/en/ref.array.php
// also has static functions; REF.PHP: https://www.php.net/manual/en/ref.array.php
public class XophpArray<T> implements Bry_bfr_able, Iterable<T> {
private final Ordered_hash hash = Ordered_hash_.New();
private int newMemberIdx;
@ -41,65 +44,39 @@ public class XophpArray<T> implements Bry_bfr_able, Iterable<T> {
internalPointerIndex = 0;
}
public int Len() {return hash.Len();}
public int count() {return hash.Len();}
public boolean count_bool() {return hash.Len() > 0;}
public boolean isset(String key) {return hash.Has(key);}
public boolean isset(int idx) {return idx >= 0 && idx < hash.Count();}
public boolean in_array(String v) {return Has(v);}
public Object end() {
int len = hash.Len();
return len == 0 ? null : ((XophpArrayItm)hash.Get_at(len - 1)).Val();
}
public boolean Eq_to_new() {return hash.Count() == 0;}// same as "array === []"
public void unset(int key) {unset(Int_.To_str(key));}
public void unset(String key) {
hash.Del(key);
}
public Object pop() {// "array_pop"
int pos = this.count() - 1;
if (pos < 0) return null;
XophpArrayItm itm = (XophpArrayItm)hash.Get_at(pos);
this.Del_at(pos);
return itm.Val();
}
// REF.PHP: https://www.php.net/manual/en/function.array-values.php
public XophpArray values() {
XophpArray rv = new XophpArray();
int len = this.count();
for (int i = 0; i < len; i++) {
rv.Add(i, this.Get_at(i));
}
return rv;
public boolean Has_obj(Object key) {return Has(Object_.Xto_str_strict_or_null(key));}
public boolean Has(String key) {
return hash.Has(key);
}
public XophpArray Add(T val) {
int key = newMemberIdx++;
Set(XophpArrayItm.New_int(key, val));
Set(XophpArrayItm.NewInt(key, val));
return this;
}
public XophpArray Add(int key, Object val) {
newMemberIdx = key + 1;
Set(XophpArrayItm.New_int(key, val));
Set(XophpArrayItm.NewInt(key, val));
return this;
}
public XophpArray Add(double key, Object val) {
int key_as_int = (int)key;
newMemberIdx = key_as_int + 1;
Set(XophpArrayItm.New_int(key_as_int, val));
Set(XophpArrayItm.NewInt(key_as_int, val));
return this;
}
public XophpArray Add(boolean key, Object val) {
int key_as_int = key ? 1 : 0;
newMemberIdx = key_as_int + 1;
Set(XophpArrayItm.New_int(key_as_int, val));
Set(XophpArrayItm.NewInt(key_as_int, val));
return this;
}
public XophpArray Add(String key, Object val) {
int key_as_int = Int_.Parse_or(key, Int_.Min_value);
if (key_as_int == Int_.Min_value) {
Set(XophpArrayItm.New_str(key, val));
Set(XophpArrayItm.NewStr(key, val));
}
else {
Set(XophpArrayItm.New_int(key_as_int, val));
Set(XophpArrayItm.NewInt(key_as_int, val));
newMemberIdx = key_as_int + 1;
}
return this;
@ -124,7 +101,6 @@ public class XophpArray<T> implements Bry_bfr_able, Iterable<T> {
return Type_.Eq_by_obj(rv, XophpArray.class) ? (XophpArray)rv : null;
}
public XophpArray Get_at_ary(int i) {return (XophpArray)Get_at(i);}
public boolean Get_at_bool(int i) {return Bool_.Cast(Get_at(i));}
public int Get_at_int(int i) {return Int_.Cast(Get_at(i));}
public String Get_at_str(int i) {return (String)Get_at(i);}
public Object Get_at(int i) {
@ -136,12 +112,6 @@ public class XophpArray<T> implements Bry_bfr_able, Iterable<T> {
if (i < 0 || i >= hash.Len()) return null;
return (XophpArrayItm)hash.Get_at(i);
}
public void Del_at(int i) {
XophpArrayItm itm = (XophpArrayItm)hash.Get_at(i);
if (itm != null) {
hash.Del(itm.Key());
}
}
public Object Get_by_obj(Object key) {return Get_by(Object_.Xto_str_strict_or_null(key));}
public Object Get_by(int key) {return Get_by(Int_.To_str(key));}
public boolean Get_by_bool_or(String key, boolean or) {Object rv = this.Get_by(key); return rv == null ? or : Bool_.Cast(rv);}
@ -163,21 +133,32 @@ public class XophpArray<T> implements Bry_bfr_able, Iterable<T> {
public XophpArray Get_by_ary(String key) {return (XophpArray)this.Get_by(key);}
public String Get_by_str(char key) {return (String)this.Get_by(Char_.To_str(key));}
public String Get_by_str(int key) {return (String)this.Get_by(Int_.To_str(key));}
public String Get_by_str_or(String key, String or) {Object rv = this.Get_by(key); return rv == null ? or : (String)rv;}
public String Get_by_str(String key) {return (String)this.Get_by(key);}
public T Get_by(String key) {
XophpArrayItm itm = (XophpArrayItm)hash.Get_by(key);
return itm == null ? null : (T)itm.Val();
}
public void Set(int key, Object val) {
this.Set(XophpArrayItm.New_int(key, val));
this.Set(XophpArrayItm.NewInt(key, val));
}
public void Set(String key, Object val) {
this.Set(XophpArrayItm.New_str(key, val));
this.Set(XophpArrayItm.NewStr(key, val));
}
public boolean Has_obj(Object key) {return Has(Object_.Xto_str_strict_or_null(key));}
public boolean Has(String key) {
return hash.Has(key);
private void Set(XophpArrayItm itm) {
String key = itm.Key();
XophpArrayItm cur = (XophpArrayItm)hash.Get_by(key);
if (cur == null) {
hash.Add(key, itm);
}
else {
cur.Val_(itm.Val());
}
}
public void Del_at(int i) {
XophpArrayItm itm = (XophpArrayItm)hash.Get_at(i);
if (itm != null) {
hash.Del(itm.Key());
}
}
public XophpArrayItm[] To_ary() {
return (XophpArrayItm[])hash.To_ary(XophpArrayItm.class);
@ -193,16 +174,6 @@ public class XophpArray<T> implements Bry_bfr_able, Iterable<T> {
itm.To_bfr(bfr);
}
}
private void Set(XophpArrayItm itm) {
String key = itm.Key();
XophpArrayItm cur = (XophpArrayItm)hash.Get_by(key);
if (cur == null) {
hash.Add(key, itm);
}
else {
cur.Val_(itm.Val());
}
}
public void Itm_str_concat_end(int idx, String v) {
String itm = (String)this.Get_at(idx);
itm += v;
@ -275,6 +246,80 @@ public class XophpArray<T> implements Bry_bfr_able, Iterable<T> {
}
}
// DEPRECATE:use XophpArray
public static boolean popBoolOrN(List_adp list) {return Bool_.Cast(List_adp_.Pop_or(list, false));}
public static byte[] popBryOrNull(List_adp list) {return (byte[])List_adp_.Pop_or(list, null);}
public static String[] array_keys_str(Ordered_hash array) {
int len = array.Len();
String[] rv = new String[len];
for (int i = 0; i < len; i++) {
rv[i] = (String)array.Get_at(i);
}
return rv;
}
public static byte[][] array_keys_bry(Ordered_hash array) {
int len = array.Len();
byte[][] rv = new byte[len][];
for (int i = 0; i < len; i++) {
rv[i] = (byte[])array.Get_at(i);
}
return rv;
}
public static boolean array_key_exists(int key, Ordered_hash array) {return array.Has(key);}
public static boolean array_key_exists(String key, Ordered_hash array) {return array.Has(key);}
public static boolean array_key_exists(byte[] key, Ordered_hash array) {return array.Has(key);}
public static boolean empty(Ordered_hash array) {
return array.Len() == 0;
}
// **********
// * STATIC *
// **********
public static final XophpArray False = null; // handles code like "if ($var === false)" where var is an Object;
public static XophpArray New(Object... vals) {
XophpArray rv = new XophpArray();
for (Object val : vals)
rv.Add(val);
return rv;
}
public static boolean Eq_to_new(XophpArray array) {return array.hash.Count() == 0;}// same as "array === []"
public static boolean empty(XophpArray array) {return array.Len() == 0;}
public static int count(XophpArray array) {return array.Len();}
public static boolean count_bool(XophpArray array) {return array.Len() > 0;}
public static boolean isset(XophpArray array, int key) {return array.Get_at(key) != null;}
public static boolean isset(XophpArray array, String key) {return array.Get_by(key) != null;}
public static boolean is_array(Object array) {return XophpType_.instance_of(array, XophpArray.class);}
public static void unset(XophpArray array, String key) {array.hash.Del(key);}
public static void unset(XophpArray array, int key) {array.hash.Del(Int_.To_str(key));}
public static void unset(Ordered_hash array, Object key) {array.Del(key);}
public static boolean array_key_exists(String key, XophpArray array) {return array.Has(key);}
public static boolean array_key_exists(int key, XophpArray array) {return array.Has(Int_.To_str(key));}
public static Object array_pop(XophpArray array) {// "array_pop"
int pos = array.Len() - 1;
if (pos < 0) return null;
XophpArrayItm itm = (XophpArrayItm)array.hash.Get_at(pos);
array.Del_at(pos);
return itm.Val();
}
public static Object end(XophpArray array) {
int len = array.Len();
return len == 0 ? null : ((XophpArrayItm)array.hash.Get_at(len - 1)).Val();
}
// REF.PHP: https://www.php.net/manual/en/function.array-values.php
public static XophpArray array_values(XophpArray array) {
XophpArray rv = new XophpArray();
int len = array.Len();
for (int i = 0; i < len; i++) {
XophpArrayItm itm = array.Get_at_itm(i);
rv.Add(i, itm.Val());
}
return rv;
}
// REF.PHP:https://www.php.net/manual/en/function.reset.php
private int internalPointerIndex = 0;
private Object internalPointerAdd(int v) {
@ -292,14 +337,245 @@ public class XophpArray<T> implements Bry_bfr_able, Iterable<T> {
return array.internalPointerAdd(1);
}
public static boolean is_array(Object val) {
return Type_.Eq_by_obj(val, XophpArray.class);
// REF.PHP:https://www.php.net/manual/en/function.array-merge.php
public static XophpArray array_merge(XophpArray... vals) {
XophpArray rv = new XophpArray();
for (XophpArray ary : vals) {
XophpArrayItm[] itms = ary.To_ary();
for (XophpArrayItm itm : itms) {
array_itm_add(rv, itm);
}
}
return rv;
}
public static final XophpArray False = null; // handles code like "if ($var === false)" where var is an Object;
public static XophpArray New(Object... vals) {
// REF.PHP:https://www.php.net/manual/en/function.array-merge.php
// "If you want to append array elements from the second array to the first array while not overwriting the elements from the first array and not re-indexing, use the + array union operator:"
public static XophpArray array_add(XophpArray lhs, XophpArray... vals) {
for (XophpArray ary : vals) {
XophpArrayItm[] itms = ary.To_ary();
for (XophpArrayItm itm : itms) {
if (lhs.Has(itm.Key())) {
continue;
}
else {
lhs.Add(itm.Key(), itm.Val());
}
}
}
return lhs;
}
private static void array_itm_add(XophpArray ary, XophpArrayItm itm) {
if (itm.KeyIsInt())
ary.Add(itm.Val());
else
ary.Add(itm.Key(), itm.Val());
}
public static XophpArray array_splice(XophpArray src, int bgn) {return array_splice(src, bgn, src.Len(), null);}
public static XophpArray array_splice(XophpArray src, int bgn, int len) {return array_splice(src, bgn, len , null);}
public static XophpArray array_splice(XophpArray src, int bgn, int len, XophpArray repl) {
// get itms before clearing it
int src_len = src.Len();
XophpArrayItm[] itms = src.To_ary();
src.Clear();
// calc bgn
if (bgn < 0) { // negative bgn should be adusted from src_len; EX: -1 means start at last item
bgn += src_len;
if (bgn < 0) // large negative bgn should be capped at 0; EX: -99
bgn = 0;
}
else if (bgn > src_len) // large positive bgn should be capped at src_len; EX: 99
bgn = src_len;
// add src from 0 to bgn
for (int i = 0; i < bgn; i++) {
array_itm_add(src, itms[i]);
}
// add repl
if (repl != null) {
XophpArrayItm[] repl_itms = repl.To_ary();
for (XophpArrayItm itm : repl_itms) {
array_itm_add(src, itm);
}
}
// calc end
int end;
if (len < 0) { // negative len should be adjusted from src_len; EX: -1 means stop at last itm
end = src_len + len;
if (end < 0) // large_negative len should be capped at 0; EX: -99
end = 0;
}
else { // positive len should be added to bgn to find end
end = bgn + len;
}
if (end < bgn) // end should never be less than bgn; EX: splice(1, -99)
end = bgn;
else if (end > src_len) // end should not be more then end;
end = src_len;
// add src from end to len
for (int i = end; i < src_len; i++) {
array_itm_add(src, itms[i]);
}
// add del to rv
XophpArray rv = new XophpArray();
for (Object val : vals)
rv.Add(val);
for (int i = bgn; i < end; i++) {
array_itm_add(rv, itms[i]);
}
return rv;
}
// ( array $array , int $offset [, int $length = NULL [, boolean $preserve_keys = FALSE ]] ) :
public static XophpArray array_slice(XophpArray array, int offset) {return array_slice(array, offset, array.Len());}
public static XophpArray array_slice(XophpArray array, int offset, int length) {
XophpArray rv = new XophpArray();
int end = offset + length;
for (int i = offset; i< end; i++) {
rv.Add(array.Get_at(i));
}
return rv;
}
public static XophpArray<String> array_keys(XophpArray array) {
XophpArray rv = XophpArray.New();
int len = array.Len();
for (int i = 0; i < len; i++) {
XophpArrayItm itm = array.Get_at_itm(i);
rv.Add(itm.Key());
}
return rv;
}
// REF.PHP:https://www.php.net/manual/en/function.array-map.php
public static XophpArray array_map(XophpCallbackOwner callback_owner, String method, XophpArray array) {
XophpArray rv = XophpArray.New();
int len = array.Len();
for (int i = 0; i < len; i++) {
String itm = array.Get_at_str(i);
rv.Add((String)callback_owner.Call(method, itm));
}
return rv;
}
// REF.PHP:https://www.php.net/manual/en/function.array-flip.php
public static XophpArray array_flip(XophpArray array) {
XophpArray rv = XophpArray.New();
int len = array.Len();
for (int i = 0; i < len; i++) {
XophpArrayItm itm = array.Get_at_itm(i);
rv.Set(Object_.Xto_str_strict_or_null(itm.Val()), itm.Key());
}
return rv;
}
// REF.PHP:https://www.php.net/manual/en/function.implode.php
public static String implode(String glue, XophpArray pieces) {
String_bldr sb = String_bldr_.new_();
int len = pieces.Len();
for (int i = 0; i < len; i++) {
if (i != 0) sb.Add(glue);
sb.Add(pieces.Get_at_str(i));
}
return sb.To_str_and_clear();
}
// REF.PHP: https://www.php.net/manual/en/function.in-array.php
public static boolean in_array(Object needle, XophpArray haystack) {return in_array(needle, haystack, false);}
public static boolean in_array(Object needle, XophpArray haystack, boolean strict) {
// if strict, cache needleType
Class<?> needleType = null;
if (strict && needle != null) {
needleType = Type_.Type_by_obj(needle);
}
// loop haystack to find match
int haystack_len = haystack.Len();
for (int i = 0; i < haystack_len; i++) {
Object val = haystack.Get_at(i);
// if strict, compare types
if (strict) {
if (needle != null && val == null) {
return false;
}
else if (needle == null && val != null) {
return false;
}
else if (needle != null && val != null) {
if (!Type_.Eq_by_obj(val, needleType)) {
return false;
}
}
}
// compare objects
if (Object_.Eq(needle, val)) {
return true;
}
}
return false;
}
// REF.PHP: https://www.php.net/manual/en/function.array-shift.php
// Returns the shifted value, or NULL if array is empty or is not an array.
public static Object array_shift(XophpArray array) {
if (array == null) {
return null;
}
int len = array.Len();
if (len == 0) {
return null;
}
XophpArrayItm[] itms = array.To_ary();
array.Clear();
int idx = 0;
for (int i = 1; i < len; i++) {
XophpArrayItm itm = itms[i];
if (itm.KeyIsInt()) {
array.Add(idx++, itm.Val());
}
else {
array.Add(itm.Key(), itm.Val());
}
}
return itms[0].Val();
}
// REF.PHP: https://www.php.net/manual/en/function.array-filter.php
public static final int ARRAY_FILTER_USE_BOTH = 1, ARRAY_FILTER_USE_KEY = 2, ARRAY_FILTER_USE_VAL = 0; // XO:USE_VAL is not PHP
public static XophpArray array_filter(XophpArray array) {return array_filter(array, NULL_CALLBACK, 0);}
public static XophpArray array_filter(XophpArray array, XophpCallback callback) {return array_filter(array, callback, 0);}
public static XophpArray array_filter(XophpArray array, XophpCallback callback, int flag) {
XophpArray rv = new XophpArray();
int len = array.Len();
for (int i = 0; i < len; i++) {
XophpArrayItm itm = array.Get_at_itm(i);
boolean filter = false;
switch (flag) {
case ARRAY_FILTER_USE_VAL:
filter = Bool_.Cast(callback.Call(itm.Val()));
break;
case ARRAY_FILTER_USE_KEY:
filter = Bool_.Cast(callback.Call(itm.Key()));
break;
case ARRAY_FILTER_USE_BOTH:
filter = Bool_.Cast(callback.Call(itm.Key(), itm.Val()));
break;
}
if (filter)
rv.Add(itm.Key(), itm.Val());
}
return rv;
}
public static XophpCallback NULL_CALLBACK = new XophpCallback(new XophpArray.XophpArrayFilterNullCallback(), "");
static class XophpArrayFilterNullCallback implements XophpCallbackOwner {
public Object Call(String method, Object... args) {
if (args.length != 1) throw new XophpRuntimeException("ArrayFilterNullCallback requires 1 arg");
Object arg = args[0];
return !XophpObject_.empty_obj(arg);
}
}
}

@ -1,30 +1,38 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
import gplx.core.brys.*;
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki;
import gplx.Bool_;
import gplx.Bry_bfr;
import gplx.Int_;
import gplx.Object_;
import gplx.String_;
import gplx.Type_;
import gplx.core.brys.Bry_bfr_able;
public class XophpArrayItm implements Bry_bfr_able {
XophpArrayItm(boolean key_is_int, int key_as_int, String key, Object val) {
this.key_is_int = key_is_int;
this.key_as_int = key_as_int;
XophpArrayItm(boolean keyIsInt, int keyAsInt, String key, Object val) {
this.keyIsInt = keyIsInt;
this.keyAsInt = keyAsInt;
this.key = key;
this.val = val;
}
public boolean Key_is_int() {return key_is_int;} private final boolean key_is_int;
public int Key_as_int() {return key_as_int;} private final int key_as_int;
public String Key() {return key;} private final String key;
public boolean KeyIsInt() {return keyIsInt;} private final boolean keyIsInt;
public int KeyAsInt() {return keyAsInt;} private final int keyAsInt;
public String Key() {return key;} private final String key;
public Object Val() {return val;} public void Val_(Object v) {this.val = v;} private Object val;
public void To_bfr(Bry_bfr bfr) {
@ -44,8 +52,8 @@ public class XophpArrayItm implements Bry_bfr_able {
XophpArrayItm comp = (XophpArrayItm)obj;
// compare key
if (key_is_int) {
if (this.key_as_int != comp.key_as_int)
if (keyIsInt) {
if (this.keyAsInt != comp.keyAsInt)
return false;
}
else {
@ -65,11 +73,12 @@ public class XophpArrayItm implements Bry_bfr_able {
}
@Override public int hashCode() {
int rv = 0;
rv = (31 * rv) + (key_is_int ? key_as_int : key.hashCode());
rv = (31 * rv) + (keyIsInt ? keyAsInt : key.hashCode());
rv = (31 * rv) + val.hashCode();
return rv;
}
public static XophpArrayItm New_int(int key, Object val) {return new XophpArrayItm(Bool_.Y, key, Int_.To_str(key), val);}
public static XophpArrayItm New_str(String key, Object val) {return new XophpArrayItm(Bool_.N, -1, key , val);}
private static final int NULL_KEY_INT = -1;
public static XophpArrayItm NewInt(int key, Object val) {return new XophpArrayItm(Bool_.Y, key, Int_.To_str(key), val);}
public static XophpArrayItm NewStr(String key, Object val) {return new XophpArrayItm(Bool_.N, NULL_KEY_INT, key, val);}
}

@ -1,325 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki;
import gplx.*;
import gplx.core.strings.*;
public class XophpArray_ {
// REF.PHP:https://www.php.net/manual/en/function.array-merge.php
public static XophpArray array_merge(XophpArray... vals) {
XophpArray rv = new XophpArray();
for (XophpArray ary : vals) {
XophpArrayItm[] itms = ary.To_ary();
for (XophpArrayItm itm : itms) {
array_itm_add(rv, itm);
}
}
return rv;
}
// REF.PHP:https://www.php.net/manual/en/function.array-merge.php
// "If you want to append array elements from the second array to the first array while not overwriting the elements from the first array and not re-indexing, use the + array union operator:"
public static XophpArray array_add(XophpArray lhs, XophpArray... vals) {
for (XophpArray ary : vals) {
XophpArrayItm[] itms = ary.To_ary();
for (XophpArrayItm itm : itms) {
if (lhs.Has(itm.Key())) {
continue;
}
else {
lhs.Add(itm.Key(), itm.Val());
}
}
}
return lhs;
}
private static void array_itm_add(XophpArray ary, XophpArrayItm itm) {
if (itm.Key_is_int())
ary.Add(itm.Val());
else
ary.Add(itm.Key(), itm.Val());
}
public static XophpArray array_splice(XophpArray src, int bgn) {return array_splice(src, bgn, src.count(), null);}
public static XophpArray array_splice(XophpArray src, int bgn, int len) {return array_splice(src, bgn, len , null);}
public static XophpArray array_splice(XophpArray src, int bgn, int len, XophpArray repl) {
// get itms before clearing it
int src_len = src.count();
XophpArrayItm[] itms = src.To_ary();
src.Clear();
// calc bgn
if (bgn < 0) { // negative bgn should be adusted from src_len; EX: -1 means start at last item
bgn += src_len;
if (bgn < 0) // large negative bgn should be capped at 0; EX: -99
bgn = 0;
}
else if (bgn > src_len) // large positive bgn should be capped at src_len; EX: 99
bgn = src_len;
// add src from 0 to bgn
for (int i = 0; i < bgn; i++) {
array_itm_add(src, itms[i]);
}
// add repl
if (repl != null) {
XophpArrayItm[] repl_itms = repl.To_ary();
for (XophpArrayItm itm : repl_itms) {
array_itm_add(src, itm);
}
}
// calc end
int end;
if (len < 0) { // negative len should be adjusted from src_len; EX: -1 means stop at last itm
end = src_len + len;
if (end < 0) // large_negative len should be capped at 0; EX: -99
end = 0;
}
else { // positive len should be added to bgn to find end
end = bgn + len;
}
if (end < bgn) // end should never be less than bgn; EX: splice(1, -99)
end = bgn;
else if (end > src_len) // end should not be more then end;
end = src_len;
// add src from end to len
for (int i = end; i < src_len; i++) {
array_itm_add(src, itms[i]);
}
// add del to rv
XophpArray rv = new XophpArray();
for (int i = bgn; i < end; i++) {
array_itm_add(rv, itms[i]);
}
return rv;
}
// ( array $array , int $offset [, int $length = NULL [, boolean $preserve_keys = FALSE ]] ) :
public static XophpArray array_slice(XophpArray array, int offset) {return array_slice(array, offset, array.count());}
public static XophpArray array_slice(XophpArray array, int offset, int length) {
XophpArray rv = new XophpArray();
int end = offset + length;
for (int i = offset; i< end; i++) {
rv.Add(array.Get_at(i));
}
return rv;
}
public static XophpArray<String> array_keys(XophpArray array) {
XophpArray rv = XophpArray.New();
int len = array.count();
for (int i = 0; i < len; i++) {
XophpArrayItm itm = array.Get_at_itm(i);
rv.Add(itm.Key());
}
return rv;
}
public static XophpArray array_values(XophpArray array) {
XophpArray rv = XophpArray.New();
int len = array.count();
for (int i = 0; i < len; i++) {
XophpArrayItm itm = array.Get_at_itm(i);
rv.Add(itm.Val());
}
return rv;
}
// DEPRECATE:use XophpArray
public static boolean popBoolOrN(List_adp list) {return Bool_.Cast(List_adp_.Pop_or(list, false));}
public static byte[] popBryOrNull(List_adp list) {return (byte[])List_adp_.Pop_or(list, null);}
public static String[] array_keys_str(Ordered_hash array) {
int len = array.Len();
String[] rv = new String[len];
for (int i = 0; i < len; i++) {
rv[i] = (String)array.Get_at(i);
}
return rv;
}
public static byte[][] array_keys_bry(Ordered_hash array) {
int len = array.Len();
byte[][] rv = new byte[len][];
for (int i = 0; i < len; i++) {
rv[i] = (byte[])array.Get_at(i);
}
return rv;
}
public static boolean array_key_exists(int key, Ordered_hash array) {return array.Has(key);}
public static boolean array_key_exists(String key, Ordered_hash array) {return array.Has(key);}
public static boolean array_key_exists(byte[] key, Ordered_hash array) {return array.Has(key);}
public static boolean empty(Ordered_hash array) {
return array.Len() == 0;
}
public static boolean empty(XophpArray array) {
return array.Len() == 0;
}
public static boolean array_key_exists(String key, XophpArray array) {return array.Has(key);}
public static boolean array_key_exists(int key, XophpArray array) {return array.Has(Int_.To_str(key));}
public static void unset(XophpArray array, String s) {array.unset(s);}
public static void unset(XophpArray array, int i) {array.unset(i);}
public static void unset(Ordered_hash array, Object key) {
array.Del(key);
}
public static Object[] unset_by_idx(Object[] ary, int idx) {
int ary_len = ary.length;
Object[] rv = new Object[ary_len];
for (int i = 0; i < idx; i++)
rv[i] = ary[i];
for (int i = idx + 1; i < ary_len; i++)
rv[i - 1] = ary[i];
return rv;
}
// REF.PHP:https://www.php.net/manual/en/function.array-map.php
public static XophpArray array_map(XophpCallbackOwner callback_owner, String method, XophpArray array) {
XophpArray rv = XophpArray.New();
int len = array.count();
for (int i = 0; i < len; i++) {
String itm = array.Get_at_str(i);
rv.Add((String)callback_owner.Call(method, itm));
}
return rv;
}
// REF.PHP:https://www.php.net/manual/en/function.array-flip.php
public static XophpArray array_flip(XophpArray array) {
XophpArray rv = XophpArray.New();
int len = array.count();
for (int i = 0; i < len; i++) {
XophpArrayItm itm = array.Get_at_itm(i);
rv.Set(Object_.Xto_str_strict_or_null(itm.Val()), itm.Key());
}
return rv;
}
// REF.PHP:https://www.php.net/manual/en/function.implode.php
public static String implode(String glue, XophpArray pieces) {
String_bldr sb = String_bldr_.new_();
int len = pieces.count();
for (int i = 0; i < len; i++) {
if (i != 0) sb.Add(glue);
sb.Add(pieces.Get_at_str(i));
}
return sb.To_str_and_clear();
}
public static int count(XophpArray array) {return array.count();}
public static boolean count_bool(XophpArray array) {return array.count_bool();}
public static Object array_pop(XophpArray array) {return array.pop();}
public static boolean isset(XophpArray array, int key) {return XophpObject_.isset_obj(array.Get_at(key));}
public static boolean isset(XophpArray array, String key) {return XophpObject_.isset_obj(array.Get_by(key));}
public static boolean is_array(Object array) {return XophpType_.instance_of(array, XophpArray.class);}
// REF.PHP: https://www.php.net/manual/en/function.in-array.php
public static boolean in_array(Object needle, XophpArray haystack) {return in_array(needle, haystack, false);}
public static boolean in_array(Object needle, XophpArray haystack, boolean strict) {
// if strict, cache needleType
Class<?> needleType = null;
if (strict && needle != null) {
needleType = Type_.Type_by_obj(needle);
}
// loop haystack to find match
int haystack_len = haystack.Len();
for (int i = 0; i < haystack_len; i++) {
Object val = haystack.Get_at(i);
// if strict, compare types
if (strict) {
if (needle != null && val == null) {
return false;
}
else if (needle == null && val != null) {
return false;
}
else if (needle != null && val != null) {
if (!Type_.Eq_by_obj(val, needleType)) {
return false;
}
}
}
// compare objects
if (Object_.Eq(needle, val)) {
return true;
}
}
return false;
}
// REF.PHP: https://www.php.net/manual/en/function.array-shift.php
// Returns the shifted value, or NULL if array is empty or is not an array.
public static Object array_shift(XophpArray array) {
if (array == null) {
return null;
}
int len = array.Len();
if (len == 0) {
return null;
}
XophpArrayItm[] itms = array.To_ary();
array.Clear();
int idx = 0;
for (int i = 1; i < len; i++) {
XophpArrayItm itm = itms[i];
if (itm.Key_is_int()) {
array.Add(idx++, itm.Val());
}
else {
array.Add(itm.Key(), itm.Val());
}
}
return itms[0].Val();
}
// REF.PHP: https://www.php.net/manual/en/function.array-filter.php
public static final int ARRAY_FILTER_USE_BOTH = 1, ARRAY_FILTER_USE_KEY = 2, ARRAY_FILTER_USE_VAL = 0; // XO:USE_VAL is not PHP
public static XophpArray array_filter(XophpArray array) {return array_filter(array, XophpArrayFilterNullCallback.Instance, 0);}
public static XophpArray array_filter(XophpArray array, XophpCallback callback) {return array_filter(array, callback, 0);}
public static XophpArray array_filter(XophpArray array, XophpCallback callback, int flag) {
XophpArray rv = new XophpArray();
int len = array.count();
for (int i = 0; i < len; i++) {
XophpArrayItm itm = array.Get_at_itm(i);
boolean filter = false;
switch (flag) {
case ARRAY_FILTER_USE_VAL:
filter = Bool_.Cast(callback.Call(itm.Val()));
break;
case ARRAY_FILTER_USE_KEY:
filter = Bool_.Cast(callback.Call(itm.Key()));
break;
case ARRAY_FILTER_USE_BOTH:
filter = Bool_.Cast(callback.Call(itm.Key(), itm.Val()));
break;
}
if (filter)
rv.Add(itm.Key(), itm.Val());
}
return rv;
}
}
class XophpArrayFilterNullCallback implements XophpCallbackOwner {
public Object Call(String method, Object... args) {
if (args.length != 1) throw new XophpRuntimeException("ArrayFilterNullCallback requires 1 arg");
Object arg = args[0];
return !XophpObject_.empty_obj(arg);
}
public static XophpCallback Instance = new XophpCallback(new XophpArrayFilterNullCallback(), "");
}

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.extensions.JsonConfig.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.JsonConfig.*;
import gplx.xowa.xtns.scribunto.*;
import gplx.xowa.mediawiki.*;
@ -181,9 +181,9 @@ public class JCValue {
else if (value_tid == Value_tid__ary && (fld_type == Type_ids_.Id__str || fld_type == Type_ids_.Id__int)) {
tmp = value_as_ary.Get_by_obj(fld);
if (fld_type == Type_ids_.Id__str)
value_as_ary.unset((String)fld);
XophpArray.unset(value_as_ary, (String)fld);
else
value_as_ary.unset(Int_.Cast(fld));
XophpArray.unset(value_as_ary, Int_.Cast(fld));
value.Del(fld);
}
else {

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.extensions.Wikibase.lib.includes.Store; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.lib.*; import gplx.xowa.mediawiki.extensions.Wikibase.lib.includes.*;
import gplx.langs.regxs.*;
// REF.WBASE:2020-01-19
@ -38,7 +38,7 @@ abstract class XomwWikiTextPropertyOrderProvider implements XomwPropertyOrderPro
}
XophpArray parsedList = this.parseList(pageContent);
return XophpArray_.array_flip(parsedList);
return XophpArray.array_flip(parsedList);
}
/**
@ -65,7 +65,7 @@ abstract class XomwWikiTextPropertyOrderProvider implements XomwPropertyOrderPro
XophpRegex_.PREG_PATTERN_ORDER
);
XophpArray orderedProperties = XophpArray_.array_map(XophpString_.Callback_owner, "strtoupper", (XophpArray)orderedPropertiesMatches.Get_at_ary(1));
XophpArray orderedProperties = XophpArray.array_map(XophpString_.Callback_owner, "strtoupper", (XophpArray)orderedPropertiesMatches.Get_at_ary(1));
return orderedProperties;
}

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*;
// MW.SRC:1.33
public class XomwCategoryViewer {// extends ContextSource
@ -560,18 +560,18 @@ public class XomwCategoryViewer {// extends ContextSource
// Kind of like array_flip() here, but we keep duplicates in an
// array instead of dropping them.
int columns_len = columns.count();
int columns_len = XophpArray.count(columns);
for (int i = 0; i < columns_len; i++) {
XophpArrayItm itm = columns.Get_at_itm(i);
String article = itm.Key();
String charVal = (String)itm.Val();
if (!colContents.isset((String)colContents.Get_by(charVal))) {
if (!XophpArray.isset(colContents, (String)colContents.Get_by(charVal))) {
colContents.Set(charVal, XophpArray.New());
}
colContents.Set(charVal, article); // colContents[char][] = article;
}
int colContentsLen = colContents.count();
int colContentsLen = colContents.Len();
for (int i = 0; i < colContentsLen; i++) {
XophpArrayItm itm = columns.Get_at_itm(i);
String charVal = itm.Key();
@ -583,7 +583,7 @@ public class XomwCategoryViewer {// extends ContextSource
ret += "</h3>\n";
ret += "<ul><li>";
ret += XophpArray_.implode("</li>\n<li>", articlesItm);
ret += XophpArray.implode("</li>\n<li>", articlesItm);
ret += "</li></ul></div>";
}

@ -19,7 +19,7 @@ import gplx.String_;
import gplx.core.primitives.String_obj_ref;
import gplx.core.tests.GfoTestMethod;
import gplx.xowa.mediawiki.XophpArray;
import gplx.xowa.mediawiki.XophpArray_;
import gplx.xowa.mediawiki.XophpArray;
import gplx.xowa.mediawiki.XophpCallback;
import gplx.xowa.mediawiki.XophpCallbackOwner;
import gplx.xowa.mediawiki.XophpFatalException;
@ -71,7 +71,7 @@ public class XomwHooks {
// throw new MWException('Cannot reset hooks in operation.');
// }
XophpArray_.unset(handlers, name);
XophpArray.unset(handlers, name);
}
/**
@ -99,12 +99,12 @@ public class XomwHooks {
public static XophpArray getHandlers(String name) {
if (!isRegistered(name)) {
return XophpArray.New();
} else if (!XophpArray_.isset(handlers, name)) {
} else if (!XophpArray.isset(handlers, name)) {
return XomwDefaultSettings.wgHooks.Get_by_ary(name);
} else if (!XophpArray_.isset(XomwDefaultSettings.wgHooks, name)) {
} else if (!XophpArray.isset(XomwDefaultSettings.wgHooks, name)) {
return handlers.Get_by_ary(name);
} else {
return XophpArray_.array_merge(handlers.Get_by_ary(name), XomwDefaultSettings.wgHooks.Get_by_ary(name));
return XophpArray.array_merge(handlers.Get_by_ary(name), XomwDefaultSettings.wgHooks.Get_by_ary(name));
}
}
@ -123,7 +123,7 @@ public class XomwHooks {
) {
XophpArray hook;
// Turn non-array values into an array. (Can't use casting because of objects.)
if (!XophpArray_.is_array(hookObj)) {
if (!XophpArray.is_array(hookObj)) {
hook = XophpArray.New(hookObj);
}
else { // XO: cast it to XophpArray
@ -135,11 +135,11 @@ public class XomwHooks {
return null;
}
if (XophpArray_.is_array(hook.Get_at(0))) {
if (XophpArray.is_array(hook.Get_at(0))) {
// First element is an array, meaning the developer intended
// the first element to be a callback. Merge it in so that
// processing can be uniform.
hook = XophpArray_.array_merge(hook.Get_at_ary(0), XophpArray_.array_slice(hook, 1));
hook = XophpArray.array_merge(hook.Get_at_ary(0), XophpArray.array_slice(hook, 1));
}
/**
@ -150,10 +150,10 @@ public class XomwHooks {
XophpCallback callback = null;
if (XophpType_.instance_of(hook.Get_at(0), XophpCallback.class)) { // XophpClosure
if (fname != null) fname.Val_("hook-" + event + "-closure");
callback = (XophpCallback) XophpArray_.array_shift(hook);
callback = (XophpCallback) XophpArray.array_shift(hook);
} else if (XophpObject_.is_object(hook.Get_at_str(0))) {
XophpCallbackOwner object = (XophpCallbackOwner)XophpArray_.array_shift(hook);
String method = (String)XophpArray_.array_shift(hook);
XophpCallbackOwner object = (XophpCallbackOwner)XophpArray.array_shift(hook);
String method = (String)XophpArray.array_shift(hook);
// If no method was specified, default to on$event.
if (XophpObject_.is_null(method)) {
@ -163,7 +163,7 @@ public class XomwHooks {
if (fname != null) fname.Val_(XophpType_.get_class(object).getName() + "::" + method);
callback = new XophpCallback(object, method);
} else if (XophpString_.is_string(hook.Get_at(0))) {
throw new XomwMWException("XOMW does not support string callbacks! Should not have been passed here!; event={0}; fname={1}\n", event, XophpArray_.array_shift(hook));
throw new XomwMWException("XOMW does not support string callbacks! Should not have been passed here!; event={0}; fname={1}\n", event, XophpArray.array_shift(hook));
} else {
throw new XomwMWException("Unknown datatype in hooks for {0}\n", event);
}
@ -181,7 +181,7 @@ public class XomwHooks {
}
// Call the hook.
XophpArray hook_args = XophpArray_.array_merge(hook, args);
XophpArray hook_args = XophpArray.array_merge(hook, args);
return (String) XophpCallback.call_user_func_array(callback, hook_args);
}
/**
@ -211,7 +211,7 @@ public class XomwHooks {
public static boolean run(String event, XophpArray args) {return run(event, args, null);}
public static boolean run(String event, XophpArray args, String deprecatedVersion) {
XophpArray handlers = getHandlers(event);
for (int i = 0; i < handlers.count(); i++) {
for (int i = 0; i < handlers.Len(); i++) {
XophpCallback hook = (XophpCallback)handlers.Get_at(i);
Object retval = callHook(event, hook, args, deprecatedVersion);
if (retval == null) {
@ -245,7 +245,7 @@ public class XomwHooks {
public static boolean runWithoutAbort(String event) {return runWithoutAbort(event, XophpArray.New(), null);}
public static boolean runWithoutAbort(String event, XophpArray args, String deprecatedVersion) {
XophpArray handlers = getHandlers(event);
int len = handlers.count();
int len = handlers.Len();
for (int i = 0; i < len; i++) {
Object hookObj = handlers.Get_at(i);
String_obj_ref fname = String_obj_ref.empty_();

@ -17,7 +17,7 @@ package gplx.xowa.mediawiki.includes;
import gplx.String_;
import gplx.xowa.mediawiki.XophpArray;
import gplx.xowa.mediawiki.XophpArray_;
import gplx.xowa.mediawiki.XophpArray;
import gplx.xowa.mediawiki.XophpInvalidArgumentException;
import gplx.xowa.mediawiki.XophpObject_;
import gplx.xowa.mediawiki.XophpString_;
@ -266,7 +266,7 @@ class XomwMessage { // implements MessageSpecifier, Serializable
if (XophpString_.is_string(key)) {
this.keysToTry = XophpArray.New(key);
}
else if (XophpArray_.is_array(key)) {
else if (XophpArray.is_array(key)) {
this.keysToTry = (XophpArray)key;
}
else {
@ -274,13 +274,13 @@ class XomwMessage { // implements MessageSpecifier, Serializable
}
// XOMW.TYPE.END
if (XophpArray_.empty(this.keysToTry)) {
if (XophpArray.empty(this.keysToTry)) {
throw new XophpInvalidArgumentException("{0} must not be an empty list", key);
}
this.key = (String)XophpArray.reset(this.keysToTry);
this.parameters = XophpArray_.array_values(params);
this.parameters = XophpArray.array_values(params);
// User language is only resolved in getLanguage(). This helps preserve the
// semantic intent of "user language" across serialize() and unserialize().
this.language = (XomwLanguage)XophpObject_.Elvis(language, null);

@ -18,7 +18,7 @@ package gplx.xowa.mediawiki.includes;
// MW.SRC:1.33.1
import gplx.xowa.mediawiki.XophpArray;
import gplx.xowa.mediawiki.XophpArray_;
import gplx.xowa.mediawiki.XophpArray;
import gplx.xowa.mediawiki.XophpObject_;
import gplx.xowa.mediawiki.XophpString_;
@ -88,7 +88,7 @@ public class XomwWebRequest {
// POST overrides GET data
// We don't use $_REQUEST here to avoid interference from cookies...
this.data = XophpArray_.array_merge(_POST, _GET);
this.data = XophpArray.array_merge(_POST, _GET);
}
// /**
@ -378,9 +378,9 @@ public class XomwWebRequest {
// https://secure.php.net/variables.external#language.variables.external.dot-in-names
// Work around PHP *feature* to avoid *bugs* elsewhere.
name = XophpString_.strtr(name, ".", "_");
if (XophpArray_.isset(arr, name)) {
if (XophpArray.isset(arr, name)) {
Object data = arr.Get_by(name);
if (XophpArray_.isset(_GET, name) && XophpString_.is_string(data)) {
if (XophpArray.isset(_GET, name) && XophpString_.is_string(data)) {
// Check for alternate/legacy character encoding.
// $contLang = MediaWikiServices::getInstance().getContentLanguage();
// $data = $contLang.checkTitleEncoding($data);

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.cache.localisation; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.cache.*;
// MW.SRC:1.33
import gplx.xowa.mediawiki.xml.*;
@ -250,11 +250,11 @@ public class XomwLocalisationCache {
* @return mixed
*/
public Object getItem(String code, String key) {
if (!this.loadedItems.Get_by_ary(code).isset(key)) {
if (!XophpArray.isset(this.loadedItems.Get_by_ary(code), key)) {
// this.loadItem(code, key);
}
if (String_.Eq(key, "fallback") && this.shallowFallbacks.isset(code)) {
if (String_.Eq(key, "fallback") && XophpArray.isset(this.shallowFallbacks, code)) {
return this.shallowFallbacks.Get_by(code);
}

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.content; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import gplx.core.brys.*;
public abstract class ContentHandler {
@ -532,7 +532,7 @@ public abstract class ContentHandler {
return true; // this means "use the default"
}
return XophpArray_.in_array(format, this.mSupportedFormats);
return XophpArray.in_array(format, this.mSupportedFormats);
}
/**

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.interwiki; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import gplx.xowa.mediawiki.includes.site.*;
public class XomwInterwikiLookupAdapter implements XomwInterwikiLookup {
@ -41,7 +41,7 @@ public class XomwInterwikiLookupAdapter implements XomwInterwikiLookup {
* @return boolean Whether it exists
*/
public boolean isValidInterwiki(byte[] prefix) {
return XophpArray_.array_key_exists(prefix, this.getInterwikiMap());
return XophpArray.array_key_exists(prefix, this.getInterwikiMap());
}
/**
@ -71,7 +71,7 @@ public class XomwInterwikiLookupAdapter implements XomwInterwikiLookup {
*/
public byte[][] getAllPrefixes(boolean local) {
if (!local) {
XophpArray_.array_keys_bry(this.getInterwikiMap());
XophpArray.array_keys_bry(this.getInterwikiMap());
}
List_adp res = List_adp_.New();
Ordered_hash hash = this.getInterwikiMap();

@ -16,7 +16,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
package gplx.xowa.mediawiki.includes.libs.services;
import gplx.xowa.mediawiki.XophpArray;
import gplx.xowa.mediawiki.XophpArray_;
import gplx.xowa.mediawiki.XophpArray;
import gplx.xowa.mediawiki.XophpCallback;
import gplx.xowa.mediawiki.XophpObject_;
import gplx.xowa.mediawiki.XophpType_;
@ -154,24 +154,24 @@ public class XomwServiceContainer implements XomwDestructibleService {
*/
public void importWiring(XomwServiceContainer container) {this.importWiring(container, new XophpArray<>());}
public void importWiring(XomwServiceContainer container, XophpArray<String> skip) {
// XophpArray<String> newInstantiators = XophpArray_.array_diff_key(
// XophpArray<String> newInstantiators = XophpArray.array_diff_key(
// container.serviceInstantiators,
// XophpArray_.array_flip(skip)
// XophpArray.array_flip(skip)
// );
//
// this.serviceInstantiators = XophpArray_.array_merge(
// this.serviceInstantiators = XophpArray.array_merge(
// this.serviceInstantiators,
// newInstantiators
// );
//
// XophpArray<String> newManipulators = XophpArray_.array_diff(
// XophpArray_.array_keys(container.serviceManipulators),
// XophpArray<String> newManipulators = XophpArray.array_diff(
// XophpArray.array_keys(container.serviceManipulators),
// skip
// );
//
// for (String name : newManipulators) {
// if (XophpArray_.isset(this.serviceManipulators, name)) {
// this.serviceManipulators.Set(name, XophpArray_.array_merge(
// if (XophpArray.isset(this.serviceManipulators, name)) {
// this.serviceManipulators.Set(name, XophpArray.array_merge(
// this.serviceManipulators.Get_by(name),
// container.serviceManipulators.Get_by(name)
// ));
@ -190,7 +190,7 @@ public class XomwServiceContainer implements XomwDestructibleService {
* @return bool
*/
public boolean hasService(String name) {
return XophpArray_.isset(this.serviceInstantiators, name);
return XophpArray.isset(this.serviceInstantiators, name);
}
/**
@ -220,7 +220,7 @@ public class XomwServiceContainer implements XomwDestructibleService {
* @return string[]
*/
public XophpArray<String> getServiceNames() {
return XophpArray_.array_keys(this.serviceInstantiators);
return XophpArray.array_keys(this.serviceInstantiators);
}
/**
@ -273,12 +273,12 @@ public class XomwServiceContainer implements XomwDestructibleService {
throw new XomwNoSuchServiceException(name);
}
if (XophpArray_.isset(this.services, name)) {
if (XophpArray.isset(this.services, name)) {
throw new XomwCannotReplaceActiveServiceException(name);
}
this.serviceInstantiators.Set(name, instantiator);
XophpArray_.unset(this.disabled, name);
XophpArray.unset(this.disabled, name);
}
/**
@ -314,7 +314,7 @@ public class XomwServiceContainer implements XomwDestructibleService {
throw new XomwNoSuchServiceException(name);
}
if (XophpArray_.isset(this.services, name)) {
if (XophpArray.isset(this.services, name)) {
throw new XomwCannotReplaceActiveServiceException(name);
}
@ -379,8 +379,8 @@ public class XomwServiceContainer implements XomwDestructibleService {
((XomwDestructibleService)instance).destroy();
}
XophpArray_.unset(this.services, name);
XophpArray_.unset(this.disabled, name);
XophpArray.unset(this.services, name);
XophpArray.unset(this.disabled, name);
}
/**
@ -408,11 +408,11 @@ public class XomwServiceContainer implements XomwDestructibleService {
throw new XomwContainerDisabledException();
}
if (XophpArray_.isset(this.disabled, name)) {
if (XophpArray.isset(this.disabled, name)) {
throw new XomwServiceDisabledException(name);
}
if (!XophpArray_.isset(this.services, name)) {
if (!XophpArray.isset(this.services, name)) {
this.services.Set(name, this.createService(name));
}
@ -427,18 +427,18 @@ public class XomwServiceContainer implements XomwDestructibleService {
*/
private Object createService(String name) {
Object service;
if (XophpArray_.isset(this.serviceInstantiators, name)) {
if (XophpArray.isset(this.serviceInstantiators, name)) {
service = (this.serviceInstantiators.Get_by(name)).Call(
this,
this.extraInstantiationParams
);
if (XophpArray_.isset(this.serviceManipulators, name)) {
if (XophpArray.isset(this.serviceManipulators, name)) {
Object ret;
for (XophpCallback callback : this.serviceManipulators.Get_by(name)) {
ret = XophpCallback.call_user_func_array(
callback,
XophpArray_.array_merge(XophpArray.New(service, this), this.extraInstantiationParams)
XophpArray.array_merge(XophpArray.New(service, this), this.extraInstantiationParams)
);
// If the manipulator callback returns an object, that object replaces
@ -464,6 +464,6 @@ public class XomwServiceContainer implements XomwDestructibleService {
* @since 1.28
*/
public boolean isServiceDisabled(String name) {
return XophpArray_.isset(this.disabled, name);
return XophpArray.isset(this.disabled, name);
}
}

@ -4051,29 +4051,29 @@ public class XomwParser implements XomwParserIface {
// result = this.callParserFunction(frame, func, funcArgs);
// Extract any forwarded flags
if (XophpArray_.isset(result, "title")) {
if (XophpArray.isset(result, "title")) {
title = (XomwTitleOld)result.Get_by("title");
}
if (XophpArray_.isset(result, "found")) {
if (XophpArray.isset(result, "found")) {
found = result.Get_by_bool("found");
}
if (XophpArray_.array_key_exists("text", result)) {
if (XophpArray.array_key_exists("text", result)) {
// a String or null
text = result.Get_by_str("text");
}
if (XophpArray_.isset(result, "nowiki")) {
if (XophpArray.isset(result, "nowiki")) {
nowiki = result.Get_by_bool("nowiki");
}
if (XophpArray_.isset(result, "isHTML")) {
if (XophpArray.isset(result, "isHTML")) {
isHTML = result.Get_by_bool("isHTML");
}
if (XophpArray_.isset(result, "forceRawInterwiki")) {
if (XophpArray.isset(result, "forceRawInterwiki")) {
forceRawInterwiki = result.Get_by_bool("forceRawInterwiki");
}
if (XophpArray_.isset(result, "isChildObj")) {
if (XophpArray.isset(result, "isChildObj")) {
isChildObj = result.Get_by_bool("isChildObj");
}
if (XophpArray_.isset(result, "isLocalObj")) {
if (XophpArray.isset(result, "isLocalObj")) {
isLocalObj = result.Get_by_bool("isLocalObj");
}
}

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import gplx.core.btries.*;
import gplx.xowa.mediawiki.includes.parsers.preprocessors.*;
@ -118,7 +118,7 @@ class XomwPreprocessor_DOM extends XomwPreprocessor { private final Bry_bfr
tmp_bfr.Add_str_a7("<title>").Add(title).Add_str_a7("</title>");
int arg_idx = 1;
int parts_len = parts.count();
int parts_len = parts.Len();
for (int j = 0; j < parts_len; j++) {
XomwPPDPart_DOM part = (XomwPPDPart_DOM)parts.Get_at(j);
if (part.eqpos != 0) {
@ -144,7 +144,7 @@ class XomwPreprocessor_DOM extends XomwPreprocessor { private final Bry_bfr
}
@Override protected Object preprocessToObj_term(XomwPPDStack stack) {
Bry_bfr root_accum = Bry_bfr_.New().Add_str_u8(((Xomw_prepro_accum__dom)stack.Get_root_accum()).To_str());
int stack_len = stack.stack.count();
int stack_len = stack.stack.Len();
for (int j = 0; j < stack_len; j++) {
// XomwPPDStackElement_Hash piece = (XomwPPDStackElement_Hash)stack.stack.Get_at(j);
// root_accum.Add((XophpArray)piece.breakSyntax(tmp_bfr));

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import gplx.xowa.mediawiki.includes.parsers.preprocessors.*;
class XomwPreprocessor_Hash extends XomwPreprocessor { private XophpArray accum;
@ -55,7 +55,7 @@ class XomwPreprocessor_Hash extends XomwPreprocessor { private XophpArray accum
accum.Add(XophpArray.New("comment", XophpArray.New(XophpString_.substr(src, bgn, end - bgn))));
}
@Override protected void preprocessToObj_removeLeadingWhitespaceFromEnd(int ws_len) {
int endIndex = accum.count() - 1;
int endIndex = accum.Len() - 1;
if ( ws_len > 0
&& endIndex >= 0) {
Object itm_obj = accum.Get_at(endIndex);
@ -86,7 +86,7 @@ class XomwPreprocessor_Hash extends XomwPreprocessor { private XophpArray accum
rv.Ary().Add
( XophpArray.New
( "h",
XophpArray_.array_merge
XophpArray.array_merge
( XophpArray.New
( XophpArray.New("@level", XophpArray.New(count))
, XophpArray.New("@i" , XophpArray.New(heading_index))
@ -98,7 +98,7 @@ class XomwPreprocessor_Hash extends XomwPreprocessor { private XophpArray accum
return rv;
}
@Override protected void preprocessToObj_heading_end(Xomw_prepro_accum element) {
XophpArray_.array_splice(accum, accum.count(), 0, ((Xomw_prepro_accum__hash)element).Ary());
XophpArray.array_splice(accum, XophpArray.count(accum), 0, ((Xomw_prepro_accum__hash)element).Ary());
}
@Override protected Xomw_prepro_accum preprocessToObj_text(XomwPPDStackElement piece, byte[] rule_end, int matching_count) {
@ -122,14 +122,14 @@ class XomwPreprocessor_Hash extends XomwPreprocessor { private XophpArray accum
children.Add(titleNode);
int argIndex = 1;
int parts_len = parts.count();
int parts_len = parts.Len();
for (int j = 0; j < parts_len; j++) {
XomwPPDPart_Hash part = (XomwPPDPart_Hash)parts.Get_at(j);
XophpArray part_out = (XophpArray)part.Accum_hash().Ary();
if (part.eqpos != 0) {
Object equalsNode = part_out.Get_at(part.eqpos);
XophpArray nameNode = XophpArray.New("name" , XophpArray_.array_slice(part_out, 0, part.eqpos));
XophpArray valueNode = XophpArray.New("value", XophpArray_.array_slice(part_out, part.eqpos + 1));
XophpArray nameNode = XophpArray.New("name" , XophpArray.array_slice(part_out, 0, part.eqpos));
XophpArray valueNode = XophpArray.New("value", XophpArray.array_slice(part_out, part.eqpos + 1));
XophpArray partNode = XophpArray.New("part" , XophpArray.New(nameNode, equalsNode, valueNode));
children.Add(partNode);
}
@ -144,19 +144,19 @@ class XomwPreprocessor_Hash extends XomwPreprocessor { private XophpArray accum
return new Xomw_prepro_accum__hash(element);
}
@Override protected void preprocessToObj_add_element(Xomw_prepro_accum element) {
XophpArray_.array_splice(accum, accum.count(), 0, ((Xomw_prepro_accum__hash)element).Ary());
XophpArray.array_splice(accum, XophpArray.count(accum), 0, ((Xomw_prepro_accum__hash)element).Ary());
}
@Override protected void preprocessToObj_equals(XomwPPDStack stack) {
accum.Add(XophpArray.New("equals", XophpArray.New("=")));
stack.getCurrentPart().eqpos = accum.count() - 1;
stack.getCurrentPart().eqpos = XophpArray.count(accum) - 1;
}
@Override protected Object preprocessToObj_term(XomwPPDStack stack) {
Xomw_prepro_accum__hash stack_accum = (Xomw_prepro_accum__hash)stack.getAccum();
XophpArray stack_ary = stack_accum.Ary();
int len = stack_ary.count();
int len = stack_ary.Len();
for (int i = 0; i < len; i++) {
// XomwPPDPart_Hash piece = (XomwPPDPart_Hash)(stack_ary.Get_at(i).Val());
// XophpArray_.array_splice(stack_ary, stack_ary.Len(), 0, piece.breakSyntax());
// XophpArray.array_splice(stack_ary, stack_ary.Len(), 0, piece.breakSyntax());
}
// for ( $stack->stack as $piece ) {
// array_splice( $stack->rootAccum, count( $stack->rootAccum ), 0, $piece->breakSyntax() );
@ -184,7 +184,7 @@ class XomwPreprocessor_Hash extends XomwPreprocessor { private XophpArray accum
private static void addLiteral(XophpArray accum, byte[] text) {addLiteral(accum, String_.new_u8(text));}
private static void addLiteral(XophpArray accum, String text) {
int n = accum.count();
int n = accum.Len();
Object itm = accum.Get_at(n - 1);
if (n > 0 && XophpType_.is_string(itm)) {
accum.Set(n - 1, ((String)itm) + text);

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.parsers.preprocessors; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
import gplx.xowa.mediawiki.includes.exception.*;
// MW.FILE:Preprocessor
@ -43,7 +43,7 @@ public class XomwPPDStack {
* @return int
*/
public int count() {
return this.stack.count();
return XophpArray.count(this.stack);
}
public Xomw_prepro_accum getAccum() {
@ -65,17 +65,17 @@ public class XomwPPDStack {
// $class = this.elementClass;
// this.stack[] = new $class($data);
// }
this.top = (XomwPPDStackElement)this.stack.Get_at(this.stack.count() - 1);
this.top = (XomwPPDStackElement)this.stack.Get_at(XophpArray.count(this.stack) - 1);
this.accum = this.top.getAccum();
}
public XomwPPDStackElement pop() {
if (this.stack.count() == 0) {
if (XophpArray.count(this.stack) == 0) {
throw XomwMWException.New_by_method(XomwPPDStack.class, "pop", "no elements remaining");
}
XomwPPDStackElement temp = (XomwPPDStackElement)this.stack.pop();
if (this.stack.count()> 0) {
this.top = (XomwPPDStackElement)this.stack.Get_at(this.stack.count() - 1);
XomwPPDStackElement temp = (XomwPPDStackElement)XophpArray.array_pop(this.stack);
if (XophpArray.count(this.stack)> 0) {
this.top = (XomwPPDStackElement)this.stack.Get_at(XophpArray.count(this.stack) - 1);
this.accum = this.top.getAccum();
} else {
this.top = null;
@ -93,7 +93,7 @@ public class XomwPPDStack {
* @return array
*/
public XomwPPDStackElementFlags getFlags() {
if (this.stack.count() == 0) {
if (XophpArray.count(this.stack) == 0) {
return XomwPPDStackElementFlags.Empty;
}
else {

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.parsers.preprocessors; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
// MW.FILE:Preprocessor
/**
@ -63,7 +63,7 @@ public class XomwPPDStackElement {
}
public Xomw_prepro_accum getAccum() {
return (Xomw_prepro_accum)Get_at(this.parts.count() - 1).Accum();
return (Xomw_prepro_accum)Get_at(XophpArray.count(this.parts) - 1).Accum();
}
public void addPart(String s) {
@ -74,14 +74,14 @@ public class XomwPPDStackElement {
}
public XomwPPDPart getCurrentPart() {
return (XomwPPDPart)Get_at(this.parts.count() - 1);
return (XomwPPDPart)Get_at(XophpArray.count(this.parts) - 1);
}
/**
* @return array
*/
public XomwPPDStackElementFlags getFlags() {
int partCount = this.parts.count();
int partCount = XophpArray.count(this.parts);
boolean findPipe = String_.EqNot(this.open, "\n") && String_.EqNot(this.open, "[");
return new XomwPPDStackElementFlags
( findPipe
@ -108,7 +108,7 @@ public class XomwPPDStackElement {
}
bfr.Add_str(XophpString_.str_repeat(this.open, openingCount));
boolean first = true;
int parts_len = parts.count();
int parts_len = parts.Len();
for (int i = 0; i < parts_len; i++) {
XomwPPDPart_DOM part = (XomwPPDPart_DOM)Get_at(i);
if (first) {

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.parsers.preprocessors; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
// MW.FILE:Preprocessor_Hash
/**
@ -42,7 +42,7 @@ public class XomwPPDStackElement_Hash extends XomwPPDStackElement { public Xomw
accum = XophpArray.New(XophpString_.str_repeat(this.open, openingCount));
int lastIndex = 0;
boolean first = true;
int parts_len = parts.count();
int parts_len = parts.Len();
for (int i = 0; i < parts_len; i++) {
XomwPPDPart_Hash part = Get_at_hash(i);
if (first) {
@ -55,7 +55,7 @@ public class XomwPPDStackElement_Hash extends XomwPPDStackElement { public Xomw
}
XophpArray part_out = ((Xomw_prepro_accum__hash)part.Accum()).Ary();
int part_out_len = part_out.count();
int part_out_len = part_out.Len();
for (int j = 0; j < part_out_len; j++) {
Object node = part_out.Get_at(j);
if (XophpType_.is_string(node) && XophpType_.is_string(accum.Get_at(lastIndex))) {

@ -97,14 +97,14 @@ public class XomwPPFrame_Hash extends XomwPPFrame { /**
args = (XophpArray)argsObj;
}
int argsLen = args.count();
int argsLen = args.Len();
for (int i = 0; i < argsLen; i++) {
XomwPPNode arg = (XomwPPNode)args.Get_at(i);
XophpArray bits = arg.splitArg();
if (bits.Has("index")) {
// Numbered parameter
int index = bits.Get_by_int("index") - indexOffset;
if (namedArgs.isset(index) || numberedArgs.isset(index)) {
if (XophpArray.isset(namedArgs, index) || XophpArray.isset(numberedArgs, index)) {
// this.parser.getOutput().addWarning(wfMessage('duplicate-args-warning',
// wfEscapeWikiText(this.title),
// wfEscapeWikiText(title),
@ -112,11 +112,11 @@ public class XomwPPFrame_Hash extends XomwPPFrame { /**
// this.parser.addTrackingCategory('duplicate-args-category');
}
numberedArgs.Set(index, bits.Get_by("value"));
namedArgs.unset(index);
XophpArray.unset(namedArgs, index);
} else {
// Named parameter
String name = String_.Trim(this.expand(bits.Get_by("name"), XomwPPFrame.STRIP_COMMENTS));
if (namedArgs.isset(name) || numberedArgs.isset(name)) {
if (XophpArray.isset(namedArgs, name) || XophpArray.isset(numberedArgs, name)) {
// this.parser.getOutput().addWarning(wfMessage('duplicate-args-warning',
// wfEscapeWikiText(this.title),
// wfEscapeWikiText(title),
@ -124,7 +124,7 @@ public class XomwPPFrame_Hash extends XomwPPFrame { /**
// this.parser.addTrackingCategory('duplicate-args-category');
}
namedArgs.Set(name, bits.Get_by("value"));
numberedArgs.unset(name);
XophpArray.unset(numberedArgs, name);
}
}
}
@ -179,15 +179,15 @@ public class XomwPPFrame_Hash extends XomwPPFrame { /**
XophpArray iteratorStack = XophpArray.New(XophpObject_.False, root);
XophpArray indexStack = XophpArray.New(0, 0);
while (iteratorStack.count() > 1) {
int level = outStack.count() - 1;
while (XophpArray.count(iteratorStack) > 1) {
int level = XophpArray.count(outStack) - 1;
Object iteratorNode = iteratorStack.Get_at(level);
String outItm = outStack.Get_at_str(level);
int index = indexStack.Get_at_int(level);
Object contextNode;
if (XophpArray.is_array(iteratorNode)) {
XophpArray iteratorNodeArray = (XophpArray)iteratorNode;
if (index >= iteratorNodeArray.count()) {
if (index >= XophpArray.count(iteratorNodeArray)) {
// All done with this iterator
iteratorStack.Set(level, XophpObject_.False);
contextNode = XophpObject_.False;
@ -233,7 +233,7 @@ public class XomwPPFrame_Hash extends XomwPPFrame { /**
} else if (XophpArray.is_array(contextNode)) {
XophpArray contextNodeArray = (XophpArray)contextNode;
// Node descriptor array
if (contextNodeArray.count() != 2) {
if (XophpArray.count(contextNodeArray) != 2) {
throw XomwMWException.New_by_method(XomwPPFrame_Hash.class, "expand",
": found an array where a node descriptor should be");
}
@ -259,7 +259,7 @@ public class XomwPPFrame_Hash extends XomwPPFrame { /**
);
} else {
XophpArray ret = this.parser.braceSubstitution(bits, this);
if (ret.isset(Object_.Cls_val_name)) {// NOTE: using Cls_val_name b/c of transpilation and Object . Object
if (XophpArray.isset(ret, Object_.Cls_val_name)) {// NOTE: using Cls_val_name b/c of transpilation and Object . Object
newIterator = ret.Get_by(Object_.Cls_val_name);
} else {
outItm += ret.Get_by_str("text");
@ -276,7 +276,7 @@ public class XomwPPFrame_Hash extends XomwPPFrame { /**
);
} else {
XophpArray ret = this.parser.argSubstitution(bits, this);
if (ret.isset(Object_.Cls_val_name)) {// NOTE: using Cls_val_name b/c of transpilation and Object . Object
if (XophpArray.isset(ret, Object_.Cls_val_name)) {// NOTE: using Cls_val_name b/c of transpilation and Object . Object
newIterator = ret.Get_by("Object");
} else {
outItm += ret.Get_by_str("text");
@ -343,7 +343,7 @@ public class XomwPPFrame_Hash extends XomwPPFrame { /**
XophpArray bits = XomwPPNode_Hash_Tree.splitRawHeading(contextChildren);
String titleText = this.title.getPrefixedDBkeyStr();
this.parser.mHeadings.Add(titleText, bits.Get_by("i"));
int serial = XophpArray_.count(this.parser.mHeadings) - 1;
int serial = XophpArray.count(this.parser.mHeadings) - 1;
String marker = XomwParser.MARKER_PREFIX + "-h-" + Int_.To_str(serial) + "-" + XomwParser.MARKER_SUFFIX;
s = XophpString_.substr(s, 0, bits.Get_by_int("level")) + marker + XophpString_.substr(s, bits.Get_by_int("level"));
this.parser.mStripState.addGeneral(marker, "");
@ -366,9 +366,9 @@ public class XomwPPFrame_Hash extends XomwPPFrame { /**
// With tail recursion
while (!XophpObject_.is_true(iteratorStack.Get_at(level)) && level > 0) {
outStack.Itm_str_concat_end(level - 1, outItm);
outStack.pop();
iteratorStack.pop();
indexStack.pop();
XophpArray.array_pop(outStack);
XophpArray.array_pop(iteratorStack);
XophpArray.array_pop(indexStack);
level--;
}
}
@ -384,7 +384,7 @@ public class XomwPPFrame_Hash extends XomwPPFrame { /**
* @return String
*/
public String implodeWithFlags(String sep, int flags, XophpArray args) {
// args = XophpArray_.array_slice(func_get_args(), 2);
// args = XophpArray.array_slice(func_get_args(), 2);
boolean first = true;
String s = "";
@ -430,7 +430,7 @@ public class XomwPPFrame_Hash extends XomwPPFrame { /**
if (!XophpArray.is_array(rootObj)) {
root = XophpArray.New(root);
}
int rootLen = root.count();
int rootLen = root.Len();
for (int i = 0; i < rootLen; i++) {
Object node = root.Get_at(i);
if (first) {
@ -464,7 +464,7 @@ public class XomwPPFrame_Hash extends XomwPPFrame { /**
if (!XophpArray.is_array(rootObj)) {
root = XophpArray.New(root);
}
int rootLen = root.count();
int rootLen = root.Len();
for (int i = 0; i < rootLen; i++) {
Object node = root.Get_at(i);
if (first) {
@ -499,7 +499,7 @@ public class XomwPPFrame_Hash extends XomwPPFrame { /**
if (!XophpArray.is_array(rootObj)) {
root = XophpArray.New((String)rootObj);
}
int root_len = root.count();
int root_len = root.Len();
for (int i = 0; i < root_len; i++) {
String node = root.Get_at_str(i);
if (first) {
@ -527,7 +527,7 @@ public class XomwPPFrame_Hash extends XomwPPFrame { /**
return this.title.getPrefixedDBkeyStr();
} else {
// return isset( $this->titleCache[$level] ) ? $this->titleCache[$level] : false;
return this.titleCache.count() > 0 ? ((String)this.titleCache.Get_at(0)) : XophpString_.False;
return XophpArray.count(this.titleCache) > 0 ? ((String)this.titleCache.Get_at(0)) : XophpString_.False;
}
}
@ -577,7 +577,7 @@ public class XomwPPFrame_Hash extends XomwPPFrame { /**
* @return boolean
*/
@Override public boolean loopCheck(XomwTitleOld title) {
return !this.loopCheckHash.isset(title.getPrefixedDBkeyStr());
return !XophpArray.isset(this.loopCheckHash, title.getPrefixedDBkeyStr());
}
/**

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.parsers.preprocessors; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
import gplx.xowa.mediawiki.includes.exception.*;
// MW.FILE:Preprocessor_Hash
@ -31,7 +31,7 @@ public class XomwPPNode_Hash_Array extends XomwPPNode { public XophpArray value
}
@Override public int getLength() {
return XophpArray_.count(this.value);
return XophpArray.count(this.value);
}
@Override public XomwPPNode item(int i) {

@ -1,19 +1,20 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.parsers.preprocessors; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.parsers.preprocessors; import gplx.*;
import gplx.xowa.mediawiki.*;
// MW.FILE:Preprocessor_Hash
/**
* @ingroup Parser
@ -138,7 +139,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
int rawChildrenLen = rawChildren.Len();
for (int i = 0; i < rawChildrenLen; i++) {
XophpArrayItm itm = rawChildren.Get_at_itm(i);
children.Add(XomwPPNode_Hash_Tree.factory(this.rawChildren, itm.Key_as_int()));
children.Add(XomwPPNode_Hash_Tree.factory(this.rawChildren, itm.KeyAsInt()));
}
return new XomwPPNode_Hash_Array(children);
}
@ -151,7 +152,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
* @return PPNode_Hash_Tree|PPNode_Hash_Attr|PPNode_Hash_Text|boolean
*/
@Override public XomwPPNode getFirstChild() {
if (this.rawChildren.isset(0)) {
if (XophpArray.isset(this.rawChildren, 0)) {
return null;
}
else {
@ -183,7 +184,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
XophpArrayItm itm = this.rawChildren.Get_at_itm(idx);
Object child = itm.Val();
if (XophpType_.is_array(child) && String_.Eq(((XophpArray)child).Get_at_str(XomwPPNode_Hash_Tree.NAME), name)) {
children.Add(XomwPPNode_Hash_Tree.factory(this.rawChildren, itm.Key_as_int()));
children.Add(XomwPPNode_Hash_Tree.factory(this.rawChildren, itm.KeyAsInt()));
}
}
return new XomwPPNode_Hash_Array(children);
@ -245,7 +246,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
continue;
}
XophpArray child = (XophpArray)childObj;
int i = itm.Key_as_int();
int i = itm.KeyAsInt();
if (String_.Eq(child.Get_at_str(XomwPPNode_Hash_Tree.NAME), "name")) {
bits.Set("name", new XomwPPNode_Hash_Tree(children, i));
if (XophpObject_.isset_obj(child.Get_at_ary(XomwPPNode_Hash_Tree.CHILDREN).Get_at_ary(0).Get_at(XomwPPNode_Hash_Tree.NAME))
@ -284,7 +285,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
*/
public static XophpArray splitRawExt(XophpArray children) {
XophpArray bits = XophpArray.New();
int len = children.count();
int len = children.Len();
for (int i = 0; i < len; i++) {
Object childObj = children.Get_at(i);
if (!XophpArray.is_array(childObj)) {
@ -305,7 +306,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
bits.Add("close", new XomwPPNode_Hash_Tree(children, i));
}
}
if (!bits.isset("name")) {
if (!XophpArray.isset(bits, "name")) {
throw new XomwMWException("Invalid ext node passed to " + "splitRawExt");
}
return bits;
@ -329,7 +330,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
*/
public static XophpArray splitRawHeading(XophpArray children) {
XophpArray bits = XophpArray.New();
int len = children.count();
int len = children.Len();
for (int i = 0; i < len; i++) {
Object childObj = children.Get_at(i);
if (!XophpArray.is_array(childObj)) {
@ -344,7 +345,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
bits.Add("level", childChildren.Get_at(0));
}
}
if (!bits.isset("i")) {
if (!XophpArray.isset(bits, "i")) {
throw new XomwMWException("Invalid h node passed to " + "splitRawHeading");
}
return bits;
@ -366,7 +367,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
public static XophpArray splitRawTemplate(XophpArray children) {
XophpArray parts = XophpArray.New();
XophpArray bits = XophpArray.New("lineStart" , "");
int len = children.count();
int len = children.Len();
for (int i = 0; i < len; i++) {
Object childObj = children.Get_at(i);
if (!XophpArray.is_array(childObj)) {
@ -383,7 +384,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
bits.Add("lineStart", "1");
}
}
if (!bits.isset("title")) {
if (!XophpArray.isset(bits, "title")) {
throw new XomwMWException("Invalid node passed to " + "splitRawTemplate");
}
bits.Add("parts", new XomwPPNode_Hash_Array(parts));

@ -51,8 +51,8 @@ class XomwPPTemplateFrame_Hash extends XomwPPFrame_Hash { public XophpArray num
@Override public String toString() {
String s = "tplframe{";
boolean first = true;
XophpArray args = XophpArray_.array_add(this.numberedArgs, this.namedArgs);
int args_len = args.count();
XophpArray args = XophpArray.array_add(this.numberedArgs, this.namedArgs);
int args_len = args.Len();
for (int i = 0; i < args_len; i++) {
XophpArrayItm itm = args.Get_at_itm(i);
if (first) {
@ -91,7 +91,7 @@ class XomwPPTemplateFrame_Hash extends XomwPPFrame_Hash { public XophpArray num
* @return boolean
*/
@Override public boolean isEmpty() {
return !this.numberedArgs.count_bool() && !this.namedArgs.count_bool();
return !XophpArray.count_bool(this.numberedArgs) && !XophpArray.count_bool(this.namedArgs);
}
/**
@ -99,10 +99,10 @@ class XomwPPTemplateFrame_Hash extends XomwPPFrame_Hash { public XophpArray num
*/
@Override public XophpArray getArguments() {
XophpArray arguments = XophpArray.New();
XophpArray merged = XophpArray_.array_merge(
XophpArray_.array_keys(this.numberedArgs),
XophpArray_.array_keys(this.namedArgs));
int merged_len = merged.count();
XophpArray merged = XophpArray.array_merge(
XophpArray.array_keys(this.numberedArgs),
XophpArray.array_keys(this.namedArgs));
int merged_len = merged.Len();
for (int i = 0; i < merged_len; i++) {
String key = merged.Get_at_str(i);
arguments.Set(key, this.getArgument(key));
@ -115,8 +115,8 @@ class XomwPPTemplateFrame_Hash extends XomwPPFrame_Hash { public XophpArray num
*/
@Override public XophpArray getNumberedArguments() {
XophpArray arguments = XophpArray.New();
XophpArray temp = XophpArray_.array_keys(this.numberedArgs);
int temp_len = temp.count();
XophpArray temp = XophpArray.array_keys(this.numberedArgs);
int temp_len = temp.Len();
for (int i = 0; i < temp_len; i++) {
String key = temp.Get_at_str(i);
arguments.Set(key, this.getArgument(key));
@ -129,8 +129,8 @@ class XomwPPTemplateFrame_Hash extends XomwPPFrame_Hash { public XophpArray num
*/
@Override public XophpArray getNamedArguments() {
XophpArray arguments = XophpArray.New();
XophpArray temp = XophpArray_.array_keys(this.namedArgs);
int temp_len = temp.count();
XophpArray temp = XophpArray.array_keys(this.namedArgs);
int temp_len = temp.Len();
for (int i = 0; i < temp_len; i++) {
String key = temp.Get_at_str(i);
arguments.Set(key, this.getArgument(key));

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.parsers.preprocessors_new; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
// MW.SRC:1.33
import gplx.xowa.mediawiki.includes.exception.*;
@ -48,7 +48,7 @@ public class XomwPPDStack {
* @return int
*/
public int count() {
return XophpArray_.count(this.stack);
return XophpArray.count(this.stack);
}
public XophpArray getAccum() { // &getAccum
@ -73,18 +73,18 @@ public class XomwPPDStack {
XophpArray array = (XophpArray)data;
this.stack.Add(elementClass.New(partClass, array.Get_by_str("open"), array.Get_by_str("close"), array.Get_by_ary_or("parts", null), array.Get_by_int_or("count", 0), array.Get_by_bool_or("lineStart", false), array.Get_by_int_or("startPos", 0)));
}
this.top = (XomwPPDStackElement)this.stack.Get_at(XophpArray_.count(this.stack) - 1);
this.top = (XomwPPDStackElement)this.stack.Get_at(XophpArray.count(this.stack) - 1);
this.accum = this.top.getAccum(); //=&
}
public XomwPPDStackElement pop() {
if (this.stack.Eq_to_new()) {
if (XophpArray.Eq_to_new(this.stack)) {
throw XomwMWException.New_by_method_obj(this, "pop", ": no elements remaining");
}
XomwPPDStackElement temp = (XomwPPDStackElement)XophpArray_.array_pop(this.stack);
XomwPPDStackElement temp = (XomwPPDStackElement)XophpArray.array_pop(this.stack);
if (XophpArray_.count_bool(this.stack)) {
this.top = (XomwPPDStackElement)this.stack.Get_at(XophpArray_.count(this.stack) - 1);
if (XophpArray.count_bool(this.stack)) {
this.top = (XomwPPDStackElement)this.stack.Get_at(XophpArray.count(this.stack) - 1);
this.accum = this.top.getAccum(); // =&
} else {
this.top = null;
@ -103,7 +103,7 @@ public class XomwPPDStack {
* @return array
*/
public XophpArray getFlags() {
if (this.stack.Eq_to_new()) {
if (XophpArray.Eq_to_new(this.stack)) {
return XophpArray.New()
.Add("findEquals", false)
.Add("findPipe", false)

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.parsers.preprocessors_new; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
// MW.SRC:1.33
/**
@ -70,7 +70,7 @@ public abstract class XomwPPDStackElement {
}
public XophpArray getAccum() {
return (XophpArray)((XomwPPDPart)(this.parts.Get_at(XophpArray_.count(this.parts) - 1))).output;
return (XophpArray)((XomwPPDPart)(this.parts.Get_at(XophpArray.count(this.parts) - 1))).output;
}
public void addPart(String s) { // s = ""
@ -82,14 +82,14 @@ public abstract class XomwPPDStackElement {
* @return PPDPart
*/
public XomwPPDPart getCurrentPart() {
return (XomwPPDPart)this.parts.Get_at(XophpArray_.count(this.parts) - 1);
return (XomwPPDPart)this.parts.Get_at(XophpArray.count(this.parts) - 1);
}
/**
* @return array
*/
public XophpArray getFlags() {
int partCount = XophpArray_.count(this.parts);
int partCount = XophpArray.count(this.parts);
boolean findPipe = !String_.Eq(this.open, "\n") && !String_.Eq(this.open, "[");
return XophpArray.New()
.Add("findPipe", findPipe)

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.parsers.preprocessors_new; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
// MW.SRC:1.33
class XomwPPDStackElement_Hash extends XomwPPDStackElement {
@ -29,7 +29,7 @@ class XomwPPDStackElement_Hash extends XomwPPDStackElement {
public XophpArray breakSyntax(int openingCount) {
XophpArray accum;
if (String_.Eq(this.open, "\n")) {
accum = XophpArray_.array_merge(XophpArray.New(this.savedPrefix), XophpArray.New(((XomwPPDPart)this.parts.Get_at(0)).output));
accum = XophpArray.array_merge(XophpArray.New(this.savedPrefix), XophpArray.New(((XomwPPDPart)this.parts.Get_at(0)).output));
} else {
if (XophpInt_.is_false(openingCount)) {
openingCount = this.count;

@ -343,7 +343,7 @@ public class XomwPPFrame_Hash extends XomwPPFrame { // /**
// XophpArray bits = XomwPPNode_Hash_Tree.splitRawHeading(contextChildren);
// String titleText = this.title.getPrefixedDBkeyStr();
// this.parser.mHeadings.Add(titleText, bits.Get_by("i"));
// int serial = XophpArray_.count(this.parser.mHeadings) - 1;
// int serial = XophpArray.count(this.parser.mHeadings) - 1;
// String marker = XomwParser.MARKER_PREFIX + "-h-" + Int_.To_str(serial) + "-" + XomwParser.MARKER_SUFFIX;
// s = XophpString_.substr(s, 0, bits.Get_by_int("level")) + marker + XophpString_.substr(s, bits.Get_by_int("level"));
// this.parser.mStripState.addGeneral(marker, "");
@ -384,7 +384,7 @@ public class XomwPPFrame_Hash extends XomwPPFrame { // /**
// * @return String
// */
// public String implodeWithFlags(String sep, int flags, XophpArray args) {
// // args = XophpArray_.array_slice(func_get_args(), 2);
// // args = XophpArray.array_slice(func_get_args(), 2);
//
// boolean first = true;
// String s = "";

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.parsers.preprocessors_new; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
import gplx.xowa.mediawiki.includes.exception.*;
// MW.FILE:Preprocessor_Hash
@ -31,7 +31,7 @@ public class XomwPPNode_Hash_Array extends XomwPPNode { public XophpArray value
}
@Override public int getLength() {
return XophpArray_.count(this.value);
return XophpArray.count(this.value);
}
@Override public XomwPPNode item(int i) {

@ -1,19 +1,20 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.parsers.preprocessors_new; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.parsers.preprocessors_new; import gplx.*;
import gplx.xowa.mediawiki.*;
// MW.FILE:Preprocessor_Hash
/**
* @ingroup Parser
@ -138,7 +139,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
int rawChildrenLen = rawChildren.Len();
for (int i = 0; i < rawChildrenLen; i++) {
XophpArrayItm itm = rawChildren.Get_at_itm(i);
children.Add(XomwPPNode_Hash_Tree.factory(this.rawChildren, itm.Key_as_int()));
children.Add(XomwPPNode_Hash_Tree.factory(this.rawChildren, itm.KeyAsInt()));
}
return new XomwPPNode_Hash_Array(children);
}
@ -151,7 +152,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
* @return PPNode_Hash_Tree|PPNode_Hash_Attr|PPNode_Hash_Text|boolean
*/
@Override public XomwPPNode getFirstChild() {
if (!XophpArray_.isset(this.rawChildren, 0)) {
if (!XophpArray.isset(this.rawChildren, 0)) {
return null;
}
else {
@ -183,7 +184,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
XophpArrayItm itm = this.rawChildren.Get_at_itm(idx);
Object child = itm.Val();
if (XophpType_.is_array(child) && String_.Eq(((XophpArray)child).Get_at_str(XomwPPNode_Hash_Tree.NAME), name)) {
children.Add(XomwPPNode_Hash_Tree.factory(this.rawChildren, itm.Key_as_int()));
children.Add(XomwPPNode_Hash_Tree.factory(this.rawChildren, itm.KeyAsInt()));
}
}
return new XomwPPNode_Hash_Array(children);
@ -245,7 +246,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
continue;
}
XophpArray child = (XophpArray)childObj;
int i = itm.Key_as_int();
int i = itm.KeyAsInt();
if (String_.Eq(child.Get_at_str(XomwPPNode_Hash_Tree.NAME), "name")) {
bits.Set("name", new XomwPPNode_Hash_Tree(children, i));
if (XophpObject_.isset_obj(child.Get_at_ary(XomwPPNode_Hash_Tree.CHILDREN).Get_at_ary(0).Get_at(XomwPPNode_Hash_Tree.NAME))
@ -284,7 +285,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
*/
public static XophpArray splitRawExt(XophpArray children) {
XophpArray bits = XophpArray.New();
int len = children.count();
int len = children.Len();
for (int i = 0; i < len; i++) {
Object childObj = children.Get_at(i);
if (!XophpArray.is_array(childObj)) {
@ -305,7 +306,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
bits.Add("close", new XomwPPNode_Hash_Tree(children, i));
}
}
if (!bits.isset("name")) {
if (!XophpArray.isset(bits, "name")) {
throw new XomwMWException("Invalid ext node passed to " + "splitRawExt");
}
return bits;
@ -329,7 +330,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
*/
public static XophpArray splitRawHeading(XophpArray children) {
XophpArray bits = XophpArray.New();
int len = children.count();
int len = children.Len();
for (int i = 0; i < len; i++) {
Object childObj = children.Get_at(i);
if (!XophpArray.is_array(childObj)) {
@ -344,7 +345,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
bits.Add("level", childChildren.Get_at(0));
}
}
if (!bits.isset("i")) {
if (!XophpArray.isset(bits, "i")) {
throw new XomwMWException("Invalid h node passed to " + "splitRawHeading");
}
return bits;
@ -366,7 +367,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
public static XophpArray splitRawTemplate(XophpArray children) {
XophpArray parts = XophpArray.New();
XophpArray bits = XophpArray.New("lineStart" , "");
int len = children.count();
int len = children.Len();
for (int i = 0; i < len; i++) {
Object childObj = children.Get_at(i);
if (!XophpArray.is_array(childObj)) {
@ -383,7 +384,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
bits.Add("lineStart", "1");
}
}
if (!bits.isset("title")) {
if (!XophpArray.isset(bits, "title")) {
throw new XomwMWException("Invalid node passed to " + "splitRawTemplate");
}
bits.Add("parts", new XomwPPNode_Hash_Array(parts));

@ -51,7 +51,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
// public override String toString() {
// String s = "tplframe{";
// boolean first = true;
// XophpArray args = XophpArray_.array_add(this.numberedArgs, this.namedArgs);
// XophpArray args = XophpArray.array_add(this.numberedArgs, this.namedArgs);
// int args_len = args.count();
// for (int i = 0; i < args_len; i++) {
// XophpArrayItm itm = args.Get_at_itm(i);
@ -99,9 +99,9 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
// */
// public override XophpArray getArguments() {
// XophpArray arguments = XophpArray.New();
// XophpArray merged = XophpArray_.array_merge(
// XophpArray_.array_keys(this.numberedArgs),
// XophpArray_.array_keys(this.namedArgs));
// XophpArray merged = XophpArray.array_merge(
// XophpArray.array_keys(this.numberedArgs),
// XophpArray.array_keys(this.namedArgs));
// int merged_len = merged.count();
// for (int i = 0; i < merged_len; i++) {
// String key = merged.Get_at_str(i);
@ -115,7 +115,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
// */
// public override XophpArray getNumberedArguments() {
// XophpArray arguments = XophpArray.New();
// XophpArray temp = XophpArray_.array_keys(this.numberedArgs);
// XophpArray temp = XophpArray.array_keys(this.numberedArgs);
// int temp_len = temp.count();
// for (int i = 0; i < temp_len; i++) {
// String key = temp.Get_at_str(i);
@ -129,7 +129,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
// */
// public override XophpArray getNamedArguments() {
// XophpArray arguments = XophpArray.New();
// XophpArray temp = XophpArray_.array_keys(this.namedArgs);
// XophpArray temp = XophpArray.array_keys(this.namedArgs);
// int temp_len = temp.count();
// for (int i = 0; i < temp_len; i++) {
// String key = temp.Get_at_str(i);

@ -1,24 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.parsers.preprocessors_new; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.parsers.preprocessors_new; import gplx.*;
import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
// MW.SRC:1.33
import gplx.core.bits.*;
import gplx.langs.regxs.*;
import gplx.xowa.mediawiki.includes.exception.*;
import gplx.xowa.mediawiki.includes.parsers.preprocessors.*;
/**
* Differences from DOM schema:
* * attribute nodes are children
@ -145,7 +144,7 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
ignoredElements = XophpArray.New("includeonly");
xmlishElements.Add("includeonly");
}
String xmlishRegex = XophpArray_.implode("|", XophpArray_.array_merge(xmlishElements, ignoredTags));
String xmlishRegex = XophpArray.implode("|", XophpArray.array_merge(xmlishElements, ignoredTags));
// Use "A" modifier (anchored) instead of "^", because ^ doesn"t work with an offset
Regx_adp elementsRegex = XophpRegex_.Pattern("(" + xmlishRegex + ")(?:\\s|\\/>|>)|(!--)", XophpRegex_.MODIFIER_i | XophpRegex_.MODIFIER_A);
@ -302,7 +301,7 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
continue;
}
// Handle comments
if (XophpArray_.isset(matches, 2) && String_.Eq(matches.Get_at_str(2), "!--")) {
if (XophpArray.isset(matches, 2) && String_.Eq(matches.Get_at_str(2), "!--")) {
// To avoid leaving blank lines, when a sequence of
// space-separated comments is both preceded and followed by
// a newline (ignoring spaces), then
@ -345,7 +344,7 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
) {
// Remove leading whitespace from the end of the accumulator
int wsLength = i - wsStart;
int endIndex = XophpArray_.count(accum) - 1;
int endIndex = XophpArray.count(accum) - 1;
// Sanity check
if (wsLength > 0
@ -360,11 +359,11 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
int commentsLen = comments.Len();
for (int commentsIdx = 0; commentsIdx < commentsLen; commentsIdx++) {
XophpArrayItm itm = comments.Get_at_itm(commentsIdx);
int j = itm.Key_as_int();
int j = itm.KeyAsInt();
XophpArray com = (XophpArray)itm.Val();
startPos = com.Get_at_int(0);
endPos = com.Get_at_int(1) + 1;
if (j == (XophpArray_.count(comments) - 1)) {
if (j == (XophpArray.count(comments) - 1)) {
break;
}
inner = XophpString_.substr(text, startPos, endPos - startPos);
@ -409,7 +408,7 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
}
// Handle ignored tags
if (XophpArray_.in_array(lowerName, ignoredTags)) {
if (XophpArray.in_array(lowerName, ignoredTags)) {
accum.Add(XophpArray.New("ignore", XophpArray.New(XophpString_.substr(text, i, tagEndPos - i + 1))));
i = tagEndPos + 1;
continue;
@ -436,7 +435,7 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
close = matches.Get_at_ary(0).Get_at_str(0);
} else {
// No end tag
if (XophpArray_.in_array(name, xmlishAllowMissingEndTag)) {
if (XophpArray.in_array(name, xmlishAllowMissingEndTag)) {
// Let it run out to the end of the text.
inner = XophpString_.substr(text, tagEndPos + 1);
i = lengthText;
@ -453,7 +452,7 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
}
}
// <includeonly> and <noinclude> just become <ignore> tags
if (XophpArray_.in_array(lowerName, ignoredElements)) {
if (XophpArray.in_array(lowerName, ignoredElements)) {
accum.Add(XophpArray.New("ignore", XophpArray.New(XophpString_.substr(text, tagStartPos, i - tagStartPos))));
continue;
}
@ -503,13 +502,13 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
stack.push(piece);
accum = stack.getAccum(); // =&
XophpArray stackFlags = stack.getFlags();
if (XophpArray_.isset(stackFlags, "findEquals")) {
if (XophpArray.isset(stackFlags, "findEquals")) {
findEquals = stackFlags.Get_by_bool("findEquals");
}
if (XophpArray_.isset(stackFlags, "findPipe")) {
if (XophpArray.isset(stackFlags, "findPipe")) {
findPipe = stackFlags.Get_by_bool("findPipe");
}
if (XophpArray_.isset(stackFlags, "inHeading")) {
if (XophpArray.isset(stackFlags, "inHeading")) {
inHeading = stackFlags.Get_by_bool("inHeading");
}
i += count;
@ -553,7 +552,7 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
if (count > 0) {
// Normal match, output <h>
element = XophpArray.New(XophpArray.New("possible-h",
XophpArray_.array_merge(
XophpArray.array_merge(
XophpArray.New(
XophpArray.New("@level", XophpArray.New(count)),
XophpArray.New("@i", XophpArray.New(headingIndex++))
@ -573,18 +572,18 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
stack.pop();
accum = stack.getAccum(); // =&
XophpArray stackFlags = stack.getFlags();
if (XophpArray_.isset(stackFlags, "findEquals")) {
if (XophpArray.isset(stackFlags, "findEquals")) {
findEquals = stackFlags.Get_by_bool("findEquals");
}
if (XophpArray_.isset(stackFlags, "findPipe")) {
if (XophpArray.isset(stackFlags, "findPipe")) {
findPipe = stackFlags.Get_by_bool("findPipe");
}
if (XophpArray_.isset(stackFlags, "inHeading")) {
if (XophpArray.isset(stackFlags, "inHeading")) {
inHeading = stackFlags.Get_by_bool("inHeading");
}
// Append the result to the enclosing accumulator
XophpArray_.array_splice(accum, XophpArray_.count(accum), 0, element);
XophpArray.array_splice(accum, XophpArray.count(accum), 0, element);
// Note that we do NOT increment the input pointer.
// This is because the closing linebreak could be the opening linebreak of
@ -625,13 +624,13 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
stack.push(piece);
accum = stack.getAccum(); // =&
XophpArray stackFlags = stack.getFlags();
if (XophpArray_.isset(stackFlags, "findEquals")) {
if (XophpArray.isset(stackFlags, "findEquals")) {
findEquals = stackFlags.Get_by_bool("findEquals");
}
if (XophpArray_.isset(stackFlags, "findPipe")) {
if (XophpArray.isset(stackFlags, "findPipe")) {
findPipe = stackFlags.Get_by_bool("findPipe");
}
if (XophpArray_.isset(stackFlags, "inHeading")) {
if (XophpArray.isset(stackFlags, "inHeading")) {
inHeading = stackFlags.Get_by_bool("inHeading");
}
} else {
@ -663,7 +662,7 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
// Skip any gaps in the callback array to find the true largest match
// Need to use array_key_exists not isset because the callback can be null
matchingCount = count;
while (matchingCount > 0 && !XophpArray_.array_key_exists(matchingCount, rule.Get_by_ary("names"))) {
while (matchingCount > 0 && !XophpArray.array_key_exists(matchingCount, rule.Get_by_ary("names"))) {
--matchingCount;
}
}
@ -688,7 +687,7 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
// Create XML element
XophpArray parts = piece.parts;
XophpArray titleAccum = ((XomwPPDPart)parts.Get_at(0)).output;
XophpArray_.unset(parts, 0);
XophpArray.unset(parts, 0);
XophpArray children = XophpArray.New();
@ -707,8 +706,8 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
XomwPPDPart_Hash part = (XomwPPDPart_Hash)parts.Get_at(j);
if (XophpInt_.is_true(part.eqpos)) { // XO.NOTE: MW says isset(part.commentEnd) b/c commentEnd can be null due to magic property
Object equalsNode = part.output.Get_at(part.eqpos);
XophpArray nameNode = XophpArray.New("name", XophpArray_.array_slice(part.output, 0, part.eqpos));
XophpArray valueNode = XophpArray.New("value", XophpArray_.array_slice(part.output, part.eqpos + 1));
XophpArray nameNode = XophpArray.New("name", XophpArray.array_slice(part.output, 0, part.eqpos));
XophpArray valueNode = XophpArray.New("value", XophpArray.array_slice(part.output, part.eqpos + 1));
XophpArray partNode = XophpArray.New("part", XophpArray.New(nameNode, equalsNode, valueNode));
children.Add(partNode);
} else {
@ -757,18 +756,18 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
}
XophpArray stackFlags = stack.getFlags();
if (XophpArray_.isset(stackFlags, "findEquals")) {
if (XophpArray.isset(stackFlags, "findEquals")) {
findEquals = stackFlags.Get_by_bool("findEquals");
}
if (XophpArray_.isset(stackFlags, "findPipe")) {
if (XophpArray.isset(stackFlags, "findPipe")) {
findPipe = stackFlags.Get_by_bool("findPipe");
}
if (XophpArray_.isset(stackFlags, "inHeading")) {
if (XophpArray.isset(stackFlags, "inHeading")) {
inHeading = stackFlags.Get_by_bool("inHeading");
}
// Add XML element to the enclosing accumulator
XophpArray_.array_splice(accum, XophpArray_.count(accum), 0, element);
XophpArray.array_splice(accum, XophpArray.count(accum), 0, element);
} else if (String_.Eq(found, "pipe")) {
findEquals = true; // shortcut for getFlags()
stack.addPart();
@ -777,7 +776,7 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
} else if (String_.Eq(found, "equals")) {
findEquals = false; // shortcut for getFlags()
accum.Add(XophpArray.New("equals", XophpArray.New("=")));
stack.getCurrentPart().eqpos = XophpArray_.count(accum) - 1;
stack.getCurrentPart().eqpos = XophpArray.count(accum) - 1;
++i;
}
}
@ -787,7 +786,7 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
int tempStackLen = tempStack.Len();
for (int j = 0; j < tempStackLen; j++) {
XomwPPDStackElement_Hash piece = (XomwPPDStackElement_Hash)tempStack.Get_at(j);
XophpArray_.array_splice(stack.rootAccum, XophpArray_.count(stack.rootAccum), 0, piece.breakSyntax());
XophpArray.array_splice(stack.rootAccum, XophpArray.count(stack.rootAccum), 0, piece.breakSyntax());
}
// Enable top-level headings
@ -795,7 +794,7 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
int rootAccumLen = rootAccum.Len();
for (int j = 0; j < rootAccumLen; j++) {
XophpArray node = rootAccum.Get_at_ary_or_null(j); // stack.rootAccum as &node
if (XophpArray_.is_array(node) && String_.Eq(node.Get_at_str(XomwPPNode_Hash_Tree.NAME), "possible-h")) {
if (XophpArray.is_array(node) && String_.Eq(node.Get_at_str(XomwPPNode_Hash_Tree.NAME), "possible-h")) {
node.Set(XomwPPNode_Hash_Tree.NAME, "h");
}
}
@ -813,7 +812,7 @@ public class XomwPreprocessor_Hash extends XomwPreprocessor {
}
private static void addLiteral(XophpArray accum, String text) {
int n = XophpArray_.count(accum);
int n = XophpArray.count(accum);
if (XophpInt_.is_true(n) && XophpType_.is_string(accum.Get_at(n - 1))) {
accum.Concat_str(n - 1, text);
} else {

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.parsers.tables; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
import gplx.xowa.parsers.htmls.*;
import gplx.xowa.mediawiki.includes.libs.*; import gplx.xowa.parsers.uniqs.*;
@ -48,13 +48,13 @@ public class Xomw_table_wkr implements gplx.core.brys.Bry_split_wkr {// THREAD.U
// Closing open td, tr && table
while (td_history.Len() > 0) {
if (XophpArray_.popBoolOrN(td_history)) {
if (XophpArray.popBoolOrN(td_history)) {
bfr.Add_str_a7("</td>\n");
}
if (XophpArray_.popBoolOrN(tr_history)) {
if (XophpArray.popBoolOrN(tr_history)) {
bfr.Add_str_a7("</tr>\n");
}
if (!XophpArray_.popBoolOrN(has_opened_tr)) {
if (!XophpArray.popBoolOrN(has_opened_tr)) {
bfr.Add_str_a7("<tr><td></td></tr>\n");
}
bfr.Add_str_a7("</table>\n");
@ -123,20 +123,20 @@ public class Xomw_table_wkr implements gplx.core.brys.Bry_split_wkr {// THREAD.U
else if (Bry_.Eq(first_2, Wtxt__tb__end)) {
// We are ending a table
line = tmp.Add_str_a7("</table>").Add_mid(line, 2, line.length).To_bry_and_clear();
byte[] last_tag = XophpArray_.popBryOrNull(last_tag_history);
byte[] last_tag = XophpArray.popBryOrNull(last_tag_history);
if (!XophpArray_.popBoolOrN(has_opened_tr)) {
if (!XophpArray.popBoolOrN(has_opened_tr)) {
line = tmp.Add_str_a7("<tr><td></td></tr>").Add(line).To_bry_and_clear();
}
if (XophpArray_.popBoolOrN(tr_history)) {
if (XophpArray.popBoolOrN(tr_history)) {
line = tmp.Add_str_a7("</tr>").Add(line).To_bry_and_clear();
}
if (XophpArray_.popBoolOrN(td_history)) {
if (XophpArray.popBoolOrN(td_history)) {
line = tmp.Add_str_a7("</").Add(last_tag).Add_byte(Byte_ascii.Angle_end).Add(line).To_bry_and_clear();
}
XophpArray_.popBryOrNull(tr_attributes);
XophpArray.popBryOrNull(tr_attributes);
// PORTED:$outLine = $line . str_repeat( '</dd></dl>', $indent_level );
tmp.Add(line);
for (int j = 0; j < indent_level; j++)
@ -152,19 +152,19 @@ public class Xomw_table_wkr implements gplx.core.brys.Bry_split_wkr {// THREAD.U
sanitizer.fixTagAttributes(tmp, Name__tr, atrs);
atrs = tmp.To_bry_and_clear();
XophpArray_.popBryOrNull(tr_attributes);
XophpArray.popBryOrNull(tr_attributes);
tr_attributes.Add(atrs);
line = Bry_.Empty;
byte[] last_tag = XophpArray_.popBryOrNull(last_tag_history);
XophpArray_.popBoolOrN(has_opened_tr);
byte[] last_tag = XophpArray.popBryOrNull(last_tag_history);
XophpArray.popBoolOrN(has_opened_tr);
has_opened_tr.Add(true);
if (XophpArray_.popBoolOrN(tr_history)) {
if (XophpArray.popBoolOrN(tr_history)) {
line = Html__tr__end;
}
if (XophpArray_.popBoolOrN(td_history)) {
if (XophpArray.popBoolOrN(td_history)) {
line = tmp.Add_str_a7("</").Add(last_tag).Add_byte(Byte_ascii.Gt).Add(line).To_bry_and_clear();
}
@ -205,19 +205,19 @@ public class Xomw_table_wkr implements gplx.core.brys.Bry_split_wkr {// THREAD.U
byte[] cell = cells[j];
previous = Bry_.Empty;
if (first_char != Byte_ascii.Plus) {
byte[] tr_after = XophpArray_.popBryOrNull(tr_attributes);
if (!XophpArray_.popBoolOrN(tr_history)) {
byte[] tr_after = XophpArray.popBryOrNull(tr_attributes);
if (!XophpArray.popBoolOrN(tr_history)) {
previous = tmp.Add_str_a7("<tr").Add(tr_after).Add_str_a7(">\n").To_bry_and_clear();
}
tr_history.Add(true);
tr_attributes.Add(Bry_.Empty);
XophpArray_.popBoolOrN(has_opened_tr);
XophpArray.popBoolOrN(has_opened_tr);
has_opened_tr.Add(true);
}
byte[] last_tag = XophpArray_.popBryOrNull(last_tag_history);
byte[] last_tag = XophpArray.popBryOrNull(last_tag_history);
if (XophpArray_.popBoolOrN(td_history)) {
if (XophpArray.popBoolOrN(td_history)) {
previous = tmp.Add_str_a7("</").Add(last_tag).Add_str_a7(">\n").Add(previous).To_bry_and_clear();
}

@ -104,14 +104,14 @@ public class XomwSiteList extends XomwGenericArrayObject { public int Len() {ret
*/
XomwSite site = (XomwSite)this.offsetGet(index);
XophpArray_.unset(this.byGlobalId, site.getGlobalId());
XophpArray_.unset(this.byInternalId, site.getInternalId());
XophpArray.unset(this.byGlobalId, site.getGlobalId());
XophpArray.unset(this.byInternalId, site.getInternalId());
Ordered_hash ids = site.getNavigationIds();
int len = ids.Len();
for (int i = 0; i < len; i++) {
int navId = Int_.Cast(ids.Get_at(i));
XophpArray_.unset(this.byNavigationId, navId);
XophpArray.unset(this.byNavigationId, navId);
}
}
@ -127,7 +127,7 @@ public class XomwSiteList extends XomwGenericArrayObject { public int Len() {ret
* @return array
*/
public String[] getGlobalIdentifiers() {
return XophpArray_.array_keys_str(this.byGlobalId);
return XophpArray.array_keys_str(this.byGlobalId);
}
/**
@ -138,7 +138,7 @@ public class XomwSiteList extends XomwGenericArrayObject { public int Len() {ret
* @return boolean
*/
public boolean hasSite(String globalSiteId) {
return XophpArray_.array_key_exists(globalSiteId, this.byGlobalId);
return XophpArray.array_key_exists(globalSiteId, this.byGlobalId);
}
/**
@ -175,7 +175,7 @@ public class XomwSiteList extends XomwGenericArrayObject { public int Len() {ret
* @return boolean
*/
@Override public boolean isEmpty() {
return XophpArray_.empty(this.byGlobalId);
return XophpArray.empty(this.byGlobalId);
}
/**
@ -186,7 +186,7 @@ public class XomwSiteList extends XomwGenericArrayObject { public int Len() {ret
* @return boolean
*/
public boolean hasInternalId(int id) {
return XophpArray_.array_key_exists(id, this.byInternalId);
return XophpArray.array_key_exists(id, this.byInternalId);
}
/**
@ -223,7 +223,7 @@ public class XomwSiteList extends XomwGenericArrayObject { public int Len() {ret
* @return boolean
*/
public boolean hasNavigationId(String id) {
return XophpArray_.array_key_exists(id, this.byNavigationId);
return XophpArray.array_key_exists(id, this.byNavigationId);
}
/**

@ -18,7 +18,7 @@ package gplx.xowa.mediawiki.includes.user;
// MW.SRC:1.33.1
import gplx.xowa.mediawiki.XophpArray;
import gplx.xowa.mediawiki.XophpArray_;
import gplx.xowa.mediawiki.XophpArray;
import gplx.xowa.mediawiki.includes.XomwWebRequest;
import gplx.xowa.mediawiki.includes.dao.XomwIDBAccessObject;
@ -3167,11 +3167,11 @@ public class XomwUser implements XomwIDBAccessObject { //, UserIdentity
// set it, and then it was disabled removing their ability to change it). But
// we don't want to erase the preferences in the database in case the preference
// is re-enabled again. So don't touch $mOptions, just override the returned value
if (!ignoreHidden && XophpArray_.in_array(oname, wgHiddenPrefs)) {
if (!ignoreHidden && XophpArray.in_array(oname, wgHiddenPrefs)) {
// return getDefaultOption(oname);
}
if (XophpArray_.array_key_exists(oname, this.mOptions)) {
if (XophpArray.array_key_exists(oname, this.mOptions)) {
return this.mOptions.Get_by(oname);
}

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.languages; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*;
import gplx.langs.regxs.*;
import gplx.core.primitives.*;
@ -4038,12 +4038,12 @@ public class XomwLanguage {
return (String)formsObject;
}
forms = (XophpArray)formsObject;
if (!forms.count_bool()) {
if (!XophpArray.count_bool(forms)) {
return "";
}
int pluralForm = this.getPluralRuleIndexNumber(count);
pluralForm = XophpMath_.min(pluralForm, forms.count() - 1);
pluralForm = XophpMath_.min(pluralForm, XophpArray.count(forms) - 1);
return forms.Get_at_str(pluralForm);
}
@ -4064,7 +4064,7 @@ public class XomwLanguage {
*/
public Object handleExplicitPluralForms(String count, XophpArray forms) {
XophpArray mutable = forms.Clone();
int len = forms.count();
int len = forms.Len();
for (int i = 0; i < len; i++) {
XophpArrayItm formItem = forms.Get_at_itm(i);
String index = formItem.Key();
@ -4074,11 +4074,11 @@ public class XomwLanguage {
if (String_.Eq(XophpString_.substr(form, 0, pos), count)) {
return XophpString_.substr(form, pos + 1);
}
mutable.unset(index);
XophpArray.unset(mutable, index);
}
}
return mutable.values();
return XophpArray.array_values(mutable);
}
private static final Regx_adp handleExplicitPluralForms_digits = Regx_adp_.new_("\\d+=");
@ -4987,7 +4987,7 @@ public class XomwLanguage {
if (pluralRules == null) return getCompiledPluralRulesEmpty;
XophpArray fallbacks = XomwLanguage.getFallbacksFor(this.mCode);
if (!XophpObject_.is_true(pluralRules)) {
int fallbacks_len = fallbacks.count();
int fallbacks_len = fallbacks.Len();
for (int i = 0; i < fallbacks_len; i++) {
String fallbackCode = fallbacks.Get_at_str(i);
pluralRules = XomwLanguage.dataCacheXowa.getItem_ary(XophpString_.strtolower(fallbackCode), "compiledPluralRules");

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.languages; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*;
import gplx.core.tests.*;
import gplx.xowa.langs.*;

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.vendor.wikimedia.cldr_plural_rule_parser.src.Converter; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.vendor.*; import gplx.xowa.mediawiki.vendor.wikimedia.*; import gplx.xowa.mediawiki.vendor.wikimedia.cldr_plural_rule_parser.*; import gplx.xowa.mediawiki.vendor.wikimedia.cldr_plural_rule_parser.src.*;
// MW.SRC:1.33.1
/**
@ -77,7 +77,7 @@ public class XomwOperator extends XomwFragment { /** @var String The name */
* @param int length
*/
public XomwOperator(XomwConverter parser, String name, int pos, int length) {super(parser, pos, length);
if (XomwOperator.aliasMap.isset(name)) {
if (XophpArray.isset(XomwOperator.aliasMap, name)) {
name = XomwOperator.aliasMap.Get_by_str(name);
}
this.name = name;

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.vendor.wikimedia.cldr_plural_rule_parser.src; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.vendor.*; import gplx.xowa.mediawiki.vendor.wikimedia.*; import gplx.xowa.mediawiki.vendor.wikimedia.cldr_plural_rule_parser.*;
import gplx.xowa.mediawiki.vendor.wikimedia.cldr_plural_rule_parser.src.Converter.*;
import gplx.langs.regxs.*;
@ -148,11 +148,11 @@ public class XomwConverter {
token.error("unexpected operator");
}
// Resolve higher precedence levels
XomwOperator lastOp = (XomwOperator)this.operators.end();
XomwOperator lastOp = (XomwOperator)XophpArray.end(this.operators);
while (lastOp != null && Int_.Cast(XomwConverter.precedence.Get_by(((XomwOperator)token).name)) <= Int_.Cast(XomwConverter.precedence.Get_by(((XomwOperator)lastOp).name))) {
this.doOperation(lastOp, this.operands);
this.operators.pop();
lastOp = (XomwOperator)this.operators.end();
XophpArray.array_pop(this.operators);
lastOp = (XomwOperator)XophpArray.end(this.operators);
}
this.operators.Add(token);
}
@ -160,15 +160,15 @@ public class XomwConverter {
// Finish off the stack
XomwOperator op = null;
while (null != (op = (XomwOperator)this.operators.pop())) {
while (null != (op = (XomwOperator)XophpArray.array_pop(this.operators))) {
this.doOperation(op, this.operands);
}
// Make sure the result is sane. The first case is possible for an empty
// String input, the second should be unreachable.
if (!this.operands.count_bool()) {
if (!XophpArray.count_bool(this.operands)) {
this.error("condition expected");
} else if (this.operands.count() > 1) {
} else if (XophpArray.count(this.operands) > 1) {
this.error("missing operator or too many operands");
}
@ -248,7 +248,7 @@ public class XomwConverter {
// Two-word operators like "is not" take precedence over single-word operators like "is"
if (String_.Eq(word2, "")) {
String bothWords = word1 + "-" + word2;
if (XomwConverter.precedence.isset(bothWords)) {
if (XophpArray.isset(XomwConverter.precedence, bothWords)) {
XomwFragment token = this.newOperator(bothWords, this.pos, nextTokenPos - this.pos);
this.pos = nextTokenPos;
@ -257,7 +257,7 @@ public class XomwConverter {
}
// Single-word operators
if (XomwConverter.precedence.isset(word1)) {
if (XophpArray.isset(XomwConverter.precedence, word1)) {
XomwFragment token = this.newOperator(word1, this.pos, XophpString_.strlen(word1));
this.pos += XophpString_.strlen(word1);
@ -293,11 +293,11 @@ public class XomwConverter {
* @param Operator op
*/
protected void doOperation(XomwOperator op, Object ignore) { // NOTE: MW passes 2 args, but method only has 1
if (this.operands.count() < 2) {
if (XophpArray.count(this.operands) < 2) {
op.error("missing operand");
}
XomwExpression right = (XomwExpression)this.operands.pop();
XomwExpression left = (XomwExpression)this.operands.pop();
XomwExpression right = (XomwExpression)XophpArray.array_pop(this.operands);
XomwExpression left = (XomwExpression)XophpArray.array_pop(this.operands);
XomwExpression result = op.operate(left, right);
this.operands.Add(result);
}

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.vendor.wikimedia.cldr_plural_rule_parser.src; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.vendor.*; import gplx.xowa.mediawiki.vendor.wikimedia.*; import gplx.xowa.mediawiki.vendor.wikimedia.cldr_plural_rule_parser.*;
import gplx.xowa.mediawiki.vendor.wikimedia.cldr_plural_rule_parser.src.Converter.*;
// MW.SRC:1.33.1
@ -42,7 +42,7 @@ public class XomwEvaluator {
XophpArray rv = XophpArray.New();
// We can't use array_map() for this because it generates a warning if
// there is an exception.
int rules_len = rules.count();
int rules_len = rules.Len();
for (int i = 0; i < rules_len; i++) {
String rule = rules.Get_at_str(i);
rule = XomwConverter.convert(rule);
@ -69,11 +69,11 @@ public class XomwEvaluator {
XophpArray m = XophpArray.New();
if (!XophpRegex_.preg_match_bool(gplx.langs.regxs.Regx_adp_.new_("^-?(([0-9]+)(?:\\.([0-9]+))?)"), number_str, m, 0, 0)) {
XomwLog_.wfDebug_by_method("evaluateCompiled", ": invalid number input, returning \"other\"\n");
return rules.count();
return XophpArray.count(rules);
}
XophpArray operandSymbols = null;
if (!m.isset(3)) {
if (!XophpArray.isset(m, 3)) {
operandSymbols = XophpArray.New()
.Add("n", Decimal_adp_.int_(XophpInt_.intval(m.Get_at_str(1))))
.Add("i", Decimal_adp_.int_(XophpInt_.intval(m.Get_at_str(1))))
@ -98,7 +98,7 @@ public class XomwEvaluator {
// The compiled form is RPN, with tokens strictly delimited by
// spaces, so this is a simple RPN evaluator.
int rules_len = rules.count();
int rules_len = rules.Len();
for (int i = 0; i < rules_len; i++) {
String rule = rules.Get_at_str(i);
XophpArray stack = XophpArray.New();
@ -108,13 +108,13 @@ public class XomwEvaluator {
String[] tokens = XophpString_.explode(" ", rule);
for (String token : tokens) {
int ord = XophpString_.ord(token);
if (operandSymbols.isset(token)) {
if (XophpArray.isset(operandSymbols, token)) {
stack.Add(XomwStackItem.New__number((Decimal_adp)operandSymbols.Get_by(token)));
} else if (ord >= zero && ord <= nine) {
stack.Add(XomwStackItem.New__number(Decimal_adp_.int_(XophpInt_.intval(token))));
} else {
XomwStackItem right = (XomwStackItem)stack.pop();
XomwStackItem left = (XomwStackItem)stack.pop();
XomwStackItem right = (XomwStackItem)XophpArray.array_pop(stack);
XomwStackItem left = (XomwStackItem)XophpArray.array_pop(stack);
XomwStackItem result = XomwEvaluator.doOperation(token, left, right);
stack.Add(result);
}
@ -125,7 +125,7 @@ public class XomwEvaluator {
}
// None of the provided rules match. The number belongs to category
// "other", which comes last.
return rules.count();
return XophpArray.count(rules);
}
/**

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.vendor.wikimedia.cldr_plural_rule_parser.src; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.vendor.*; import gplx.xowa.mediawiki.vendor.wikimedia.*; import gplx.xowa.mediawiki.vendor.wikimedia.cldr_plural_rule_parser.*;
// MW.SRC:1.33.1
/**
@ -50,7 +50,7 @@ class XomwRange {
*/
public boolean isNumberIn(Decimal_adp number) {return isNumberIn(number, true);}
public boolean isNumberIn(Decimal_adp number, boolean integerConstraint) {
int parts_len = parts.count();
int parts_len = parts.Len();
for (int i = 0; i < parts_len; i++) {
Object part_obj = this.parts.Get_at(i);
if (XophpArray.is_array(part_obj)) {
@ -91,7 +91,7 @@ class XomwRange {
*/
public void add(Object otherObj) {
if (Type_.Eq_by_obj(otherObj, XomwRange.class)) {
this.parts = XophpArray_.array_merge(this.parts, ((XomwRange)otherObj).parts);
this.parts = XophpArray.array_merge(this.parts, ((XomwRange)otherObj).parts);
} else {
this.parts.Add(otherObj);
}
@ -105,7 +105,7 @@ class XomwRange {
*/
@Override public String toString() {
String s = "Range(";
int parts_len = this.parts.count();
int parts_len = this.parts.Len();
for (int i = 0; i < parts_len; i++) {
Object part_obj = this.parts.Get_at(i);
if (i > 0) {

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.xtns.pfuncs.langs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
import gplx.xowa.langs.*; import gplx.xowa.langs.kwds.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.tmpls.*;
@ -39,8 +39,8 @@ public class Pfunc_plural extends Pf_func_base {
// no match for explicit key; take results (which has removed all explicit keys) and get plural rule index; EX: {{plural:1|2=two|3=three|one|many}} -> {{plural:?|one|many}}
XophpArray resultArray = (XophpArray)result;
int idx = ctx.Lang().Mw_lang().getPluralRuleIndexNumber(number_str);
if (idx >= resultArray.count()) // bound-check; EX: {{plural:2|wiki}} -> idx = 1 -> idx = 0
idx = resultArray.count() - 1;
if (idx >= XophpArray.count(resultArray)) // bound-check; EX: {{plural:2|wiki}} -> idx = 1 -> idx = 0
idx = XophpArray.count(resultArray) - 1;
bfr.Add_str_u8(resultArray.Get_at_str(idx));
}
}

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
import gplx.langs.jsons.*; import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.parsers.*; import gplx.xowa.xtns.wbases.claims.itms.*; import gplx.xowa.xtns.wbases.stores.*;
import gplx.xowa.wikis.domains.*;
@ -359,11 +359,11 @@ public function formatValues( $snaksSerialization ) {
// }
// }
// ksort( orderedPropertiesPart );
// orderedProperties = XophpArray_.array_merge(orderedPropertiesPart, unorderedProperties);
// orderedProperties = XophpArray.array_merge(orderedPropertiesPart, unorderedProperties);
// Lua tables start at 1
// XophpArray orderedPropertiesResult = XophpArray_.array_combine(
// range(1, count(orderedProperties)), XophpArray_.array_values(orderedProperties)
// XophpArray orderedPropertiesResult = XophpArray.array_combine(
// range(1, count(orderedProperties)), XophpArray.array_values(orderedProperties)
// );
// return rslt.Init_obj(orderedPropertiesResult.To_kv_ary());
return rslt.Init_obj(propertyIds);

@ -13,18 +13,19 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
package gplx.xowa.mediawiki;
import org.junit.*; import gplx.core.tests.*;
public class XophpArray_tst { // REF: http://php.net/manual/en/language.types.array.php
private final XophpArray_fxt fxt = new XophpArray_fxt();
public class XophpArrayInstanceTest { // REF: http://php.net/manual/en/language.types.array.php
private final XophpArrayfxt fxt = new XophpArrayfxt();
@Test public void array__kvs() {
// $array = array("foo" => "bar", "bar" => "foo",);
fxt.Test__array
( XophpArray.New()
. Add("foo", "bar")
. Add("bar", "foo")
, XophpArrayItm.New_str("foo", "bar")
, XophpArrayItm.New_str("bar", "foo")
, XophpArrayItm.NewStr("foo", "bar")
, XophpArrayItm.NewStr("bar", "foo")
);
}
@Test public void array__casting() {
@ -35,7 +36,7 @@ public class XophpArray_tst { // REF: http://php.net/manual/en/language.types.ar
. Add("1" , "b")
. Add(1.5 , "c")
. Add(true, "d")
, XophpArrayItm.New_int(1, "d"));
, XophpArrayItm.NewInt(1, "d"));
}
@Test public void array__mixed() {
// $array = array("foo" => "bar", "bar" => "foo", 100 => -100, -100 => 100);
@ -45,10 +46,10 @@ public class XophpArray_tst { // REF: http://php.net/manual/en/language.types.ar
. Add("bar", "foo")
. Add(100, -100)
. Add(-100, 100)
, XophpArrayItm.New_str("foo", "bar")
, XophpArrayItm.New_str("bar", "foo")
, XophpArrayItm.New_int(100, -100)
, XophpArrayItm.New_int(-100, 100)
, XophpArrayItm.NewStr("foo", "bar")
, XophpArrayItm.NewStr("bar", "foo")
, XophpArrayItm.NewInt(100, -100)
, XophpArrayItm.NewInt(-100, 100)
);
}
@Test public void array__objs() {
@ -59,10 +60,10 @@ public class XophpArray_tst { // REF: http://php.net/manual/en/language.types.ar
. Add("bar")
. Add("hello")
. Add("world")
, XophpArrayItm.New_int(0, "foo")
, XophpArrayItm.New_int(1, "bar")
, XophpArrayItm.New_int(2, "hello")
, XophpArrayItm.New_int(3, "world")
, XophpArrayItm.NewInt(0, "foo")
, XophpArrayItm.NewInt(1, "bar")
, XophpArrayItm.NewInt(2, "hello")
, XophpArrayItm.NewInt(3, "world")
);
}
@Test public void array__unkeyed() {
@ -73,10 +74,10 @@ public class XophpArray_tst { // REF: http://php.net/manual/en/language.types.ar
. Add("b")
. Add(6, "c")
. Add("d")
, XophpArrayItm.New_int(0, "a")
, XophpArrayItm.New_int(1, "b")
, XophpArrayItm.New_int(6, "c")
, XophpArrayItm.New_int(7, "d")
, XophpArrayItm.NewInt(0, "a")
, XophpArrayItm.NewInt(1, "b")
, XophpArrayItm.NewInt(6, "c")
, XophpArrayItm.NewInt(7, "d")
);
}
@Test public void array__multidimensional() {
@ -99,9 +100,9 @@ public class XophpArray_tst { // REF: http://php.net/manual/en/language.types.ar
. Add("dimensional", XophpArray.New()
. Add("array", "foo")
))
, XophpArrayItm.New_str("foo", "bar")
, XophpArrayItm.New_int(42, "24")
, XophpArrayItm.New_str("multi", XophpArray.New()
, XophpArrayItm.NewStr("foo", "bar")
, XophpArrayItm.NewInt(42, "24")
, XophpArrayItm.NewStr("multi", XophpArray.New()
. Add("dimensional", XophpArray.New()
. Add("array", "foo")
))
@ -112,13 +113,13 @@ public class XophpArray_tst { // REF: http://php.net/manual/en/language.types.ar
ary.Add(0, "a").Add(1, "b");
// delete all
ary.unset(0);
ary.unset(1);
XophpArray.unset(ary, 0);
XophpArray.unset(ary, 1);
fxt.Test__array(ary);
// add new and assert idx is 2
ary.Add("c");
fxt.Test__array(ary, XophpArrayItm.New_int(2, "c"));
fxt.Test__array(ary, XophpArrayItm.NewInt(2, "c"));
}
@Test public void Pop() {
XophpArray ary = XophpArray.New();
@ -154,9 +155,9 @@ public class XophpArray_tst { // REF: http://php.net/manual/en/language.types.ar
fxt.Test__Get_by(ary, "missing", null);
}
}
class XophpArray_fxt {
class XophpArrayfxt {
public void Test__Count(XophpArray ary, int expd) {
Gftest.Eq__int(expd, ary.count());
Gftest.Eq__int(expd, ary.Len());
}
public void Test__array(XophpArray ary, XophpArrayItm... expd) {
XophpArrayItm[] actl = ary.To_ary();
@ -167,7 +168,7 @@ class XophpArray_fxt {
Gftest.Eq__ary(expd, actl);
}
public void Test__Pop(XophpArray ary, String expd) {
String actl = (String)ary.pop();
String actl = (String)XophpArray.array_pop(ary);
Gftest.Eq__str(expd, actl);
}
public void Test__Itm_str_concat_end(XophpArray ary, String expd, int idx, String v) {

@ -22,61 +22,61 @@ import gplx.String_;
import gplx.core.tests.Gftest;
import org.junit.Test;
public class XophpArray__tst {
private final XophpArray__fxt fxt = new XophpArray__fxt();
public class XophpArrayStaticTest {
private final XophpArray_fxt fxt = new XophpArray_fxt();
// REF.PHP:https://www.php.net/manual/en/function.array-merge.php
@Test public void array_merge__basic() {
XophpArray ary1 = fxt.Make().Add("key1", "val1").Add("a");
XophpArray ary2 = fxt.Make().Add("key2", "val2").Add("b");
fxt.Test__eq
( fxt.Make().Add("key1", "val1").Add("a").Add("key2", "val2").Add("b")
, XophpArray_.array_merge(ary1, ary2));
, XophpArray.array_merge(ary1, ary2));
}
@Test public void array_merge__same_key() {
XophpArray ary1 = fxt.Make().Add("key", "val1");
XophpArray ary2 = fxt.Make().Add("key", "val2");
fxt.Test__eq
( fxt.Make().Add("key", "val2")
, XophpArray_.array_merge(ary1, ary2));
, XophpArray.array_merge(ary1, ary2));
}
@Test public void array_merge__same_idx() {
XophpArray ary1 = fxt.Make().Add(0, "a");
XophpArray ary2 = fxt.Make().Add(0, "b");
fxt.Test__eq
( fxt.Make().Add(0, "a").Add(1, "b")
, XophpArray_.array_merge(ary1, ary2));
, XophpArray.array_merge(ary1, ary2));
}
@Test public void array_merge__renumber() {
XophpArray ary1 = fxt.Make().Add(3, "a");
XophpArray ary2 = fxt.Make().Add(2, "b");
fxt.Test__eq
( fxt.Make().Add(0, "a").Add(1, "b")
, XophpArray_.array_merge(ary1, ary2));
, XophpArray.array_merge(ary1, ary2));
}
@Test public void array_merge__example_1() {
XophpArray ary1 = fxt.Make().Add("color", "red").Add_many(2, 4);
XophpArray ary2 = fxt.Make().Add_many("a", "b").Add("color", "green").Add("shape", "trapezoid").Add(4);
fxt.Test__eq
( fxt.Make().Add("color", "green").Add_many(2, 4, "a", "b").Add("shape", "trapezoid").Add(4)
, XophpArray_.array_merge(ary1, ary2));
, XophpArray.array_merge(ary1, ary2));
}
@Test public void array_merge__example_2() {
XophpArray ary1 = fxt.Make();
XophpArray ary2 = fxt.Make().Add(1, "data");
fxt.Test__eq
( fxt.Make().Add(0, "data")
, XophpArray_.array_merge(ary1, ary2));
, XophpArray.array_merge(ary1, ary2));
}
@Test public void array_add() {
XophpArray ary1 = fxt.Make().Add(0, "zero_a").Add(2, "two_a").Add(3, "three_a");
XophpArray ary2 = fxt.Make().Add(1, "one_b").Add(3, "three_b").Add(4, "four_b");
fxt.Test__eq
( fxt.Make().Add(0, "zero_a").Add(2, "two_a").Add(3, "three_a").Add(1, "one_b").Add(4, "four_b")
, XophpArray_.array_add(ary1, ary2));
, XophpArray.array_add(ary1, ary2));
}
@Test public void array_splice__bgn_is_positive() {
XophpArray src = fxt.Make().Add_many("a", "b", "c", "d");
XophpArray del = XophpArray_.array_splice(src, 1);
XophpArray del = XophpArray.array_splice(src, 1);
fxt.Test__eq
( fxt.Make().Add_many("a")
, src
@ -88,7 +88,7 @@ public class XophpArray__tst {
}
@Test public void array_splice__bgn_is_positive_large() {
XophpArray src = fxt.Make().Add_many("a", "b", "c", "d");
XophpArray del = XophpArray_.array_splice(src, 99);
XophpArray del = XophpArray.array_splice(src, 99);
fxt.Test__eq
( fxt.Make().Add_many("a", "b", "c", "d")
, src
@ -100,7 +100,7 @@ public class XophpArray__tst {
}
@Test public void array_splice__bgn_is_negative() {
XophpArray src = fxt.Make().Add_many("a", "b", "c", "d");
XophpArray del = XophpArray_.array_splice(src, -3);
XophpArray del = XophpArray.array_splice(src, -3);
fxt.Test__eq
( fxt.Make().Add_many("a")
, src
@ -112,7 +112,7 @@ public class XophpArray__tst {
}
@Test public void array_splice__bgn_is_negative_large() {
XophpArray src = fxt.Make().Add_many("a", "b", "c", "d");
XophpArray del = XophpArray_.array_splice(src, -99);
XophpArray del = XophpArray.array_splice(src, -99);
fxt.Test__eq
( fxt.Make()
, src
@ -124,7 +124,7 @@ public class XophpArray__tst {
}
@Test public void array_splice__len_is_positive() {
XophpArray src = fxt.Make().Add_many("a", "b", "c", "d");
XophpArray del = XophpArray_.array_splice(src, 1, 2);
XophpArray del = XophpArray.array_splice(src, 1, 2);
fxt.Test__eq
( fxt.Make().Add_many("a", "d")
, src
@ -136,7 +136,7 @@ public class XophpArray__tst {
}
@Test public void array_splice__len_is_positive_large() {
XophpArray src = fxt.Make().Add_many("a", "b", "c", "d");
XophpArray del = XophpArray_.array_splice(src, 1, 99);
XophpArray del = XophpArray.array_splice(src, 1, 99);
fxt.Test__eq
( fxt.Make().Add_many("a")
, src
@ -148,7 +148,7 @@ public class XophpArray__tst {
}
@Test public void array_splice__len_is_negative() {
XophpArray src = fxt.Make().Add_many("a", "b", "c", "d");
XophpArray del = XophpArray_.array_splice(src, 1, -2);
XophpArray del = XophpArray.array_splice(src, 1, -2);
fxt.Test__eq
( fxt.Make().Add_many("a", "c", "d")
, src
@ -160,7 +160,7 @@ public class XophpArray__tst {
}
@Test public void array_splice__len_is_negative_large() {
XophpArray src = fxt.Make().Add_many("a", "b", "c", "d");
XophpArray del = XophpArray_.array_splice(src, 1, -99);
XophpArray del = XophpArray.array_splice(src, 1, -99);
fxt.Test__eq
( fxt.Make().Add_many("a", "b", "c", "d")
, src
@ -172,7 +172,7 @@ public class XophpArray__tst {
}
@Test public void array_splice__repl() {
XophpArray src = fxt.Make().Add(0, "a").Add(1, "b").Add(2, "c").Add(3, "d");
XophpArray del = XophpArray_.array_splice(src, 1, 2, fxt.Make().Add(0, "x"));
XophpArray del = XophpArray.array_splice(src, 1, 2, fxt.Make().Add(0, "x"));
fxt.Test__eq
( fxt.Make().Add(0, "a").Add(1, "x").Add(2, "d")
, src
@ -184,7 +184,7 @@ public class XophpArray__tst {
}
@Test public void array_splice__example_1a() {
XophpArray src = fxt.Make().Add_many("red", "green", "blue", "yellow");
XophpArray del = XophpArray_.array_splice(src, 2);
XophpArray del = XophpArray.array_splice(src, 2);
fxt.Test__eq
( fxt.Make().Add_many("red", "green")
, src
@ -196,7 +196,7 @@ public class XophpArray__tst {
}
@Test public void array_splice__example_1b() {
XophpArray src = fxt.Make().Add_many("red", "green", "blue", "yellow");
XophpArray del = XophpArray_.array_splice(src, 1, -1);
XophpArray del = XophpArray.array_splice(src, 1, -1);
fxt.Test__eq
( fxt.Make().Add_many("red", "yellow")
, src
@ -208,7 +208,7 @@ public class XophpArray__tst {
}
@Test public void array_splice__example_1c() {
XophpArray src = fxt.Make().Add_many("red", "green", "blue", "yellow");
XophpArray del = XophpArray_.array_splice(src, 1, 4, XophpArray.New("orange"));
XophpArray del = XophpArray.array_splice(src, 1, 4, XophpArray.New("orange"));
fxt.Test__eq
( fxt.Make().Add_many("red", "orange")
, src
@ -220,7 +220,7 @@ public class XophpArray__tst {
}
@Test public void array_splice__example_1d() {
XophpArray src = fxt.Make().Add_many("red", "green", "blue", "yellow");
XophpArray del = XophpArray_.array_splice(src, -1, 1, XophpArray.New("black", "maroon"));
XophpArray del = XophpArray.array_splice(src, -1, 1, XophpArray.New("black", "maroon"));
fxt.Test__eq
( fxt.Make().Add_many("red", "green", "blue", "black", "maroon")
, src
@ -234,35 +234,35 @@ public class XophpArray__tst {
XophpArray orig = fxt.Make().Add("size", "XL").Add("color", "gold");
fxt.Test__eq
( fxt.Make().Add(0, "XL").Add(1, "gold")
, orig.values()
, XophpArray.array_values(orig)
);
}
@Test public void array_map() {
XophpArray orig = fxt.Make().Add_many("a", "b", "c");
fxt.Test__eq
( fxt.Make().Add_many("A", "B", "C")
, XophpArray_.array_map(XophpString_.Callback_owner, "strtoupper", orig)
, XophpArray.array_map(XophpString_.Callback_owner, "strtoupper", orig)
);
}
@Test public void array_flip__basic() {
XophpArray orig = fxt.Make().Add_many("oranges", "apples", "pears");
fxt.Test__eq
( fxt.Make().Add("oranges", 0).Add("apples", 1).Add("pears", 2)
, XophpArray_.array_flip(orig)
, XophpArray.array_flip(orig)
);
}
@Test public void array_flip__collision() {
XophpArray orig = fxt.Make().Add("a", 1).Add("b", 1).Add("c", 2);
fxt.Test__eq
( fxt.Make().Add("1", "b").Add("2", "c")
, XophpArray_.array_flip(orig)
, XophpArray.array_flip(orig)
);
}
@Test public void implode() {
XophpArray orig = fxt.Make().Add_many("a", "b", "c");
Gftest.Eq__str
( "a b c"
, XophpArray_.implode(" ", orig)
, XophpArray.implode(" ", orig)
);
}
@Test public void in_array() {
@ -270,19 +270,19 @@ public class XophpArray__tst {
XophpArray array;
// Example #1
array = XophpArray.New("Mac", "NT", "Irix", "Linux");
Gftest.Eq__bool(Bool_.Y, XophpArray_.in_array("Irix", array));
Gftest.Eq__bool(Bool_.N, XophpArray_.in_array("mac" , array));
Gftest.Eq__bool(Bool_.Y, XophpArray.in_array("Irix", array));
Gftest.Eq__bool(Bool_.N, XophpArray.in_array("mac" , array));
// Example #2
array = XophpArray.New(12.4d, 1.13d);
Gftest.Eq__bool(Bool_.N, XophpArray_.in_array("12.4", array, true));
Gftest.Eq__bool(Bool_.Y, XophpArray_.in_array( 1.13d, array, true));
Gftest.Eq__bool(Bool_.N, XophpArray.in_array("12.4", array, true));
Gftest.Eq__bool(Bool_.Y, XophpArray.in_array( 1.13d, array, true));
// Example #3
array = XophpArray.New(XophpArray.New('p', 'h'), XophpArray.New('p', 'r'), 'o');
Gftest.Eq__bool(Bool_.Y, XophpArray_.in_array(XophpArray.New('p', 'h'), array));
Gftest.Eq__bool(Bool_.N, XophpArray_.in_array(XophpArray.New('f', 'i'), array));
Gftest.Eq__bool(Bool_.Y, XophpArray_.in_array('o', array));
Gftest.Eq__bool(Bool_.Y, XophpArray.in_array(XophpArray.New('p', 'h'), array));
Gftest.Eq__bool(Bool_.N, XophpArray.in_array(XophpArray.New('f', 'i'), array));
Gftest.Eq__bool(Bool_.Y, XophpArray.in_array('o', array));
}
@Test public void array_shift() {
XophpArray array;
@ -290,7 +290,7 @@ public class XophpArray__tst {
// key is int
array = XophpArray.New("a", "b");
shifted = (String)XophpArray_.array_shift(array);
shifted = (String)XophpArray.array_shift(array);
Gftest.Eq__str("a", shifted);
fxt.Test__eq
@ -300,7 +300,7 @@ public class XophpArray__tst {
// key is str and int
array = XophpArray.New().Add("a", "a").Add(2, "b").Add(5, "c");
shifted = (String)XophpArray_.array_shift(array);
shifted = (String)XophpArray.array_shift(array);
Gftest.Eq__str("a", shifted);
fxt.Test__eq
@ -310,7 +310,7 @@ public class XophpArray__tst {
// empty
array = XophpArray.New();
shifted = (String)XophpArray_.array_shift(array);
shifted = (String)XophpArray.array_shift(array);
Gftest.Eq__bool_y(shifted == null);
fxt.Test__eq
@ -320,7 +320,7 @@ public class XophpArray__tst {
// null
array = null;
shifted = (String)XophpArray_.array_shift(array);
shifted = (String)XophpArray.array_shift(array);
Gftest.Eq__bool_y(shifted == null);
Gftest.Eq__bool_y(array == null);
@ -328,7 +328,7 @@ public class XophpArray__tst {
// PHP examples
// Example #1
array = XophpArray.New("orange", "banana", "apple", "strawberry");
shifted = (String)XophpArray_.array_shift(array);
shifted = (String)XophpArray.array_shift(array);
Gftest.Eq__str("orange", shifted);
fxt.Test__eq
@ -344,31 +344,31 @@ public class XophpArray__tst {
array = XophpArray.New().Add("a", 1).Add("b", 2).Add("c", 3).Add("d", 4).Add("e", 5);
fxt.Test__eq
( XophpArray.New().Add("a", 1).Add("c", 3).Add("e", 5)
, XophpArray_.array_filter(array, callbackOwner.NewCallback("array_filter_odd"))
, XophpArray.array_filter(array, callbackOwner.NewCallback("array_filter_odd"))
);
array = XophpArray.New(6, 7, 8, 9, 10, 11, 12);
fxt.Test__eq
( XophpArray.New().Add(0, 6).Add(2, 8).Add(4, 10).Add(6, 12)
, XophpArray_.array_filter(array, callbackOwner.NewCallback( "array_filter_even"))
, XophpArray.array_filter(array, callbackOwner.NewCallback( "array_filter_even"))
);
// Example #2 array_filter() without callback
array = XophpArray.New().Add(0, "foo").Add(1, false).Add(2, -1).Add(3, null).Add(4, "").Add(5, "0").Add(6, 0);
fxt.Test__eq
( XophpArray.New().Add(0, "foo").Add(2, -1)
, XophpArray_.array_filter(array)
, XophpArray.array_filter(array)
);
// Example #3 array_filter() with flag
array = XophpArray.New().Add("a", 1).Add("b", 2).Add("c", 3).Add("d", 4);
fxt.Test__eq
( XophpArray.New().Add("b", 2)
, XophpArray_.array_filter(array, callbackOwner.NewCallback("array_filter_key"), XophpArray_.ARRAY_FILTER_USE_KEY)
, XophpArray.array_filter(array, callbackOwner.NewCallback("array_filter_key"), XophpArray.ARRAY_FILTER_USE_KEY)
);
fxt.Test__eq
( XophpArray.New().Add("b", 2).Add("d", 4)
, XophpArray_.array_filter(array, callbackOwner.NewCallback("array_filter_both"), XophpArray_.ARRAY_FILTER_USE_BOTH)
, XophpArray.array_filter(array, callbackOwner.NewCallback("array_filter_both"), XophpArray.ARRAY_FILTER_USE_BOTH)
);
}
@Test public void reset() {
@ -390,7 +390,7 @@ public class XophpArray__tst {
Gftest.Eq__str("step one", (String)XophpArray.current(array));
}
}
class XophpArray__fxt {
class XophpArray_fxt {
public XophpArray Make() {return new XophpArray();}
public void Test__eq(XophpArray expd, XophpArray actl) {
Gftest.Eq__str(expd.To_str(), actl.To_str());

@ -2,7 +2,6 @@ package gplx.xowa.mediawiki.includes;
import gplx.core.tests.Gftest;
import gplx.xowa.mediawiki.XophpArray;
import gplx.xowa.mediawiki.XophpArray__tst;
import gplx.xowa.mediawiki.XophpCallback;
import gplx.xowa.mediawiki.XophpCallbackOwner;
import org.junit.Before;
@ -75,7 +74,7 @@ class XomwHooksTestCallbackOwner implements XophpCallbackOwner {
public String Result() {return result;} private String result = "";
@Override
public Object Call(String method, Object... args) {
result += method + ":" + (args == null ? -1 : ((XophpArray)args[0]).count()) + ";";
result += method + ":" + (args == null ? -1 : ((XophpArray)args[0]).Len()) + ";";
return null; // NOTE: XomwHooks throws error if non-null
}
}
Loading…
Cancel
Save