xmltype.html
来自「j2ee帮助文档软件设计/软件工程 文件格式」· HTML 代码 · 共 693 行 · 第 1/2 页
HTML
693 行
<xs:element name="state" type="xs:string"/> <xs:element name="zip" type="xs:decimal"/> </xs:complexType> ... </xs:sequence> </xs:complexType> </pre> <p> <b> Example 5: </b> Map a property to an attribute with anonymous type. <pre> //Example: Code fragment public class Item { public String name; @XmlAttribute public USPrice price; } // map class to anonymous simple type. @XmlType(name="") public class USPrice { @XmlValue public java.math.BigDecimal price; } <!-- Example: XML Schema fragment --> <xs:complexType name="Item"> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:attribute name="price"> <xs:simpleType> <xs:restriction base="xs:decimal"/> </xs:simpleType> </xs:attribute> </xs:sequence> </xs:complexType> </pre> <p> <b> Example 6: </b> Define a factoryClass and factoryMethod <pre> @XmlType(name="USAddressType", factoryClass=USAddressFactory.class, factoryMethod="getUSAddress") public class USAddress { private String city; private String name; private String state; private String street; private int zip; public USAddress(String name, String street, String city, String state, int zip) { this.name = name; this.street = street; this.city = city; this.state = state; this.zip = zip; } } public class USAddressFactory { public static USAddress getUSAddress(){ return new USAddress("Mark Baker", "23 Elm St", "Dayton", "OH", 90952); } </pre> <p> <b> Example 7: </b> Define factoryMethod and use the default factoryClass <pre> @XmlType(name="USAddressType", factoryMethod="getNewInstance") public class USAddress { private String city; private String name; private String state; private String street; private int zip; private USAddress() {} public static USAddress getNewInstance(){ return new USAddress(); } } </pre><P><P><DL><DT><B>Since:</B></DT> <DD>JAXB2.0</DD><DT><B>Version:</B></DT> <DD>$Revision: 1.20 $</DD><DT><B>Author:</B></DT> <DD>Sekhar Vajjhala, Sun Microsystems, Inc.</DD><DT><B>See Also:</B><DD><A HREF="../../../../javax/xml/bind/annotation/XmlElement.html" title="annotation in javax.xml.bind.annotation"><CODE>XmlElement</CODE></A>, <A HREF="../../../../javax/xml/bind/annotation/XmlAttribute.html" title="annotation in javax.xml.bind.annotation"><CODE>XmlAttribute</CODE></A>, <A HREF="../../../../javax/xml/bind/annotation/XmlValue.html" title="annotation in javax.xml.bind.annotation"><CODE>XmlValue</CODE></A>, <A HREF="../../../../javax/xml/bind/annotation/XmlSchema.html" title="annotation in javax.xml.bind.annotation"><CODE>XmlSchema</CODE></A></DL><HR><P><!-- =========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY =========== --><A NAME="annotation_type_optional_element_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Optional Element Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/xml/bind/annotation/XmlType.html#factoryClass()">factoryClass</A></B></CODE><BR> Class containing a no-arg factory method for creating an instance of this class.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/xml/bind/annotation/XmlType.html#factoryMethod()">factoryMethod</A></B></CODE><BR> Name of a no-arg factory method in the class specified in <tt>factoryClass</tt> factoryClass().</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/xml/bind/annotation/XmlType.html#name()">name</A></B></CODE><BR> Name of the XML Schema type which the class is mapped.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/xml/bind/annotation/XmlType.html#namespace()">namespace</A></B></CODE><BR> Name of the target namespace of the XML Schema type.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>[]</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/xml/bind/annotation/XmlType.html#propOrder()">propOrder</A></B></CODE><BR> Specifies the order for XML Schema elements when class is mapped to a XML Schema complex type.</TD></TR></TABLE> <P><A NAME="name()"><!-- --></A><H3>name</H3><PRE>public abstract <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>name</B></PRE><DL><DD>Name of the XML Schema type which the class is mapped.<P><DD><DL></DL></DD><DD><DL></DL><DL><DT><B>Default:</B><DD>"##default"</DD></DL></DL><HR><A NAME="propOrder()"><!-- --></A><H3>propOrder</H3><PRE>public abstract <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>[] <B>propOrder</B></PRE><DL><DD>Specifies the order for XML Schema elements when class is mapped to a XML Schema complex type. <p> Refer to the table for how the propOrder affects the mapping of class </p> <p> The propOrder is a list of names of JavaBean properties in the class. Each name in the list is the name of a Java identifier of the JavaBean property. The order in which JavaBean properties are listed is the order of XML Schema elements to which the JavaBean properties are mapped. </p> <p> All of the JavaBean properties being mapped to XML Schema elements must be listed. <p> A JavaBean property or field listed in propOrder must not be transient or annotated with <tt>@XmlTransient</tt>. <p> The default ordering of JavaBean properties is determined by @<A HREF="../../../../javax/xml/bind/annotation/XmlAccessorOrder.html" title="annotation in javax.xml.bind.annotation"><CODE>XmlAccessorOrder</CODE></A>.<P><DD><DL></DL></DD><DD><DL></DL><DL><DT><B>Default:</B><DD>""</DD></DL></DL><HR><A NAME="namespace()"><!-- --></A><H3>namespace</H3><PRE>public abstract <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>namespace</B></PRE><DL><DD>Name of the target namespace of the XML Schema type. By default, this is the target namespace to which the package containing the class is mapped.<P><DD><DL></DL></DD><DD><DL></DL><DL><DT><B>Default:</B><DD>"##default"</DD></DL></DL><HR><A NAME="factoryClass()"><!-- --></A><H3>factoryClass</H3><PRE>public abstract <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A> <B>factoryClass</B></PRE><DL><DD>Class containing a no-arg factory method for creating an instance of this class. The default is this class. <p>If <tt>factoryClass</tt> is DEFAULT.class and <tt>factoryMethod</tt> is "", then there is no static factory method. <p>If <tt>factoryClass</tt> is DEFAULT.class and <tt>factoryMethod</tt> is not "", then <tt>factoryMethod</tt> is the name of a static factory method in this class. <p>If <tt>factoryClass</tt> is not DEFAULT.class, then <tt>factoryMethod</tt> must not be "" and must be the name of a static factory method specified in <tt>factoryClass</tt>.<P><DD><DL></DL></DD><DD><DL></DL><DL><DT><B>Default:</B><DD>javax.xml.bind.annotation.XmlType.DEFAULT.class</DD></DL></DL><HR><A NAME="factoryMethod()"><!-- --></A><H3>factoryMethod</H3><PRE>public abstract <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>factoryMethod</B></PRE><DL><DD>Name of a no-arg factory method in the class specified in <tt>factoryClass</tt> factoryClass().<P><DD><DL></DL></DD><DD><DL></DL><DL><DT><B>Default:</B><DD>""</DD></DL></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ======= START OF BOTTOM NAVBAR ====== --><A NAME="navbar_bottom"><!-- --></A><A HREF="#skip-navbar_bottom" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../javax/xml/bind/annotation/XmlTransient.html" title="annotation in javax.xml.bind.annotation"><B>PREV CLASS</B></A> <A HREF="../../../../javax/xml/bind/annotation/XmlType.DEFAULT.html" title="class in javax.xml.bind.annotation"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html?javax/xml/bind/annotation/XmlType.html" target="_top"><B>FRAMES</B></A> <A HREF="XmlType.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--></SCRIPT><NOSCRIPT> <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: REQUIRED | <A HREF="#annotation_type_optional_element_summary">OPTIONAL</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#annotation_type_element_detail">ELEMENT</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_bottom"></A><!-- ======== END OF BOTTOM NAVBAR ======= --><HR><font size="-1"><a href="http://java.sun.com/webapps/bugreport">Submit a bug or feature</a> <p>Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to <a href="../legal/license.html" target="_top">license terms.</a></font></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?