xmltype.html

来自「j2ee帮助文档软件设计/软件工程 文件格式」· HTML 代码 · 共 693 行 · 第 1/2 页

HTML
693
字号
           &lt;xs:element name="state" type="xs:string"/>           &lt;xs:element name="zip" type="xs:decimal"/>         &lt;/xs:complexType>       ...     &lt;/xs:sequence>   &lt;/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;         &#64;XmlAttribute          public USPrice price;     }         // map class to anonymous simple type.      &#64;XmlType(name="")     public class USPrice {          &#64;XmlValue         public java.math.BigDecimal price;     }     &lt;!-- Example: XML Schema fragment -->     &lt;xs:complexType name="Item">       &lt;xs:sequence>         &lt;xs:element name="name" type="xs:string"/>         &lt;xs:attribute name="price">           &lt;xs:simpleType>             &lt;xs:restriction base="xs:decimal"/>           &lt;/xs:simpleType>         &lt;/xs:attribute>       &lt;/xs:sequence>     &lt;/xs:complexType> </pre>  <p> <b> Example 6: </b> Define a factoryClass and factoryMethod <pre>       &#64;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>      &#64;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>&nbsp;<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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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>&nbsp;<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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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>&nbsp;<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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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>&nbsp;<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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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>&nbsp;<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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Specifies the order for XML Schema elements when class is mapped to a XML Schema complex type.</TD></TR></TABLE>&nbsp;<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>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../../../javax/xml/bind/annotation/XmlTransient.html" title="annotation in javax.xml.bind.annotation"><B>PREV CLASS</B></A>&nbsp;&nbsp;<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>  &nbsp;&nbsp;<A HREF="XmlType.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;&nbsp;<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:&nbsp;REQUIRED&nbsp;|&nbsp;<A HREF="#annotation_type_optional_element_summary">OPTIONAL</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL:&nbsp;<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 + -
显示快捷键?