For some historical reasons, the dynamic model refers to classes as descriptors.
In a dynamic model an object can use any object as its own descriptor, inheriting the behavior of the descriptor.
A model's descriptors attribute is used to mark its descriptors.
<?xml version='1.0' encoding='utf-8'?> <Person name="ZhangSan" descriptors="Person"> <Child name="XiaoMing"/> </Person>
As in the above XML, descriptors="Person" means that it uses the model whose path is Person as its descriptor (class), so the above XML also inherits the behavior of Person.
If a model has multiple descriptors, the descriptor paths are separated by commas.
For example: descriptors="Person,Employee".
The descriptor has the ability to describe the behavior of the object because the object inherits the behavior of the descriptor, so the behavior of the descriptor is equivalent to the behavior of the object.
Descriptor's child node<attriubte name="xxx" .../>Attributes for object, Descriptor's child node<thing name="xxx" ... /> is used to describe the child nodes of the object.
<?xml version='1.0' encoding='utf-8'?> <thing name="Person" _xmeta_id_="379" descriptors="xworker.lang.MetaDescriptor3"> <attribute name="name"/> <attribute name="age" _xmeta_id_="652"/> <attribute name="sex" _xmeta_id_="653" inputtype="select"> <value name="male" _xmeta_id_="654" value="male"/> <value name="female" _xmeta_id_="655" value="female"/> </attribute> <attribute name="birthDay" _xmeta_id_="656" inputtype="datePick"/> <attribute name="memo" _xmeta_id_="657" inputtype="html"/> <actions> <GroovyAction name="sayHello" descriptors="xworker.groovy.GroovyAction" code="println self.get("name") + " say hello world!" ;"/> </actions> <thing name="Child" extends="_transient.p379"/> </thing>
When a model uses the above XML as its own descriptor, then the model should have attributes such as name, age, sex, birthDay and memo, and can add <Child .../> byte point.
For example, the following model is described by the above model.
<Person name="ZhangSan" descriptors="Person"> <Child name="XiaoMing"/> </Person>
When a model is serialized for storage, only the attributes defined by the descriptor are usually saved.
Copyright © 2007-2019 XWorker.org 版权所有 沪ICP备08000575号