blob: 277ab3421570ebd3389e6b159371a2eed02f5943 [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>XmlValue</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="XmlValue";
}
}
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="../../../../jakarta/xml/bind/annotation/XmlType.DEFAULT.html" title="class in jakarta.xml.bind.annotation"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li>Next&nbsp;Class</li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?jakarta/xml/bind/annotation/XmlValue.html" target="_top">Frames</a></li>
<li><a href="XmlValue.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>Optional</li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Element</li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">jakarta.xml.bind.annotation</div>
<h2 title="Annotation Type XmlValue" class="title">Annotation Type XmlValue</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>@Retention(value=RUNTIME)
@Target(value={FIELD,METHOD})
public @interface <span class="memberNameLabel">XmlValue</span></pre>
<div class="block"><p>
Enables mapping a class to a XML Schema complex type with a
simpleContent or a XML Schema simple type.
</p>
<p>
<b> Usage: </b>
<p>
The <code>@XmlValue</code> annotation can be used with the following program
elements:
<ul>
<li> a JavaBean property.</li>
<li> non static, non transient field.</li>
</ul>
<p>See "Package Specification" in jakarta.xml.bind.package javadoc for
additional common information.</p>
The usage is subject to the following usage constraints:
<ul>
<li>At most one field or property can be annotated with the
<code>@XmlValue</code> annotation. </li>
<li><code>@XmlValue</code> can be used with the following
annotations: <a href="../../../../jakarta/xml/bind/annotation/XmlList.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlList</code></a>. However this is redundant since
<a href="../../../../jakarta/xml/bind/annotation/XmlList.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlList</code></a> maps a type to a simple schema type that derives by
list just as <a href="../../../../jakarta/xml/bind/annotation/XmlValue.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlValue</code></a> would. </li>
<li>If the type of the field or property is a collection type,
then the collection item type must map to a simple schema
type. </li>
<li>If the type of the field or property is not a collection
type, then the type must map to a XML Schema simple type. </li>
</ul>
<p>
If the annotated JavaBean property is the sole class member being
mapped to XML Schema construct, then the class is mapped to a
simple type.
If there are additional JavaBean properties (other than the
JavaBean property annotated with <code>@XmlValue</code> annotation)
that are mapped to XML attributes, then the class is mapped to a
complex type with simpleContent.
</p>
<p> <b> Example 1: </b> Map a class to XML Schema simpleType</p>
<pre>
// Example 1: Code fragment
public class USPrice {
&#64;XmlValue
public java.math.BigDecimal price;
}
<code>
&lt;!-- Example 1: XML Schema fragment --&gt;
&lt;xs:simpleType name="USPrice"&gt;
&lt;xs:restriction base="xs:decimal"/&gt;
&lt;/xs:simpleType&gt;
</code></pre>
<p><b> Example 2: </b> Map a class to XML Schema complexType with
with simpleContent.</p>
<pre>
// Example 2: Code fragment
public class InternationalPrice {
&#64;XmlValue
public java.math.BigDecimal price;
&#64;XmlAttribute
public String currency;
}
<code>
&lt;!-- Example 2: XML Schema fragment --&gt;
&lt;xs:complexType name="InternationalPrice"&gt;
&lt;xs:simpleContent&gt;
&lt;xs:extension base="xs:decimal"&gt;
&lt;xs:attribute name="currency" type="xs:string"/&gt;
&lt;/xs:extension&gt;
&lt;/xs:simpleContent&gt;
&lt;/xs:complexType&gt;
</code></pre></div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.6, JAXB 2.0</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../jakarta/xml/bind/annotation/XmlType.html" title="annotation in jakarta.xml.bind.annotation"><code>XmlType</code></a></dd>
</dl>
</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="../../../../jakarta/xml/bind/annotation/XmlType.DEFAULT.html" title="class in jakarta.xml.bind.annotation"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li>Next&nbsp;Class</li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?jakarta/xml/bind/annotation/XmlValue.html" target="_top">Frames</a></li>
<li><a href="XmlValue.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>Optional</li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Element</li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>