blob: b8ae338c76670660ade0dcc595a1166746b98caf [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>ParamConverter</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="ParamConverter";
}
}
catch(err) {
}
//-->
var methods = {"i0":6,"i1":6};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</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/ws/rs/ext/MessageBodyWriter.html" title="interface in javax.ws.rs.ext"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../javax/ws/rs/ext/ParamConverter.Lazy.html" title="annotation in javax.ws.rs.ext"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?javax/ws/rs/ext/ParamConverter.html" target="_top">Frames</a></li>
<li><a href="ParamConverter.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><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</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.ws.rs.ext</div>
<h2 title="Interface ParamConverter" class="title">Interface ParamConverter&lt;T&gt;</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>T</code> - the supported Java type convertible to/from a <code>String</code> format.</dd>
</dl>
<hr>
<br>
<pre>public interface <span class="typeNameLabel">ParamConverter&lt;T&gt;</span></pre>
<div class="block">Defines a contract for a delegate responsible for converting between a
<code>String</code> form of a message parameter value and the corresponding custom
Java type <code>T</code>.
Conversion of message parameter values injected via
<a href="../../../../javax/ws/rs/PathParam.html" title="annotation in javax.ws.rs"><code>&#64;PathParam</code></a>, <a href="../../../../javax/ws/rs/QueryParam.html" title="annotation in javax.ws.rs"><code>&#64;QueryParam</code></a>,
<a href="../../../../javax/ws/rs/MatrixParam.html" title="annotation in javax.ws.rs"><code>&#64;MatrixParam</code></a>, <a href="../../../../javax/ws/rs/FormParam.html" title="annotation in javax.ws.rs"><code>&#64;FormParam</code></a>,
<a href="../../../../javax/ws/rs/CookieParam.html" title="annotation in javax.ws.rs"><code>&#64;CookieParam</code></a> and <a href="../../../../javax/ws/rs/HeaderParam.html" title="annotation in javax.ws.rs"><code>&#64;HeaderParam</code></a>
is supported.
JAX-RS implementations MUST support the <code>ParamConverter</code> mechanism for all Java types.
If a <code>ParamConverter</code> is available for a type, it MUST be preferred over all other
conversion strategies mentioned in section 3.2 (i.e. single <code>String</code> argument constructor,
static <code>valueOf</code> or <code>fromString</code> methods, etc.).
<p>
By default, when used for injection of parameter values, a selected <code>ParamConverter</code>
instance MUST be used eagerly by a JAX-RS runtime to convert any <a href="../../../../javax/ws/rs/DefaultValue.html" title="annotation in javax.ws.rs"><code>default value</code></a> in the resource or provider model, that is during the application deployment,
before any value &ndash; default or otherwise &ndash; is actually required.
This conversion strategy ensures that any errors in the default values are reported
as early as possible.
This default behavior may be overridden by annotating the <code>ParamConverter</code>
implementation class with a <a href="../../../../javax/ws/rs/ext/ParamConverter.Lazy.html" title="annotation in javax.ws.rs.ext"><code>&#64;Lazy</code></a> annotation. In such case any default
value conversion delegated to the <code>@Lazy</code>-annotated converter will be deferred
to a latest possible moment (i.e. until the injection of such default value is required).
</p>
<p>
NOTE: A service implementing this contract is not recognized as a registrable
JAX-RS extension provider. Instead, a <a href="../../../../javax/ws/rs/ext/ParamConverterProvider.html" title="interface in javax.ws.rs.ext"><code>ParamConverterProvider</code></a> instance
responsible for providing <code>ParamConverter</code> instances has to be registered
as one of the JAX-RS extension providers.
</p></div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>2.0</dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== NESTED CLASS SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="nested.class.summary">
<!-- -->
</a>
<h3>Nested Class Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Nested Class Summary table, listing nested classes, and an explanation">
<caption><span>Nested Classes</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Interface and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static interface&nbsp;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../javax/ws/rs/ext/ParamConverter.Lazy.html" title="annotation in javax.ws.rs.ext">ParamConverter.Lazy</a></span></code>
<div class="block">Mandates that a conversion of any <a href="../../../../javax/ws/rs/DefaultValue.html" title="annotation in javax.ws.rs"><code>default value</code></a> delegated
to a <a href="../../../../javax/ws/rs/ext/ParamConverter.html" title="interface in javax.ws.rs.ext"><code>parameter converter</code></a> annotated with <code>@Lazy</code>
annotation SHOULD occur only once the value is actually required (e.g.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t3" class="tableTab"><span><a href="javascript:show(4);">Abstract Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code><a href="../../../../javax/ws/rs/ext/ParamConverter.html" title="type parameter in ParamConverter">T</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../javax/ws/rs/ext/ParamConverter.html#fromString-java.lang.String-">fromString</a></span>(java.lang.String&nbsp;value)</code>
<div class="block">Parse the supplied value and create an instance of <code>T</code>.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../javax/ws/rs/ext/ParamConverter.html#toString-T-">toString</a></span>(<a href="../../../../javax/ws/rs/ext/ParamConverter.html" title="type parameter in ParamConverter">T</a>&nbsp;value)</code>
<div class="block">Convert the supplied value to a String.</div>
</td>
</tr>
</table>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="fromString-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>fromString</h4>
<pre><a href="../../../../javax/ws/rs/ext/ParamConverter.html" title="type parameter in ParamConverter">T</a>&nbsp;fromString(java.lang.String&nbsp;value)</pre>
<div class="block">Parse the supplied value and create an instance of <code>T</code>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>value</code> - the string value.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the newly created instance of <code>T</code>.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if the supplied string cannot be
parsed or is <code>null</code>.</dd>
</dl>
</li>
</ul>
<a name="toString-java.lang.Object-">
<!-- -->
</a><a name="toString-T-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>toString</h4>
<pre>java.lang.String&nbsp;toString(<a href="../../../../javax/ws/rs/ext/ParamConverter.html" title="type parameter in ParamConverter">T</a>&nbsp;value)</pre>
<div class="block">Convert the supplied value to a String.
<p>
This method is reserved for future use. Proprietary JAX-RS extensions may leverage the method.
Users should be aware that any such support for the method comes at the expense of producing
non-portable code.
</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>value</code> - the value of type <code>T</code>.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a String representation of the value.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if the supplied object cannot be
serialized or is <code>null</code>.</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/ws/rs/ext/MessageBodyWriter.html" title="interface in javax.ws.rs.ext"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../javax/ws/rs/ext/ParamConverter.Lazy.html" title="annotation in javax.ws.rs.ext"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?javax/ws/rs/ext/ParamConverter.html" target="_top">Frames</a></li>
<li><a href="ParamConverter.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><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>