[转]SModel- 提供 XML , JSON , POJO 等结构化数据统一编程模型

SModel provides users a uniform way to access and manipulate structured model in the format of XML, JSON, POJO or other user defined data format from data source such as stream, database or others.

Base on SModel, Document Oriented Service(DOS) framework can employee a uniform set of APIs to read and manipulate different format of document.

Features
1) provides a uniform way to access and manipulate structure model, including: add, remove, query, move, update, and introspect data. SModel also provides mechanism to subscribe for the change event of the model manipulation.
2)supports to load model from XML, JSON, POJO, or user defined format.
3)supports to flush model to XML, JSON, POJO or user defined format.
4)supports to validate model according to SModel defined or user defined rule.
5)provides mechanism to extend the function of the model.
6)provides mechanism to subscribe for error or warning message of the SModel.

Two Minutes Reference
1)create a xml document
sample xml:

<?xml version="1.0" encoding="UTF-8"?>
<order id="order id 1" name="order name 1">
<orderDate>2009-09-06 20:36:01.196</orderDate>
<items>
<item count="100" id="item id 1" name="item name 1" price="10.3" />
</items>
</order>



IXmlModel orderModel = new XmlModel("order");
orderModel.setProperty("id", "order id 1");
orderModel.setProperty("name", "order name 1");
orderModel.setChildText("orderDate", Utils.buildTimestamp(new Timestamp(new Date().getTime())));

IXmlModel items = (IXmlModel) orderModel.addChild("items");
IXmlModel item = (IXmlModel) items.addChild("item");
item.setProperty("id", "item id 1");
item.setProperty("name", "item name 1");
item.setProperty("price", 10.3);
item.setProperty("count", 100);

XmlModelService.flushToXml(orderModel, "d:/order.xml");

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值