Package | org.samchon.protocol.entity |
Class | public class EntityArray |
Inheritance | EntityArray ![]() |
Implements | IEntity, IDictionary |
Subclasses | FTFolder, Invoke, NTCriteria, NTParameter, NTParameterArray, NTSideParameterArray |
An Entity and an Array of children Entity objects.
EntityArray is a template class for containinig children Entity objects, and also another type of an Entity, too. You can realize hierarchical relationship. Although some entities have complicated hierarchical relationship, you can deduct a optimal solution easily with EntityArray and Entity.
If an entity has some subordinate entities of same type, they are in "Composite relationship". Make the entity to be EmntityGroup and subordinate entities to be children of the entity. When those relationships are continued, continue to create classes dervied from EntityArray. When those relationshiop meets a terminal node, then make the terminal node to be an Entity.
EntityArray is an Entity, and a container of children Entity objects at the same time. If children type, of a class derived from an EntityArray, is itself, you can realize hierarchical and recursive relationship. The relationship is called as "Composite pattern".
Default MXML Propertysource
See also
Property | Defined By | ||
---|---|---|---|
CHILD_TAG : String [read-only]
A tag name of children in composite relationship
Needed for
virtual EntityArray::construct(XML)
virtual EntityArray::toXML() -> XML
<TAG>
<CHILD_TAG />
<CHILD_TAG />
</TAG>
| EntityArray | ||
key : * [read-only] | EntityArray | ||
TAG : String [read-only] | EntityArray |
Method | Defined By | ||
---|---|---|---|
Default Constructor. | EntityArray | ||
construct(xml:XML):void
Construct data of the Entity from an XML object. | EntityArray | ||
createChild(xml:XML):IEntity
Factory method of a child Entity. | EntityArray | ||
erase(key:*):Boolean | EntityArray | ||
has(key:*):Boolean | EntityArray | ||
toXML():XML
Get an XML object represents the EntityArray. | EntityArray |
Method | Defined By | ||
---|---|---|---|
Access the element(Entity) by specified index. | EntityArray | ||
Access the element(Entity) by specified identifier(key). | EntityArray |
CHILD_TAG | property |
CHILD_TAG:String
[read-only] A tag name of children in composite relationship Needed for virtual EntityArray::construct(XML) virtual EntityArray::toXML() -> XML <TAG> <CHILD_TAG /> <CHILD_TAG /> </TAG>
public function get CHILD_TAG():String
key | property |
key:*
[read-only] public function get key():*
TAG | property |
TAG:String
[read-only] public function get TAG():String
EntityArray | () | Constructor |
public function EntityArray()
Default Constructor.
_at | () | method |
protected function _at(index:int):IEntity
Access the element(Entity
) by specified index.
Parameters
index:int — The index in the list from which to retrieve the item.
|
IEntity — The item(Entity) at that index. or null if there is none.
|
_get | () | method |
protected function _get(key:*):IEntity
Access the element(Entity
) by specified identifier(key).
Parameters
key:* — the identifier of the Entity wants to access
|
IEntity — The Entity having the key, or null if there is none.
|
construct | () | method |
public function construct(xml:XML):void
Construct data of the Entity from an XML object.
Constructs the EntityArray's own member variables only from the input XML object.
Do not consider about constructing children Entity objects' data in EntityArray::construct(). Those children Entity objects' data will constructed by their own construct() method. Even insertion of XML objects representing children are done by abstract method of EntityArray::toXML().
Constructs only data of EntityArray's own.
Construct data of the Entity from a XML object.
Overrides the construct() method and fetch data of member variables from the XML.
By recommended guidance, data representing member variables are contained in properties of the put XML object.
Parameters
xml:XML — An xml used to contruct data of entity.
|
createChild | () | method |
public function createChild(xml:XML):IEntity
Factory method of a child Entity.
EntityArray::createChild() is a factory method creating a new child Entity which is belonged to the EntityArray. This method is called by EntityArray::construct(). The children construction methods Entity::construct() will be called by abstract method of the EntityArray::construct().
Parameters
xml:XML |
IEntity — A new child Entity belongs to EntityArray.
|
erase | () | method |
public function erase(key:*):Boolean
Parameters
key:* |
Boolean |
has | () | method |
public function has(key:*):Boolean
Parameters
key:* |
Boolean |
toXML | () | method |
public function toXML():XML
Get an XML object represents the EntityArray.
Archives the EntityArray's own member variables only to the returned XML object.
Do not consider about archiving children Entity objects' data in EntityArray::toXML(). Those children Entity objects will converted to XML object by their own toXML() method. The insertion of XML objects representing children are done by abstract method of EntityArray::toXML().
Archives only data of EntityArray's own.
Get a XML object represents the Entity.
A member variable (not object, but atomic value like number, string or date) is categorized as a property within the framework of entity side. Thus, when overriding a toXML() method and archiving member variables to an XML object to return, puts each variable to be a property belongs to only a XML object.
Don't archive the member variable of atomic value to XML::value causing enormouse creation of XML objects to number of member variables. An Entity must be represented by only a XML instance (tag).
Standard Usage | Non-standard usage abusing value |
---|---|
<memberList> <member id='jhnam88' name='Jeongho+Nam' birthdate='1988-03-11' /> <member id='master' name='Administartor' birthdate='2011-07-28' /> </memberList\> |
<member> <id>jhnam88</id> <name>Jeongho+Nam<name> <birthdate>1988-03-11</birthdate> </member> |
XML — An XML object representing the Entity.
|