1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-10-27 20:34:16 +00:00

Xomw: Add XomwSiteList and XomwGenericArrayObject

This commit is contained in:
gnosygnu 2017-03-18 09:49:11 -04:00
parent 5967c75433
commit a1d2e69211
12 changed files with 9211 additions and 357 deletions

View File

@ -15,14 +15,15 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx; package gplx;
public interface Hash_adp extends gplx.core.lists.EnumerAble { public interface Hash_adp extends gplx.core.lists.EnumerAble {
int Count(); int Count();
boolean Has(Object key); boolean Has(Object key);
Object Get_by(Object key); Object Get_by(Object key);
Object Get_by_or_fail(Object key); Object Get_by_or_fail(Object key);
void Add(Object key, Object val); void Add(Object key, Object val);
void Add_as_key_and_val(Object val); Hash_adp Add_and_more(Object key, Object val);
boolean Add_if_dupe_use_1st(Object key, Object val); void Add_as_key_and_val(Object val);
void Add_if_dupe_use_nth(Object key, Object val); boolean Add_if_dupe_use_1st(Object key, Object val);
void Del(Object key); void Add_if_dupe_use_nth(Object key, Object val);
void Clear(); void Del(Object key);
void Clear();
} }

View File

@ -26,6 +26,7 @@ class Hash_adp_noop implements Hash_adp {
public Object Get_by(Object key) {return null;} public Object Get_by(Object key) {return null;}
public Object Get_by_or_fail(Object key) {throw Err_.new_missing_key(Object_.Xto_str_strict_or_null_mark(key));} public Object Get_by_or_fail(Object key) {throw Err_.new_missing_key(Object_.Xto_str_strict_or_null_mark(key));}
public void Add(Object key, Object val) {} public void Add(Object key, Object val) {}
public Hash_adp Add_and_more(Object key, Object val) {return this;}
public void Add_as_key_and_val(Object val) {} public void Add_as_key_and_val(Object val) {}
public void Add_if_dupe_use_nth(Object key, Object val) {} public void Add_if_dupe_use_nth(Object key, Object val) {}
public boolean Add_if_dupe_use_1st(Object key, Object val) {return false;} public boolean Add_if_dupe_use_1st(Object key, Object val) {return false;}

View File

@ -19,6 +19,7 @@ public abstract class Hash_adp_base implements Hash_adp {
public Object Get_by(Object key) {return Fetch_base(key);} public Object Get_by(Object key) {return Fetch_base(key);}
public Object Get_by_or_fail(Object key) {return Get_by_or_fail_base(key);} public Object Get_by_or_fail(Object key) {return Get_by_or_fail_base(key);}
public void Add(Object key, Object val) {Add_base(key, val);} public void Add(Object key, Object val) {Add_base(key, val);}
public Hash_adp Add_and_more(Object key, Object val) {Add_base(key, val); return this;}
public void Add_as_key_and_val(Object val) {Add_base(val, val);} public void Add_as_key_and_val(Object val) {Add_base(val, val);}
public void Add_if_dupe_use_nth(Object key, Object val) { public void Add_if_dupe_use_nth(Object key, Object val) {
Object existing = Fetch_base(key); if (existing != null) Del(key); // overwrite if exists Object existing = Fetch_base(key); if (existing != null) Del(key); // overwrite if exists

View File

@ -15,5 +15,5 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.dbs; import gplx.*; package gplx.dbs; import gplx.*;
public class Db_conn_ { public class Db_conn_ {
public static final Db_conn Noop = Db_conn_pool.Instance.Get_or_new(Db_conn_info_.Null); public static final Db_conn Noop = new Db_conn(gplx.dbs.engines.noops.Noop_engine.Instance);
} }

View File

@ -17,4 +17,24 @@ package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
public class XophpArray { public class XophpArray {
public static boolean popBoolOrN(List_adp list) {return Bool_.Cast(List_adp_.Pop_or(list, false));} 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 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 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_is_empty(Ordered_hash array) {
return array.Len() == 0;
}
public static void unset(Ordered_hash array, Object key) {
array.Del(key);
}
} }

View File

@ -0,0 +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
*/
package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
public class XophpInvalidArgumentException extends Err { public XophpInvalidArgumentException(String text) {super(false, "", text, text);}
}

View File

@ -38,6 +38,7 @@ public class XophpUtility {
return true; return true;
} }
public static boolean is_null(int v) {return v == NULL_INT;}
public static final int NULL_INT = Int_.Max_value; public static final int NULL_INT = Int_.Max_value;
public static final double NULL_DOUBLE = Double_.MinValue; public static final double NULL_DOUBLE = Double_.MinValue;
public static final byte[] NULL_BRY = null; public static final byte[] NULL_BRY = null;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,39 @@
/*
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.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
// bare-bones implementation of PHP ArrayObject
// REF:http://php.net/manual/en/class.arrayobject.php
public abstract class XomwArrayObject {
private final Ordered_hash hash = Ordered_hash_.New();
public boolean offsetExists(Object key) {
return hash.Has(key);
}
public Object offsetGet(Object key) {
return hash.Get_by(key);
}
public void offsetUnset(Object key) {
hash.Del(key);
}
@gplx.Virtual public void offsetSet(int key, Object val) {
hash.Add(key, val);
}
public int count() {return hash.Len();}
public Object Get_at(int i) {return hash.Get_at(i);}
public void Add_or_update(Object val) {
hash.Add(hash.Count(), val);
}
}

View File

@ -0,0 +1,231 @@
/*
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.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
/**
* Extends ArrayObject and does two things:
*
* Allows for deriving cla+sses to easily intercept additions
* and deletions for purposes such as additional indexing.
*
* Enforces the objects to be of a certain type, so this
* can be replied upon, much like if this had true support
* for generics, which sadly enough is not possible in PHP.
*/
public abstract class XomwGenericArrayObject extends XomwArrayObject { /**
* Returns the name of an interface/class that the element should implement/extend.
*
* @since 1.20
*
* @return String
*/
abstract public Class<?> getObjectType();
/**
* @see SiteList::getNewOffset()
* @since 1.20
* @var integer
*/
protected int indexOffset = 0;
/**
* Finds a new offset for when appending an element.
* The super class does this, so it would be better to integrate,
* but there does not appear to be any way to do this...
*
* @since 1.20
*
* @return integer
*/
protected int getNewOffset() {
while (this.offsetExists(this.indexOffset)) {
this.indexOffset++;
}
return this.indexOffset;
}
/**
* Constructor.
* @see ArrayObject::__construct
*
* @since 1.20
*
* @param null|array $input
* @param int $flags
* @param String $iterator_class
*/
public XomwGenericArrayObject() {
// if (input != null) {
// int len = Array_.Len(input);
// for (int i = 0; i < len; i++) {
// Object val = Array_.Get_at(input, i);
// this.offsetSet(i, val);
// }
// }
}
/**
* @see ArrayObject::append
*
* @since 1.20
*
* @param mixed $value
*/
public void append(Object val) {
this.setElement(XophpUtility.NULL_INT, val);
}
/**
* @see ArrayObject::offsetSet()
*
* @since 1.20
*
* @param mixed $index
* @param mixed $value
*/
@Override public void offsetSet(int index, Object val) {
this.setElement(index, val);
}
/**
* Returns if the provided value has the same type as the elements
* that can be added to this ArrayObject.
*
* @since 1.20
*
* @param mixed $value
*
* @return boolean
*/
protected boolean hasValidType(Object val) {
Class<?> cls = this.getObjectType();
return Type_adp_.Eq_typeSafe(val, cls);
}
/**
* Method that actually sets the element and holds
* all common code needed for set operations, including
* type checking and offset resolving.
*
* If you want to do additional indexing or have code that
* otherwise needs to be executed whenever an element is added,
* you can overload @see preSetElement.
*
* @since 1.20
*
* @param mixed $index
* @param mixed $value
*
* @throws InvalidArgumentException
*/
protected void setElement(int index, Object val) {
if (!this.hasValidType(val)) {
throw new XophpInvalidArgumentException(
"Can only add " + Type_adp_.FullNameOf_type(this.getObjectType()) + " implementing objects to "
+ Type_adp_.ClassOf_obj(this) + "."
);
}
if (XophpUtility.is_null(index)) {
index = this.getNewOffset();
}
if (this.preSetElement(index, val)) {
super.offsetSet(index, val);
}
}
/**
* Gets called before a new element is added to the ArrayObject.
*
* At this point the index is always set (ie not null) and the
* value is always of the type returned by @see getObjectType.
*
* Should return a boolean. When false is returned the element
* does not get added to the ArrayObject.
*
* @since 1.20
*
* @param integer|String $index
* @param mixed $value
*
* @return boolean
*/
protected boolean preSetElement(int index, Object val) {
return true;
}
// /**
// * @see Serializable::serialize
// *
// * @since 1.20
// *
// * @return String
// */
// public function serialize() {
// return serialize(this.getSerializationData());
// }
//
// /**
// * Returns an array holding all the data that should go into serialization calls.
// * This is intended to allow overloading without having to reimplement the
// * behavior of this super class.
// *
// * @since 1.20
// *
// * @return array
// */
// protected function getSerializationData() {
// return [
// 'data' => this.getArrayCopy(),
// 'index' => this.indexOffset,
// ];
// }
//
// /**
// * @see Serializable::unserialize
// *
// * @since 1.20
// *
// * @param String $serialization
// *
// * @return array
// */
// public function unserialize($serialization) {
// $serializationData = unserialize($serialization);
//
// foreach ($serializationData['data'] as $offset => $value) {
// // Just set the element, bypassing checks and offset resolving,
// // as these elements have already gone through this.
// parent::offsetSet($offset, $value);
// }
//
// this.indexOffset = $serializationData['index'];
//
// return $serializationData;
// }
/**
* Returns if the ArrayObject has no elements.
*
* @since 1.20
*
* @return boolean
*/
@gplx.Virtual public boolean isEmpty() {
return this.count() == 0;
}
}

View File

@ -83,7 +83,7 @@ public class XomwSite {
* *
* @var array[] * @var array[]
*/ */
private Hash_adp localIds; private Ordered_hash localIds;
/** /**
* @since 1.21 * @since 1.21
@ -492,12 +492,12 @@ public class XomwSite {
*/ */
public void addLocalId(String type, String identifier) { public void addLocalId(String type, String identifier) {
if (this.localIds == null) { if (this.localIds == null) {
this.localIds = Hash_adp_.New(); this.localIds = Ordered_hash_.New();
} }
Hash_adp typeHash = (Hash_adp)this.localIds.Get_by(type); Ordered_hash typeHash = (Ordered_hash)this.localIds.Get_by(type);
if (typeHash == null) { if (typeHash == null) {
typeHash = Hash_adp_.New(); typeHash = Ordered_hash_.New();
this.localIds.Add(type, typeHash); this.localIds.Add(type, typeHash);
} }
@ -535,8 +535,8 @@ public class XomwSite {
* *
* @return String[] * @return String[]
*/ */
public Hash_adp getInterwikiIds() { public Ordered_hash getInterwikiIds() {
return (Hash_adp)this.localIds.Get_by(XomwSite.ID_INTERWIKI); return (Ordered_hash)this.localIds.Get_by(XomwSite.ID_INTERWIKI);
} }
/** /**
@ -547,8 +547,8 @@ public class XomwSite {
* *
* @return String[] * @return String[]
*/ */
public Hash_adp getNavigationIds() { public Ordered_hash getNavigationIds() {
return (Hash_adp)this.localIds.Get_by(XomwSite.ID_EQUIVALENT); return (Ordered_hash)this.localIds.Get_by(XomwSite.ID_EQUIVALENT);
} }
/** /**
@ -558,7 +558,7 @@ public class XomwSite {
* *
* @return array[] * @return array[]
*/ */
public Hash_adp getLocalIds() { public Ordered_hash getLocalIds() {
return this.localIds; return this.localIds;
} }
@ -635,20 +635,10 @@ public class XomwSite {
* @return Site * @return Site
*/ */
public static XomwSite newForType(String siteType) { public static XomwSite newForType(String siteType) {
// global $wgSiteTypes; String type = (String)XomwDefaultSettings.wgSiteTypes.Get_by(siteType);
if (String_.Eq(type, XomwDefaultSettings.wgSiteTypes__MediaWikiSite)) {
/* return new XomwMediaWikiSite();
//$wgSiteTypes = [
// 'mediawiki' => 'MediaWikiSite',
//];
Object o = XomwDefaultSettings.wgSiteTypes;
if (o != null) {
return new XomwMediaWikiSite()
} }
*/
// if (array_key_exists($siteType, $wgSiteTypes)) {
// return new $wgSiteTypes[$siteType]();
// }
return new XomwSite(siteType); return new XomwSite(siteType);
} }

View File

@ -14,332 +14,340 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.includes.site; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; package gplx.xowa.mediawiki.includes.site; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import gplx.xowa.mediawiki.includes.libs.*;
/** /**
* Collection of Site objects. * Collection of Site objects.
*/ */
public class XomwSiteList { public class XomwSiteList extends XomwGenericArrayObject { public int Len() {return 0;}
public int Len() {return 0;}
public XomwSite GetAt(int idx) {return null;} public XomwSite GetAt(int idx) {return null;}
// /** public XomwSiteList() {super();
// * Internal site identifiers pointing to their sites offset value. }
// * /**
// * @since 1.21 * Internal site identifiers pointing to their sites offset value.
// * *
// * @var array Array of integer * @since 1.21
// */ *
// protected $byInternalId = []; * @var array Array of integer
// */
// /** private final Ordered_hash byInternalId = Ordered_hash_.New();
// * Global site identifiers pointing to their sites offset value.
// * /**
// * @since 1.21 * Global site identifiers pointing to their sites offset value.
// * *
// * @var array Array of String * @since 1.21
// */ *
// protected $byGlobalId = []; * @var array Array of String
// */
// /** private final Ordered_hash byGlobalId = Ordered_hash_.New();
// * Navigational site identifiers alias inter-language prefixes
// * pointing to their sites offset value. /**
// * * Navigational site identifiers alias inter-language prefixes
// * @since 1.23 * pointing to their sites offset value.
// * *
// * @var array Array of String * @since 1.23
// */ *
// protected $byNavigationId = []; * @var array Array of String
// */
// /** private final Ordered_hash byNavigationId = Ordered_hash_.New();
// * @see GenericArrayObject::getObjectType
// * /**
// * @since 1.21 * @see GenericArrayObject::getObjectType
// * *
// * @return String * @since 1.21
// */ *
// public function getObjectType() { * @return String
// return 'Site'; */
// } @Override public Class<?> getObjectType() {
// return XomwSite.class;
// /** }
// * @see GenericArrayObject::preSetElement
// * /**
// * @since 1.21 * @see GenericArrayObject::preSetElement
// * *
// * @param int|String $index * @since 1.21
// * @param Site $site *
// * * @param int|String index
// * @return boolean * @param Site site
// */ *
// protected function preSetElement( $index, $site ) { * @return boolean
// if ( $this->hasSite( $site->getGlobalId() ) ) { */
// $this->removeSite( $site->getGlobalId() ); public boolean preSetElement(int index, XomwSite site) {
// } if (this.hasSite(site.getGlobalId())) {
// this.removeSite(site.getGlobalId());
// $this->byGlobalId[$site->getGlobalId()] = $index; }
// $this->byInternalId[$site->getInternalId()] = $index;
// this.byGlobalId.Add(site.getGlobalId(), index);
// $ids = $site->getNavigationIds(); this.byInternalId.Add(site.getInternalId(), index);
// foreach ( $ids as $navId ) {
// $this->byNavigationId[$navId] = $index; Ordered_hash ids = site.getNavigationIds();
// } int len = ids.Len();
// for (int i = 0; i < len; i++) {
// return true; int navId = Int_.cast(ids.Get_at(i));
// } this.byNavigationId.Add(navId, index);
// }
// /**
// * @see ArrayObject::offsetUnset() return true;
// * }
// * @since 1.21
// * /**
// * @param mixed $index * @see ArrayObject::offsetUnset()
// */ *
// public function offsetUnset( $index ) { * @since 1.21
// if ( $this->offsetExists( $index ) ) { *
// /** * @param mixed index
// * @var Site $site */
// */ public void offsetUnset(int index) {
// $site = $this->offsetGet( $index ); if (this.offsetExists(index)) {
// /**
// unset( $this->byGlobalId[$site->getGlobalId()] ); * @var Site site
// unset( $this->byInternalId[$site->getInternalId()] ); */
// XomwSite site = (XomwSite)this.offsetGet(index);
// $ids = $site->getNavigationIds();
// foreach ( $ids as $navId ) { XophpArray.unset(this.byGlobalId, site.getGlobalId());
// unset( $this->byNavigationId[$navId] ); XophpArray.unset(this.byInternalId, site.getInternalId());
// }
// } Ordered_hash ids = site.getNavigationIds();
// int len = ids.Len();
// parent::offsetUnset( $index ); for (int i = 0; i < len; i++) {
// } int navId = Int_.cast(ids.Get_at(i));
// XophpArray.unset(this.byNavigationId, navId);
// /** }
// * Returns all the global site identifiers. }
// * Optionally only those belonging to the specified group.
// * super.offsetUnset(index);
// * @since 1.21 }
// *
// * @return array /**
// */ * Returns all the global site identifiers.
// public function getGlobalIdentifiers() { * Optionally only those belonging to the specified group.
// return array_keys( $this->byGlobalId ); *
// } * @since 1.21
// *
// /** * @return array
// * Returns if the list contains the site with the provided global site identifier. */
// * public String[] getGlobalIdentifiers() {
// * @param String $globalSiteId return XophpArray.array_keys_str(this.byGlobalId);
// * }
// * @return boolean
// */ /**
// public function hasSite( $globalSiteId ) { * Returns if the list contains the site with the provided global site identifier.
// return array_key_exists( $globalSiteId, $this->byGlobalId ); *
// } * @param String globalSiteId
// *
// /** * @return boolean
// * Returns the Site with the provided global site identifier. */
// * The site needs to exist, so if not sure, call hasGlobalId first. public boolean hasSite(String globalSiteId) {
// * return XophpArray.array_key_exists(globalSiteId, this.byGlobalId);
// * @since 1.21 }
// *
// * @param String $globalSiteId /**
// * * Returns the Site with the provided global site identifier.
// * @return Site * The site needs to exist, so if not sure, call hasGlobalId first.
// */ *
// public function getSite( $globalSiteId ) { * @since 1.21
// return $this->offsetGet( $this->byGlobalId[$globalSiteId] ); *
// } * @param String globalSiteId
// *
// /** * @return Site
// * Removes the site with the specified global site identifier. */
// * The site needs to exist, so if not sure, call hasGlobalId first. public XomwSite getSite(String globalSiteId) {
// * return (XomwSite)this.offsetGet(this.byGlobalId.Get_by(globalSiteId));
// * @since 1.21 }
// *
// * @param String $globalSiteId /**
// */ * Removes the site with the specified global site identifier.
// public function removeSite( $globalSiteId ) { * The site needs to exist, so if not sure, call hasGlobalId first.
// $this->offsetUnset( $this->byGlobalId[$globalSiteId] ); *
// } * @since 1.21
// *
// /** * @param String globalSiteId
// * Returns if the list contains no sites. */
// * public void removeSite(String globalSiteId) {
// * @since 1.21 this.offsetUnset(this.byGlobalId.Get_by(globalSiteId));
// * }
// * @return boolean
// */ /**
// public function isEmpty() { * Returns if the list contains no sites.
// return $this->byGlobalId === []; *
// } * @since 1.21
// *
// /** * @return boolean
// * Returns if the list contains the site with the provided site id. */
// * @Override public boolean isEmpty() {
// * @param int $id return XophpArray.array_is_empty(this.byGlobalId);
// * }
// * @return boolean
// */ /**
// public function hasInternalId( $id ) { * Returns if the list contains the site with the provided site id.
// return array_key_exists( $id, $this->byInternalId ); *
// } * @param int id
// *
// /** * @return boolean
// * Returns the Site with the provided site id. */
// * The site needs to exist, so if not sure, call has first. public boolean hasInternalId(int id) {
// * return XophpArray.array_key_exists(id, this.byInternalId);
// * @since 1.21 }
// *
// * @param int $id /**
// * * Returns the Site with the provided site id.
// * @return Site * The site needs to exist, so if not sure, call has first.
// */ *
// public function getSiteByInternalId( $id ) { * @since 1.21
// return $this->offsetGet( $this->byInternalId[$id] ); *
// } * @param int id
// *
// /** * @return Site
// * Removes the site with the specified site id. */
// * The site needs to exist, so if not sure, call has first. public XomwSite getSiteByInternalId(int id) {
// * return (XomwSite)this.offsetGet(this.byInternalId.Get_by(id));
// * @since 1.21 }
// *
// * @param int $id /**
// */ * Removes the site with the specified site id.
// public function removeSiteByInternalId( $id ) { * The site needs to exist, so if not sure, call has first.
// $this->offsetUnset( $this->byInternalId[$id] ); *
// } * @since 1.21
// *
// /** * @param int id
// * Returns if the list contains the site with the provided navigational site id. */
// * public void removeSiteByInternalId(int id) {
// * @param String $id this.offsetUnset(this.byInternalId.Get_by(id));
// * }
// * @return boolean
// */ /**
// public function hasNavigationId( $id ) { * Returns if the list contains the site with the provided navigational site id.
// return array_key_exists( $id, $this->byNavigationId ); *
// } * @param String id
// *
// /** * @return boolean
// * Returns the Site with the provided navigational site id. */
// * The site needs to exist, so if not sure, call has first. public boolean hasNavigationId(String id) {
// * return XophpArray.array_key_exists(id, this.byNavigationId);
// * @since 1.23 }
// *
// * @param String $id /**
// * * Returns the Site with the provided navigational site id.
// * @return Site * The site needs to exist, so if not sure, call has first.
// */ *
// public function getSiteByNavigationId( $id ) { * @since 1.23
// return $this->offsetGet( $this->byNavigationId[$id] ); *
// } * @param String id
// *
// /** * @return Site
// * Removes the site with the specified navigational site id. */
// * The site needs to exist, so if not sure, call has first. public XomwSite getSiteByNavigationId(String id) {
// * return (XomwSite)this.offsetGet(this.byNavigationId.Get_by(id));
// * @since 1.23 }
// *
// * @param String $id /**
// */ * Removes the site with the specified navigational site id.
// public function removeSiteByNavigationId( $id ) { * The site needs to exist, so if not sure, call has first.
// $this->offsetUnset( $this->byNavigationId[$id] ); *
// } * @since 1.23
// *
// /** * @param String id
// * Sets a site in the list. If the site was not there, */
// * it will be added. If it was, it will be updated. public void removeSiteByNavigationId(String id) {
// * this.offsetUnset(this.byNavigationId.Get_by(id));
// * @since 1.21 }
// *
// * @param Site $site /**
// */ * Sets a site in the list. If the site was not there,
// public function setSite( Site $site ) { * it will be added. If it was, it will be updated.
// $this[] = $site; *
// } * @since 1.21
// *
// /** * @param Site site
// * Returns the sites that are in the provided group. */
// * public void setSite(XomwSite site) {
// * @since 1.21 this.Add_or_update(site);
// * }
// * @param String $groupName
// * /**
// * @return SiteList * Returns the sites that are in the provided group.
// */ *
// public function getGroup( $groupName ) { * @since 1.21
// $group = new self(); *
// * @param String groupName
// /** *
// * @var Site $site * @return SiteList
// */ */
// foreach ( $this as $site ) { public XomwSiteList getGroup(String groupName) {
// if ( $site->getGroup() === $groupName ) { XomwSiteList group = new XomwSiteList();
// $group[] = $site;
// } /**
// } * @var Site site
// */
// return $group; int len = this.count();
// } for (int i = 0; i < len; i++) {
// XomwSite site = (XomwSite)this.Get_at(i);
// /** if (String_.Eq(site.getGroup(), groupName)) {
// * A version ID that identifies the serialization structure used by getSerializationData() group.Add_or_update(site);
// * and unserialize(). This is useful for constructing cache keys in cases where the cache relies }
// * on serialization for storing the SiteList. }
// *
// * @var String A String uniquely identifying the version of the serialization structure, return group;
// * not including any sub-structures. }
// */
// static final SERIAL_VERSION_ID = '2014-03-17'; // /**
// // * A version ID that identifies the serialization structure used by getSerializationData()
// /** // * and unserialize(). This is useful for constructing cache keys in cases where the cache relies
// * Returns the version ID that identifies the serialization structure used by // * on serialization for storing the SiteList.
// * getSerializationData() and unserialize(), including the structure of any nested structures. // *
// * This is useful for constructing cache keys in cases where the cache relies // * @var String A String uniquely identifying the version of the serialization structure,
// * on serialization for storing the SiteList. // * not including any sub-structures.
// * // */
// * @return String A String uniquely identifying the version of the serialization structure, // static final SERIAL_VERSION_ID = '2014-03-17';
// * including any sub-structures. //
// */ // /**
// public static function getSerialVersionId() { // * Returns the version ID that identifies the serialization structure used by
// return self::SERIAL_VERSION_ID . '+Site:' . Site::SERIAL_VERSION_ID; // * getSerializationData() and unserialize(), including the structure of any nested structures.
// } // * This is useful for constructing cache keys in cases where the cache relies
// // * on serialization for storing the SiteList.
// /** // *
// * @see GenericArrayObject::getSerializationData // * @return String A String uniquely identifying the version of the serialization structure,
// * // * including any sub-structures.
// * @since 1.21 // */
// * // public static function getSerialVersionId() {
// * @return array // return self::SERIAL_VERSION_ID . '+Site:' . Site::SERIAL_VERSION_ID;
// */ // }
// protected function getSerializationData() { //
// // NOTE: When changing the structure, either implement unserialize() to handle the // /**
// // old structure too, or update SERIAL_VERSION_ID to kill any caches. // * @see GenericArrayObject::getSerializationData
// return array_merge( // *
// parent::getSerializationData(), // * @since 1.21
// [ // *
// 'internalIds' => $this->byInternalId, // * @return array
// 'globalIds' => $this->byGlobalId, // */
// 'navigationIds' => $this->byNavigationId // protected function getSerializationData() {
// ] // // NOTE: When changing the structure, either implement unserialize() to handle the
// ); // // old structure too, or update SERIAL_VERSION_ID to kill any caches.
// } // return array_merge(
// // super.getSerializationData(),
// /** // [
// * @see GenericArrayObject::unserialize // 'internalIds' => this.byInternalId,
// * // 'globalIds' => this.byGlobalId,
// * @since 1.21 // 'navigationIds' => this.byNavigationId
// * // ]
// * @param String $serialization // );
// * // }
// * @return array //
// */ // /**
// public function unserialize( $serialization ) { // * @see GenericArrayObject::unserialize
// $serializationData = parent::unserialize( $serialization ); // *
// // * @since 1.21
// $this->byInternalId = $serializationData['internalIds']; // *
// $this->byGlobalId = $serializationData['globalIds']; // * @param String serialization
// $this->byNavigationId = $serializationData['navigationIds']; // *
// // * @return array
// return $serializationData; // */
// } // public function unserialize(serialization) {
// serializationData = super.unserialize(serialization);
//
// this.byInternalId = serializationData['internalIds'];
// this.byGlobalId = serializationData['globalIds'];
// this.byNavigationId = serializationData['navigationIds'];
//
// return serializationData;
// }
} }