blob: 25f07c5ff659792ed21c311eb5721ebe3e69ce62 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<title>XmlElement</title>
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="XmlElement";
}
}
catch(err) {
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../javax/xml/bind/annotation/XmlAttribute.html" title="annotation in javax.xml.bind.annotation"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../javax/xml/bind/annotation/XmlElement.DEFAULT.html" title="class in javax.xml.bind.annotation"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?javax/xml/bind/annotation/XmlElement.html" target="_top">Frames</a></li>
<li><a href="XmlElement.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Required&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.optional.element.summary">Optional</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.element.detail">Element</a></li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">javax.xml.bind.annotation</div>
<h2 title="Annotation Type XmlElement" class="title">Annotation Type XmlElement</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>@Retention(value=RUNTIME)
@Target(value={FIELD,METHOD,PARAMETER})
public @interface <span class="memberNameLabel">XmlElement</span></pre>
<div class="block">Maps a JavaBean property to a XML element derived from property name.
<p> <b>Usage</b>
<p>
<code>@XmlElement</code> annotation can be used with the following program
elements:
<ul>
<li> a JavaBean property </li>
<li> non static, non transient field </li>
<li> within <a href="../../../../javax/xml/bind/annotation/XmlElements.html" title="annotation in javax.xml.bind.annotation"><code>XmlElements</code></a>
</ul>
The usage is subject to the following constraints:
<ul>
<li> This annotation can be used with following annotations:
<a href="../../../../javax/xml/bind/annotation/XmlID.html" title="annotation in javax.xml.bind.annotation"><code>XmlID</code></a>,
<a href="../../../../javax/xml/bind/annotation/XmlIDREF.html" title="annotation in javax.xml.bind.annotation"><code>XmlIDREF</code></a>,
<a href="../../../../javax/xml/bind/annotation/XmlList.html" title="annotation in javax.xml.bind.annotation"><code>XmlList</code></a>,
<a href="../../../../javax/xml/bind/annotation/XmlSchemaType.html" title="annotation in javax.xml.bind.annotation"><code>XmlSchemaType</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/XmlAttachmentRef.html" title="annotation in javax.xml.bind.annotation"><code>XmlAttachmentRef</code></a>,
<a href="../../../../javax/xml/bind/annotation/XmlMimeType.html" title="annotation in javax.xml.bind.annotation"><code>XmlMimeType</code></a>,
<a href="../../../../javax/xml/bind/annotation/XmlInlineBinaryData.html" title="annotation in javax.xml.bind.annotation"><code>XmlInlineBinaryData</code></a>,
<a href="../../../../javax/xml/bind/annotation/XmlElementWrapper.html" title="annotation in javax.xml.bind.annotation"><code>XmlElementWrapper</code></a>,
<a href="../../../../javax/xml/bind/annotation/adapters/XmlJavaTypeAdapter.html" title="annotation in javax.xml.bind.annotation.adapters"><code>XmlJavaTypeAdapter</code></a></li>
<li> if the type of JavaBean property is a collection type of
array, an indexed property, or a parameterized list, and
this annotation is used with <a href="../../../../javax/xml/bind/annotation/XmlElements.html" title="annotation in javax.xml.bind.annotation"><code>XmlElements</code></a> then,
<code>@XmlElement.type()</code> must be DEFAULT.class since the
collection item type is already known. </li>
</ul>
<p>
A JavaBean property, when annotated with @XmlElement annotation
is mapped to a local element in the XML Schema complex type to
which the containing class is mapped.
<p>
<b>Example 1: </b> Map a public non static non final field to local
element
<pre>
//Example: Code fragment
public class USPrice {
@XmlElement(name="itemprice")
public java.math.BigDecimal price;
}
<code>
&lt;!-- Example: Local XML Schema element --&gt;
&lt;xs:complexType name="USPrice"/&gt;
&lt;xs:sequence&gt;
&lt;xs:element name="itemprice" type="xs:decimal" minOccurs="0"/&gt;
&lt;/sequence&gt;
&lt;/xs:complexType&gt;
</code></pre>
<p>
<b> Example 2: </b> Map a field to a nillable element.
<pre>
//Example: Code fragment
public class USPrice {
@XmlElement(nillable=true)
public java.math.BigDecimal price;
}
<code>
&lt;!-- Example: Local XML Schema element --&gt;
&lt;xs:complexType name="USPrice"&gt;
&lt;xs:sequence&gt;
&lt;xs:element name="price" type="xs:decimal" nillable="true" minOccurs="0"/&gt;
&lt;/sequence&gt;
&lt;/xs:complexType&gt;
</code></pre>
<p>
<b> Example 3: </b> Map a field to a nillable, required element.
<pre>
//Example: Code fragment
public class USPrice {
@XmlElement(nillable=true, required=true)
public java.math.BigDecimal price;
}
<code>
&lt;!-- Example: Local XML Schema element --&gt;
&lt;xs:complexType name="USPrice"&gt;
&lt;xs:sequence&gt;
&lt;xs:element name="price" type="xs:decimal" nillable="true" minOccurs="1"/&gt;
&lt;/sequence&gt;
&lt;/xs:complexType&gt;
</code></pre>
<p> <b>Example 4: </b>Map a JavaBean property to an XML element
with anonymous type.</p>
<p>
See Example 6 in @<a href="../../../../javax/xml/bind/annotation/XmlType.html" title="annotation in javax.xml.bind.annotation"><code>XmlType</code></a>.</div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.6, JAXB 2.0</dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="annotation.type.optional.element.summary">
<!-- -->
</a>
<h3>Optional Element Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Optional Element Summary table, listing optional elements, and an explanation">
<caption><span>Optional Elements</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Optional Element and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../javax/xml/bind/annotation/XmlElement.html#defaultValue--">defaultValue</a></span></code>
<div class="block">Default value of this element.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../javax/xml/bind/annotation/XmlElement.html#name--">name</a></span></code>
<div class="block">Name of the XML Schema element.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../javax/xml/bind/annotation/XmlElement.html#namespace--">namespace</a></span></code>
<div class="block">XML target namespace of the XML Schema element.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../javax/xml/bind/annotation/XmlElement.html#nillable--">nillable</a></span></code>
<div class="block">Customize the element declaration to be nillable.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../javax/xml/bind/annotation/XmlElement.html#required--">required</a></span></code>
<div class="block">Customize the element declaration to be required.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>java.lang.Class</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../javax/xml/bind/annotation/XmlElement.html#type--">type</a></span></code>
<div class="block">The Java class being referenced.</div>
</td>
</tr>
</table>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="annotation.type.element.detail">
<!-- -->
</a>
<h3>Element Detail</h3>
<a name="name--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>name</h4>
<pre>public abstract&nbsp;java.lang.String&nbsp;name</pre>
<div class="block">Name of the XML Schema element.
<p> If the value is "##default", then element name is derived from the
JavaBean property name.</div>
<dl>
<dt>Default:</dt>
<dd>"##default"</dd>
</dl>
</li>
</ul>
</li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="nillable--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>nillable</h4>
<pre>public abstract&nbsp;boolean&nbsp;nillable</pre>
<div class="block">Customize the element declaration to be nillable.
<p>If nillable() is true, then the JavaBean property is
mapped to a XML Schema nillable element declaration.</div>
<dl>
<dt>Default:</dt>
<dd>false</dd>
</dl>
</li>
</ul>
</li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="required--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>required</h4>
<pre>public abstract&nbsp;boolean&nbsp;required</pre>
<div class="block">Customize the element declaration to be required.
<p>If required() is true, then Javabean property is mapped to
an XML schema element declaration with minOccurs="1".
maxOccurs is "1" for a single valued property and "unbounded"
for a multivalued property.
<p>If required() is false, then the Javabean property is mapped
to XML Schema element declaration with minOccurs="0".
maxOccurs is "1" for a single valued property and "unbounded"
for a multivalued property.</div>
<dl>
<dt>Default:</dt>
<dd>false</dd>
</dl>
</li>
</ul>
</li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="namespace--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>namespace</h4>
<pre>public abstract&nbsp;java.lang.String&nbsp;namespace</pre>
<div class="block">XML target namespace of the XML Schema element.
<p>
If the value is "##default", then the namespace is determined
as follows:
<ol>
<li>
If the enclosing package has <a href="../../../../javax/xml/bind/annotation/XmlSchema.html" title="annotation in javax.xml.bind.annotation"><code>XmlSchema</code></a> annotation,
and its <a href="../../../../javax/xml/bind/annotation/XmlSchema.html#elementFormDefault--"><code>elementFormDefault</code></a>
is <a href="../../../../javax/xml/bind/annotation/XmlNsForm.html#QUALIFIED"><code>QUALIFIED</code></a>, then the namespace of
the enclosing class.
<li>
Otherwise '' (which produces unqualified element in the default
namespace.
</ol></div>
<dl>
<dt>Default:</dt>
<dd>"##default"</dd>
</dl>
</li>
</ul>
</li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="defaultValue--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>defaultValue</h4>
<pre>public abstract&nbsp;java.lang.String&nbsp;defaultValue</pre>
<div class="block">Default value of this element.
<p>
The <pre>'�'</pre> value specified as a default of this annotation element
is used as a poor-man's substitute for null to allow implementations
to recognize the 'no default value' state.</div>
<dl>
<dt>Default:</dt>
<dd>"\u0000"</dd>
</dl>
</li>
</ul>
</li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="type--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>type</h4>
<pre>public abstract&nbsp;java.lang.Class&nbsp;type</pre>
<div class="block">The Java class being referenced.</div>
<dl>
<dt>Default:</dt>
<dd>javax.xml.bind.annotation.XmlElement.DEFAULT.class</dd>
</dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../javax/xml/bind/annotation/XmlAttribute.html" title="annotation in javax.xml.bind.annotation"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../javax/xml/bind/annotation/XmlElement.DEFAULT.html" title="class in javax.xml.bind.annotation"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?javax/xml/bind/annotation/XmlElement.html" target="_top">Frames</a></li>
<li><a href="XmlElement.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Required&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.optional.element.summary">Optional</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.element.detail">Element</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>