blob: 4c9105261f8ba947e48306ed3814e100873770f0 [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>XmlAttribute</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="XmlAttribute";
}
}
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/XmlAttachmentRef.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.html" title="annotation 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/XmlAttribute.html" target="_top">Frames</a></li>
<li><a href="XmlAttribute.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 XmlAttribute" class="title">Annotation Type XmlAttribute</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">XmlAttribute</span></pre>
<div class="block"><p>
Maps a JavaBean property to a XML attribute.
<p> <b>Usage</b> </p>
<p>
The <code>@XmlAttribute</code> annotation can be used with the
following program elements:
<ul>
<li> JavaBean property </li>
<li> field </li>
</ul>
<p> A static final field is mapped to a XML fixed attribute.
<p>See "Package Specification" in javax.xml.bind.package javadoc for
additional common information.</p>
The usage is subject to the following constraints:
<ul>
<li> If type of the field or the property is a collection
type, then the collection item type must be mapped to schema
simple type.
<pre>
// Examples
&#64;XmlAttribute List&lt;Integer&gt; items; //legal
&#64;XmlAttribute List&lt;Bar&gt; foo; // illegal if Bar does not map to a schema simple type
</pre>
</li>
<li> If the type of the field or the property is a non
collection type, then the type of the property or field
must map to a simple schema type.
<pre>
// Examples
&#64;XmlAttribute int foo; // legal
&#64;XmlAttribute Foo foo; // illegal if Foo does not map to a schema simple type
</pre>
</li>
<li> This annotation can be used with the 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/adapters/XmlJavaTypeAdapter.html" title="annotation in javax.xml.bind.annotation.adapters"><code>XmlJavaTypeAdapter</code></a>.</li>
</ul>
<p> <b>Example 1: </b>Map a JavaBean property to an XML attribute.</p>
<pre>
//Example: Code fragment
public class USPrice {
&#64;XmlAttribute
public java.math.BigDecimal getPrice() {...} ;
public void setPrice(java.math.BigDecimal ) {...};
}
<code>
&lt;!-- Example: XML Schema fragment --&gt;
&lt;xs:complexType name="USPrice"&gt;
&lt;xs:sequence&gt;
&lt;/xs:sequence&gt;
&lt;xs:attribute name="price" type="xs:decimal"/&gt;
&lt;/xs:complexType&gt;
</code></pre>
<p> <b>Example 2: </b>Map a JavaBean property to an XML attribute with anonymous type.</p>
See Example 7 in @<a href="../../../../javax/xml/bind/annotation/XmlType.html" title="annotation in javax.xml.bind.annotation"><code>XmlType</code></a>.
<p> <b>Example 3: </b>Map a JavaBean collection property to an XML attribute.</p>
<pre>
// Example: Code fragment
class Foo {
...
&#64;XmlAttribute List&lt;Integer&gt; items;
}
<code>
&lt;!-- Example: XML Schema fragment --&gt;
&lt;xs:complexType name="foo"&gt;
...
&lt;xs:attribute name="items"&gt;
&lt;xs:simpleType&gt;
&lt;xs:list itemType="xs:int"/&gt;
&lt;/xs:simpleType&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="../../../../javax/xml/bind/annotation/XmlType.html" title="annotation in javax.xml.bind.annotation"><code>XmlType</code></a></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/XmlAttribute.html#name--">name</a></span></code>
<div class="block">Name of the XML Schema attribute.</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/XmlAttribute.html#namespace--">namespace</a></span></code>
<div class="block">Specifies the XML target namespace of the XML Schema
attribute.</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/XmlAttribute.html#required--">required</a></span></code>
<div class="block">Specifies if the XML Schema attribute is optional or
required.</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 attribute. By default, the XML Schema
attribute 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="required--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>required</h4>
<pre>public abstract&nbsp;boolean&nbsp;required</pre>
<div class="block">Specifies if the XML Schema attribute is optional or
required. If true, then the JavaBean property is mapped to a
XML Schema attribute that is required. Otherwise it is mapped
to a XML Schema attribute that is optional.</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="blockListLast">
<li class="blockList">
<h4>namespace</h4>
<pre>public abstract&nbsp;java.lang.String&nbsp;namespace</pre>
<div class="block">Specifies the XML target namespace of the XML Schema
attribute.</div>
<dl>
<dt>Default:</dt>
<dd>"##default"</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/XmlAttachmentRef.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.html" title="annotation 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/XmlAttribute.html" target="_top">Frames</a></li>
<li><a href="XmlAttribute.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>