Apache sdo学习笔记(四)——通过动态类型创建DataObject
来源:互联网 发布:詹姆斯打球特点 知乎 编辑:程序博客网 时间:2024/05/01 20:44
1:java代码
package com.waysoft.intergration.dao;import org.apache.tuscany.sdo.api.SDOUtil;import commonj.sdo.DataObject;import commonj.sdo.Type;import commonj.sdo.helper.HelperContext;import commonj.sdo.helper.TypeHelper;public class Test3 {/** * @param args */public static void main(String[] args) {HelperContext scope = SDOUtil.createHelperContext();scope.getTypeHelper().define(getCustomerType());DataObject customer = scope.getDataFactory().create("http://example.com/customer", "Customer");customer.setInt("custNum", 123);customer.setString("firstName", "范德萨");customer.setString("lastName", "太热");// --DataObjecttry {scope.getXMLHelper().save(customer, "http://example.com/customer","customer", System.out);System.out.println();} catch (Exception e) {e.printStackTrace();}}protected static DataObject getCustomerType() {HelperContext scope = SDOUtil.createHelperContext();TypeHelper typeHelper = scope.getTypeHelper();Type intType = typeHelper.getType("commonj.sdo", "Int");Type stringType = typeHelper.getType("commonj.sdo", "String");DataObject customerType = scope.getDataFactory().create("commonj.sdo","Type");customerType.set("uri", "http://example.com/customer");customerType.set("name", "Customer");DataObject custNumType = customerType.createDataObject("property");custNumType.set("name", "custNum");custNumType.set("type", intType);DataObject firstNameType = customerType.createDataObject("property");firstNameType.set("name", "firstName");firstNameType.set("type", stringType);DataObject lastNameType = customerType.createDataObject("property");lastNameType.set("name", "lastName");lastNameType.set("type", stringType);return customerType;}}
2:运行结果
<?xml version="1.0" encoding="UTF-8"?><customer:customer xmlns:customer="http://example.com/customer"> <custNum>123</custNum> <firstName>范德萨</firstName> <lastName>太热</lastName></customer:customer>
- Apache sdo学习笔记(四)——通过动态类型创建DataObject
- Apache SDO学习笔记(一)——通过xml字符串创建DataObject对象
- Apache sdo学习笔记(二)——通过Shema创建DataObject对象
- Apache sdo学习笔记(三)——通过DataGraph创建DataObject对象
- Apache sdo学习笔记(五)——变更摘要
- Apache sdo学习笔记(六)——数据访问服务(DAS)访问关系数据库
- 创建自定义的DataObject类型
- Python学习笔记(四):动态类型
- MFC学习笔记四——动态创建 Dynamic Creation
- JavaScript基础学习笔记(四)——Object类型
- Apache学习笔记(四)Apache日志文件
- Python学习笔记之四——类型
- C#学习笔记(四):结构类型
- 深入浅出MFC学习笔记:(第三章MFC六大关键技术之仿真:类型识别,动态创建) .
- 深入浅出MFC学习笔记:(第三章MFC六大关键技术之仿真:类型识别,动态创建)
- 深入浅出MFC学习笔记:(第三章MFC六大关键技术之仿真:类型识别,动态创建) .
- 6.笔记 MySQL学习——通过脚本创建表
- Qt之GUI学习笔记(四)——创建对话框
- Loadrunner调用的DLL中的函数有类的实例时解决方法
- C/C++中const、mutable、volatile详解
- Exporting .kyr certificate for Apache[转]
- OpenCV参考手册之Mat类详解
- cmd窗口一闪而过
- Apache sdo学习笔记(四)——通过动态类型创建DataObject
- PHP CodeBase: 将时间显示为“刚刚”“n分钟/小时前”等
- 50个Web设计师超便利的工具
- 验证码生成
- linux 使用 c.vim
- Android实时滤镜
- 移动信息化在路上:机遇与挑战
- FP-Tree算法的实现
- 常见的敏捷开发流程比较