Java Factory factory DBFactory new Instance factory connect
数据绑定的示例 // � 定到数据� 中的某个关系表,以便通� Java � 象� 行操作 Factory factory = DBFactory. new. Instance(". . . "); factory. connect(); List<Employee> employees = factory. unmarshal(Database. Constants. EMPLOYEE_TABLE); // Manipulate data in employee objects for (Iterator<Employee> i = employees. iterator; i. has. Next(); ) { Employee employee = i. next(); System. out. println("First name: " + employee. get. First. Name()); System. out. println("Last name: " + employee. get. Last. Name()); // 修改 Java � 象中的数据,然后再写入到数据� 表中 employee. set. First. Name(". . . "); employee. set. Last. Name(". . . "); factory. marshal(employee, Database. Constants. EMPLOYEE_TABLE); }
数据绑定的一般概念和 XML 数据绑定 n 文法(Grammar) n 解组(Unmarshalling) n 编组(Marshalling) n 往返(Round-tripping) n 语义等价(Semantic Equivalent) n 映射或转换规则(Mapping/Transformation Rules) n 数据类型绑定(Data Type Binding)
XML Schema 数据� 型 Java 数据� 型 xsd: string java. lang. String xsd: integer java. math. Big. Integer xsd: int xsd: long xsd: short xsd: decimal java. math. Big. Decimal xsd: float xsd: double xsd: boolean xsd: byte xsd: QName javax. xml. namespace. QName xsd: date. Time javax. xml. datatype. XMLGregorian. Calendar xsd: base 64 Binary byte[] xsd: hex. Binary byte[] xsd: unsigned. Int long xsd: unsigned. Short int xsd: unsigned. Byte short
XML 数据绑定 API �品 / �言 支持 Casto JA Liquid Xsd. r X Tech e B x e XML Be ans C# (. NET) X √ √ √ X Java √ √ √ X √ C++ (Win 32, Linux, Solaris) X X √ X X VB. NET (. NET) X X X √ X
9. 2. 4 对 XML 文档进行解组操作 n Test. Jaxb. java
- Slides: 11