castor简介(castor简介)
What is 1. Castor?
Castor is an open source software that automatically binds Java objects to XML. It can be bound between Java objects, XML text, SQL data tables, and LDAP directories
Castor XML is an XML databinding framework. Unlike the two main XML APIs DOM (Document Object Model) and SAX (Simple API for XML which with the structure) deal of an XML document, Castor enables one to deal with the data defined in an XML document through an object model which represents that data.
Castor can convert Java objects to XML documents, freeing users plex XML parsing, and focusing more on data rather than documents.
Castor web site: /
2 Castor usage
The Java object refers to a setX and getX method JavaBean,
Castor JavaBean for the use of specific methods are as follows
Usage: default default usage refers to no use mapping format description file when usage
Standard usage: Standard usage refers to the use of the mapping file format description.
In fact, Castor not only can be used for the JavaBean class. It can also be accessed with a public member variable simple data object class data. For example, slightly modifying the aforementioned Test class, you can use the following definition of flight data, and eventually get the same XML format:
Public class FlightData {public String carrier; public int number; public String departure; public String arrival;}
In order to make the Castor work, a class must all adopt this way or that way. If the class defines any getX or setX method, Castor treats it as bean, and only uses these methods in marshalling and reconciliation groups
3 the format of XML under default usage
< XML version= encoding=UTF-8? >
<arrival-time>8:42a</arrival-time>
<departure-time>6:23</departure-time>
<carrier>AR</carrier>
In other words
An attribute that creates elements for attributes with basic type values (in this case, only the number attribute is declared as int by the getNumber () method. For each attribute with an
castor简介(castor简介) 来自淘豆网www.taodocs.com转载请标明出处.