| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <!-- NewPage --> |
| <html lang="en"> |
| <head> |
| <title>GenericEntity</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="GenericEntity"; |
| } |
| } |
| catch(err) { |
| } |
| //--> |
| var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10}; |
| var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete 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/core/Form.html" title="class in javax.ws.rs.core"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../../javax/ws/rs/core/GenericType.html" title="class in javax.ws.rs.core"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../index.html?javax/ws/rs/core/GenericEntity.html" target="_top">Frames</a></li> |
| <li><a href="GenericEntity.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_top"> |
| <li><a href="../../../../allclasses-noframe.html">All 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: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li><a href="#constructor.summary">Constr</a> | </li> |
| <li><a href="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#constructor.detail">Constr</a> | </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.core</div> |
| <h2 title="Class GenericEntity" class="title">Class GenericEntity<T></h2> |
| </div> |
| <div class="contentContainer"> |
| <ul class="inheritance"> |
| <li>java.lang.Object</li> |
| <li> |
| <ul class="inheritance"> |
| <li>javax.ws.rs.core.GenericEntity<T></li> |
| </ul> |
| </li> |
| </ul> |
| <div class="description"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <dl> |
| <dt><span class="paramLabel">Type Parameters:</span></dt> |
| <dd><code>T</code> - response entity instance type</dd> |
| </dl> |
| <hr> |
| <br> |
| <pre>public class <span class="typeNameLabel">GenericEntity<T></span> |
| extends java.lang.Object</pre> |
| <div class="block">Represents a message entity of a generic type <code>T</code>. |
| <p> |
| Normally type erasure removes generic type information such that a |
| <a href="../../../../javax/ws/rs/core/Response.html" title="class in javax.ws.rs.core"><code>Response</code></a> instance that contains, e.g., an entity of type |
| <code>List<String></code> appears to contain a raw <code>List<?></code> at runtime. |
| When the generic type is required to select a suitable |
| <a href="../../../../javax/ws/rs/ext/MessageBodyWriter.html" title="interface in javax.ws.rs.ext"><code>MessageBodyWriter</code></a>, this class may be used to wrap the |
| entity and capture its generic type. |
| </p> |
| <p> |
| There are two ways to create an instance: |
| </p> |
| <ol> |
| <li>Create a (typically anonymous) subclass of this |
| class which enables retrieval of the type information at runtime despite |
| type erasure. For example, the following code shows how to create a |
| <a href="../../../../javax/ws/rs/core/Response.html" title="class in javax.ws.rs.core"><code>Response</code></a> containing an entity of type <code>List<String></code> whose |
| generic type will be available at runtime for selection of a suitable |
| <a href="../../../../javax/ws/rs/ext/MessageBodyWriter.html" title="interface in javax.ws.rs.ext"><code>MessageBodyWriter</code></a>: |
| |
| <pre>List<String> list = new ArrayList<String>(); |
| GenericEntity<List<String>> entity = new GenericEntity<List<String>>(list) {}; |
| Response response = Response.ok(entity).build();</pre> |
| |
| <p>where <code>list</code> is the instance of <code>List<String></code> |
| that will form the response body and entity is an instance of an anonymous |
| subclass of <code>GenericEntity</code>.</p></li> |
| <li>Create an instance directly by supplying the generic type information |
| with the entity. For example the following code shows how to create |
| a response containing the result of a method invoked via reflection: |
| <pre>Method method = ...; |
| GenericEntity<Object> entity = new GenericEntity<Object>( |
| method.invoke(...), method.getGenericReturnType()); |
| Response response = Response.ok(entity).build();</pre></li> |
| <p>The above obtains the generic type from the return type of the method, |
| the raw type is the class of entity.</p> |
| </ol></div> |
| <dl> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>1.0</dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../../../javax/ws/rs/core/GenericType.html" title="class in javax.ws.rs.core"><code>GenericType</code></a></dd> |
| </dl> |
| </li> |
| </ul> |
| </div> |
| <div class="summary"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ======== CONSTRUCTOR SUMMARY ======== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="constructor.summary"> |
| <!-- --> |
| </a> |
| <h3>Constructor Summary</h3> |
| <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation"> |
| <caption><span>Constructors</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier</th> |
| <th class="colLast" scope="col">Constructor and Description</th> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>protected </code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../javax/ws/rs/core/GenericEntity.html#GenericEntity-T-">GenericEntity</a></span>(<a href="../../../../javax/ws/rs/core/GenericEntity.html" title="type parameter in GenericEntity">T</a> entity)</code> |
| <div class="block">Constructs a new generic entity.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code> </code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../javax/ws/rs/core/GenericEntity.html#GenericEntity-T-java.lang.reflect.Type-">GenericEntity</a></span>(<a href="../../../../javax/ws/rs/core/GenericEntity.html" title="type parameter in GenericEntity">T</a> entity, |
| java.lang.reflect.Type genericType)</code> |
| <div class="block">Create a new instance of GenericEntity, supplying the generic type information.</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"> </span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd"> </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>boolean</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../javax/ws/rs/core/GenericEntity.html#equals-java.lang.Object-">equals</a></span>(java.lang.Object obj)</code> </td> |
| </tr> |
| <tr id="i1" class="rowColor"> |
| <td class="colFirst"><code><a href="../../../../javax/ws/rs/core/GenericEntity.html" title="type parameter in GenericEntity">T</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../javax/ws/rs/core/GenericEntity.html#getEntity--">getEntity</a></span>()</code> |
| <div class="block">Get the enclosed entity.</div> |
| </td> |
| </tr> |
| <tr id="i2" class="altColor"> |
| <td class="colFirst"><code>java.lang.Class<?></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../javax/ws/rs/core/GenericEntity.html#getRawType--">getRawType</a></span>()</code> |
| <div class="block">Gets the raw type of the enclosed entity.</div> |
| </td> |
| </tr> |
| <tr id="i3" class="rowColor"> |
| <td class="colFirst"><code>java.lang.reflect.Type</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../javax/ws/rs/core/GenericEntity.html#getType--">getType</a></span>()</code> |
| <div class="block">Gets underlying <code>Type</code> instance.</div> |
| </td> |
| </tr> |
| <tr id="i4" class="altColor"> |
| <td class="colFirst"><code>int</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../javax/ws/rs/core/GenericEntity.html#hashCode--">hashCode</a></span>()</code> </td> |
| </tr> |
| <tr id="i5" class="rowColor"> |
| <td class="colFirst"><code>java.lang.String</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../javax/ws/rs/core/GenericEntity.html#toString--">toString</a></span>()</code> </td> |
| </tr> |
| </table> |
| <ul class="blockList"> |
| <li class="blockList"><a name="methods.inherited.from.class.java.lang.Object"> |
| <!-- --> |
| </a> |
| <h3>Methods inherited from class java.lang.Object</h3> |
| <code>clone, finalize, getClass, notify, notifyAll, wait, wait, wait</code></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| <div class="details"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ========= CONSTRUCTOR DETAIL ======== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="constructor.detail"> |
| <!-- --> |
| </a> |
| <h3>Constructor Detail</h3> |
| <a name="GenericEntity-java.lang.Object-"> |
| <!-- --> |
| </a><a name="GenericEntity-T-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>GenericEntity</h4> |
| <pre>protected GenericEntity(<a href="../../../../javax/ws/rs/core/GenericEntity.html" title="type parameter in GenericEntity">T</a> entity)</pre> |
| <div class="block">Constructs a new generic entity. Derives represented class from type |
| parameter. Note that this constructor is protected, users should create |
| a (usually anonymous) subclass as shown above.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>entity</code> - the entity instance, must not be <code>null</code>.</dd> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code>java.lang.IllegalArgumentException</code> - if entity is <code>null</code>.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="GenericEntity-java.lang.Object-java.lang.reflect.Type-"> |
| <!-- --> |
| </a><a name="GenericEntity-T-java.lang.reflect.Type-"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>GenericEntity</h4> |
| <pre>public GenericEntity(<a href="../../../../javax/ws/rs/core/GenericEntity.html" title="type parameter in GenericEntity">T</a> entity, |
| java.lang.reflect.Type genericType)</pre> |
| <div class="block">Create a new instance of GenericEntity, supplying the generic type information. |
| The entity must be assignable to a variable of the |
| supplied generic type, e.g. if <code>entity</code> is an instance of |
| <code>ArrayList<String></code> then <code>genericType</code> could |
| be the same or a superclass of <code>ArrayList</code> with the same generic |
| type like <code>List<String></code>.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>entity</code> - the entity instance, must not be <code>null</code>.</dd> |
| <dd><code>genericType</code> - the generic type, must not be <code>null</code>.</dd> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code>java.lang.IllegalArgumentException</code> - if the entity is not assignable to |
| a variable of the supplied generic type or if entity or genericType |
| is null.</dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <!-- ============ METHOD DETAIL ========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method.detail"> |
| <!-- --> |
| </a> |
| <h3>Method Detail</h3> |
| <a name="getRawType--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getRawType</h4> |
| <pre>public final java.lang.Class<?> getRawType()</pre> |
| <div class="block">Gets the raw type of the enclosed entity. Note that this is the raw type of |
| the instance, not the raw type of the type parameter. I.e. in the example |
| in the introduction, the raw type is <code>ArrayList</code> not <code>List</code>.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the raw type.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getType--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getType</h4> |
| <pre>public final java.lang.reflect.Type getType()</pre> |
| <div class="block">Gets underlying <code>Type</code> instance. Note that this is derived from the |
| type parameter, not the enclosed instance. I.e. in the example |
| in the introduction, the type is <code>List<String></code> not |
| <code>ArrayList<String></code>.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the type</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getEntity--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getEntity</h4> |
| <pre>public final <a href="../../../../javax/ws/rs/core/GenericEntity.html" title="type parameter in GenericEntity">T</a> getEntity()</pre> |
| <div class="block">Get the enclosed entity.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the enclosed entity.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="equals-java.lang.Object-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>equals</h4> |
| <pre>public boolean equals(java.lang.Object obj)</pre> |
| <dl> |
| <dt><span class="overrideSpecifyLabel">Overrides:</span></dt> |
| <dd><code>equals</code> in class <code>java.lang.Object</code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="hashCode--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>hashCode</h4> |
| <pre>public int hashCode()</pre> |
| <dl> |
| <dt><span class="overrideSpecifyLabel">Overrides:</span></dt> |
| <dd><code>hashCode</code> in class <code>java.lang.Object</code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="toString--"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>toString</h4> |
| <pre>public java.lang.String toString()</pre> |
| <dl> |
| <dt><span class="overrideSpecifyLabel">Overrides:</span></dt> |
| <dd><code>toString</code> in class <code>java.lang.Object</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/core/Form.html" title="class in javax.ws.rs.core"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../../javax/ws/rs/core/GenericType.html" title="class in javax.ws.rs.core"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../index.html?javax/ws/rs/core/GenericEntity.html" target="_top">Frames</a></li> |
| <li><a href="GenericEntity.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_bottom"> |
| <li><a href="../../../../allclasses-noframe.html">All 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: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li><a href="#constructor.summary">Constr</a> | </li> |
| <li><a href="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#constructor.detail">Constr</a> | </li> |
| <li><a href="#method.detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.bottom"> |
| <!-- --> |
| </a></div> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| </body> |
| </html> |