模型本质上是树形结构的数据,我们推荐使用程序来管理模型,所以相对来说并不需要太关心模型代码的格式。下面是模型常用的几种格式。
XML格式的模型代码是为了方便手工修改模型代码的。如下面的模型代码。
<?xml version="1.0" encoding="utf-8"?>
<Shell name="HelloWorld" descriptors="xworker.swt.widgets.Shell"
text="Hello World" RESIZE="true"
width="800" height="600" design="">
<FillLayout name="FillLayout"></FillLayout>
<Browser name="Browser" url="http://www.xworker.org" WEBKIT="true">
</Browser>
</Shell>
也可以使用JSON格式来保存模型。如下面的模型代码。
{
"thing":{
"name": "Person",
"actions":{
"JavaAction":{
"name": "eat",
"useOuterJava": true,
"outerClassName": "org.xmeta.json.Person",
"methodName":"run"
}
},
"thing":{
"name": "Child",
"extends":"org.xmeta.json.Person"
},
"attribute":{
"name":"name"
},
"attribute":{
"name":"age"
}
}
}
Properties格式是模型编辑工具的常用的格式,上面两种格式可读性更好,而Properties格式支持的功能最全。如下面的模型代码。
^1504835115722 @ sname HelloWorld stext Hello World swidth 800 sheight 600 scenterScreen true spack false smaximized false sfullScreen false sH_SCROLL false sV_SCROLL false sNO_BACKGROUND false sNO_MERGE_PAINTS false sNO_REDRAW_RESIZE false sNO_RADIO_GROUP false sEMBEDDED false sDOUBLE_BUFFERED false slabel HelloWorld scapture false senabled true sredraw true svisible true sdescriptors xworker.swt.widgets.Shell sth_createIndex false sth_registMyChilds false sth_mark false @/@FillLayout sname FillLayout stype SWT.HORIZONTAL sdescriptors xworker.swt.Layouts/@FillLayout sth_createIndex false sth_registMyChilds false sth_mark false sid FillLayout @/@Browser sname Browser surl http://www.xworker.org sMOZILLA false sWEBKIT true sjavascriptEnabled true sdescriptors xworker.swt.Widgets/@Browser sth_createIndex false sth_registMyChilds false sth_mark false sid Browser