This is an automated email from the ASF dual-hosted git repository. harbs pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push: new fbd30083e7 white space fbd30083e7 is described below commit fbd30083e78874d8105888d40b632cf36d5a3d4e Author: Harbs <ha...@in-tools.com> AuthorDate: Wed Dec 20 20:24:44 2023 +0200 white space --- .../apache/royale/collections/HierarchicalData.as | 472 ++++++++++----------- 1 file changed, 230 insertions(+), 242 deletions(-) diff --git a/frameworks/projects/Collections/src/main/royale/org/apache/royale/collections/HierarchicalData.as b/frameworks/projects/Collections/src/main/royale/org/apache/royale/collections/HierarchicalData.as index e847c3eec4..dce94df2b1 100644 --- a/frameworks/projects/Collections/src/main/royale/org/apache/royale/collections/HierarchicalData.as +++ b/frameworks/projects/Collections/src/main/royale/org/apache/royale/collections/HierarchicalData.as @@ -20,272 +20,260 @@ package org.apache.royale.collections { -import org.apache.royale.events.Event; -import org.apache.royale.events.EventDispatcher; + import org.apache.royale.events.Event; + import org.apache.royale.events.EventDispatcher; -/** - * Hierarchical data is data already in a structure of parent and child data items. - * The HierarchicalData class provides a default implementation for - * accessing and manipulating data. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion Royale 0.0 - */ -public class HierarchicalData extends EventDispatcher implements IHierarchicalData -{ - //-------------------------------------------------------------------------- - // - // Constructor - // - //-------------------------------------------------------------------------- - - /** - * Constructor. - * - * @param value The data used to populate the HierarchicalData instance. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion Royale 0.0 - */ - public function HierarchicalData(value:Object = null) - { - super(); - - source = value; - } - - //-------------------------------------------------------------------------- - // - // Properties - // - //-------------------------------------------------------------------------- - - private var _flatList:FlattenedList; + /** + * Hierarchical data is data already in a structure of parent and child data items. + * The HierarchicalData class provides a default implementation for + * accessing and manipulating data. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.0 + */ + public class HierarchicalData extends EventDispatcher implements IHierarchicalData + { + /** + * Constructor. + * + * @param value The data used to populate the HierarchicalData instance. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.0 + */ + public function HierarchicalData(value:Object = null) + { + super(); + source = value; + } - //-------------------------------------------------------------------------- - // childrenField - //-------------------------------------------------------------------------- + //-------------------------------------------------------------------------- + // + // Properties + // + //-------------------------------------------------------------------------- + + private var _flatList:FlattenedList; - /** - * @private - * The field name to be used to detect children field. - */ - private var _childrenField:String = "children"; + //-------------------------------------------------------------------------- + // childrenField + //-------------------------------------------------------------------------- - /** - * Indicates the field name to be used to detect children objects in - * a data item. - * By default, all subnodes are considered as children for - * XML data, and the <code>children</code> property is used for the Object data type. - * - * This is helpful in adapting to a data format that uses custom data fields - * to represent children. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion Royale 0.0 - */ - public function get childrenField():String - { - return _childrenField; - } + /** + * @private + * The field name to be used to detect children field. + */ + private var _childrenField:String = "children"; - /** - * @private - */ - public function set childrenField(value:String):void - { - _childrenField = value; - } + /** + * Indicates the field name to be used to detect children objects in + * a data item. + * By default, all subnodes are considered as children for + * XML data, and the <code>children</code> property is used for the Object data type. + * + * This is helpful in adapting to a data format that uses custom data fields + * to represent children. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.0 + */ + public function get childrenField():String + { + return _childrenField; + } - //-------------------------------------------------------------------------- - // source - //-------------------------------------------------------------------------- + /** + * @private + */ + public function set childrenField(value:String):void + { + _childrenField = value; + } - /** - * @private - * The source collection. - */ - private var _source:Object; + /** + * @private + * The source collection. + */ + private var _source:Object; - /** - * The source collection. - * The collection should implement the IList interface - * to facilitate operation like the addition and removal of items. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion Royale 0.0 - */ - public function get source():Object - { - return _source; - } + /** + * The source collection. + * The collection should implement the IList interface + * to facilitate operation like the addition and removal of items. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.0 + */ + public function get source():Object + { + return _source; + } - /** - * @private - */ - public function set source(value:Object):void - { - _source = value; + /** + * @private + */ + public function set source(value:Object):void + { + _source = value; + dispatchEvent(new Event("collectionChanged")); + } - dispatchEvent(new Event("collectionChanged")); - } + //-------------------------------------------------------------------------- + // + // Methods + // + //-------------------------------------------------------------------------- - //-------------------------------------------------------------------------- - // - // Methods - // - //-------------------------------------------------------------------------- + /** + * @inheritDoc + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.0 + */ + public function canHaveChildren(node:Object):Boolean + { + if (node == null) + return false; - /** - * @inheritDoc - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion Royale 0.0 - */ - public function canHaveChildren(node:Object):Boolean - { - if (node == null) - return false; + var branch:Boolean = false; - var branch:Boolean = false; + if (node is Object) + { + try + { + if (node[childrenField] != undefined) + { + branch = true; + } + } + catch (e:Error) + { + } + } + return branch; + } - if (node is Object) - { - try - { - if (node[childrenField] != undefined) - { - branch = true; - } - } - catch (e:Error) - { - } - } - return branch; - } + /** + * @inheritDoc + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.0 + */ + public function getChildren(node:Object):Object + { + if (node == null) + return null; - /** - * @inheritDoc - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion Royale 0.0 - */ - public function getChildren(node:Object):Object - { - if (node == null) - return null; + var children:*; - var children:*; + //first get the children based on the type of node. + if (node is Object) + { + //we'll try the default children property + try + { + children = node[childrenField]; + } + catch (e:Error) + { + } + } - //first get the children based on the type of node. - if (node is Object) - { - //we'll try the default children property - try - { - children = node[childrenField]; - } - catch (e:Error) - { - } - } + //no children exist for this node + if(children === undefined) + return null; - //no children exist for this node - if(children === undefined) - return null; + return children; + } - return children; - } + /** + * @inheritDoc + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.0 + */ + public function hasChildren(node:Object):Boolean + { + if (node == null) + return false; - /** - * @inheritDoc - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion Royale 0.0 - */ - public function hasChildren(node:Object):Boolean - { - if (node == null) - return false; + //This default impl can't optimize this call to getChildren + //since we can't make any assumptions by type. Custom impl's + //can probably avoid this call and reduce the number of calls to + //getChildren if need be. + var children:Object = getChildren(node); + try + { + if (children.length > 0) + return true; + } + catch (e:Error) + { + } + return false; + } - //This default impl can't optimize this call to getChildren - //since we can't make any assumptions by type. Custom impl's - //can probably avoid this call and reduce the number of calls to - //getChildren if need be. - var children:Object = getChildren(node); - try - { - if (children.length > 0) - return true; - } - catch (e:Error) - { - } - return false; - } + /** + * @inheritDoc + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.0 + */ + public function getData(node:Object):Object + { + return Object(node); + } - /** - * @inheritDoc - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion Royale 0.0 - */ - public function getData(node:Object):Object - { - return Object(node); - } + /** + * @inheritDoc + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.0 + */ + public function getRoot():Object + { + return source; + } + + public function isOpen(node:Object):Boolean + { + return _flatList.isOpen(node); + } + + public function openNode(node:Object):void + { + _flatList.openNode(node); + } + + public function closeNode(node:Object):void + { + _flatList.closeNode(node); + } + + public function getDepth(node:Object):int + { + return _flatList.getDepth(node); + } - /** - * @inheritDoc - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion Royale 0.0 - */ - public function getRoot():Object - { - return source; - } - - public function isOpen(node:Object):Boolean - { - return _flatList.isOpen(node); - } - - public function openNode(node:Object):void - { - _flatList.openNode(node); - } - - public function closeNode(node:Object):void - { - _flatList.closeNode(node); } - - public function getDepth(node:Object):int - { - return _flatList.getDepth(node); - } - -} }