blob: 7904d551e48765fca7326aa7a665df87f6a13ae0 [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>JsonArray</title>
<link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../script.js"></script>
<link rel="shortcut icon" href="/img/jakarta-favicon.ico">
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="JsonArray";
}
}
catch(err) {
}
//-->
var methods = {"i0":6,"i1":6,"i2":6,"i3":6,"i4":6,"i5":6,"i6":6,"i7":6,"i8":6,"i9":6,"i10":6,"i11":18,"i12":6};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"],16:["t5","Default 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="../../jakarta/json/Json.html" title="class in jakarta.json"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../jakarta/json/JsonArrayBuilder.html" title="interface in jakarta.json"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../index.html?jakarta/json/JsonArray.html" target="_top">Frames</a></li>
<li><a href="JsonArray.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>Nested&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">jakarta.json</div>
<h2 title="Interface JsonArray" class="title">Interface JsonArray</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Superinterfaces:</dt>
<dd>java.util.Collection&lt;<a href="../../jakarta/json/JsonValue.html" title="interface in jakarta.json">JsonValue</a>&gt;, java.lang.Iterable&lt;<a href="../../jakarta/json/JsonValue.html" title="interface in jakarta.json">JsonValue</a>&gt;, <a href="../../jakarta/json/JsonStructure.html" title="interface in jakarta.json">JsonStructure</a>, <a href="../../jakarta/json/JsonValue.html" title="interface in jakarta.json">JsonValue</a>, java.util.List&lt;<a href="../../jakarta/json/JsonValue.html" title="interface in jakarta.json">JsonValue</a>&gt;</dd>
</dl>
<hr>
<br>
<pre>public interface <span class="typeNameLabel">JsonArray</span>
extends <a href="../../jakarta/json/JsonStructure.html" title="interface in jakarta.json">JsonStructure</a>, java.util.List&lt;<a href="../../jakarta/json/JsonValue.html" title="interface in jakarta.json">JsonValue</a>&gt;</pre>
<div class="block"><code>JsonArray</code> represents an immutable JSON array
(an ordered sequence of zero or more values).
It also provides an unmodifiable list view of the values in the array.
<p>A <code>JsonArray</code> object can be created by reading JSON data from
an input source or it can be built from scratch using an array builder
object.
<p>The following example demonstrates how to create a <code>JsonArray</code>
object from an input source using the method <a href="../../jakarta/json/JsonReader.html#readArray--"><code>JsonReader.readArray()</code></a>:
<pre><code>
JsonReader jsonReader = Json.createReader(...);
JsonArray array = jsonReader.readArray();
jsonReader.close();
</code></pre>
<p>The following example demonstrates how to build an empty JSON array
using the class <a href="../../jakarta/json/JsonArrayBuilder.html" title="interface in jakarta.json"><code>JsonArrayBuilder</code></a>:
<pre><code>
JsonArray array = Json.createArrayBuilder().build();
</code></pre>
<p>The example code below demonstrates how to create the following JSON array:
<pre><code>
[
{ "type": "home", "number": "212 555-1234" },
{ "type": "fax", "number": "646 555-4567" }
]
</code></pre>
<pre><code>
JsonArray value = Json.createArrayBuilder()
.add(Json.createObjectBuilder()
.add("type", "home")
.add("number", "212 555-1234"))
.add(Json.createObjectBuilder()
.add("type", "fax")
.add("number", "646 555-4567"))
.build();
</code></pre>
<p>The following example demonstrates how to write a <code>JsonArray</code> object
as JSON data:
<pre><code>
JsonArray arr = ...;
JsonWriter writer = Json.createWriter(...)
writer.writeArray(arr);
writer.close();
</code></pre>
<p>The values in a <code>JsonArray</code> can be of the following types:
<a href="../../jakarta/json/JsonObject.html" title="interface in jakarta.json"><code>JsonObject</code></a>, <a href="../../jakarta/json/JsonArray.html" title="interface in jakarta.json"><code>JsonArray</code></a>,
<a href="../../jakarta/json/JsonString.html" title="interface in jakarta.json"><code>JsonString</code></a>, <a href="../../jakarta/json/JsonNumber.html" title="interface in jakarta.json"><code>JsonNumber</code></a>, <a href="../../jakarta/json/JsonValue.html#TRUE"><code>JsonValue.TRUE</code></a>,
<a href="../../jakarta/json/JsonValue.html#FALSE"><code>JsonValue.FALSE</code></a>, and <a href="../../jakarta/json/JsonValue.html#NULL"><code>JsonValue.NULL</code></a>.
<code>JsonArray</code> provides various accessor methods to access the values
in an array.
<p>The following example shows how to obtain the home phone number
"212 555-1234" from the array built in the previous example:
<pre><code>
JsonObject home = array.getJsonObject(0);
String number = home.getString("number");
</code></pre>
<p><code>JsonArray</code> instances are list objects that provide read-only
access to the values in the JSON array. Any attempt to modify the list,
whether directly or using its collection views, results in an
<code>UnsupportedOperationException</code>.</div>
<dl>
<dt><span class="simpleTagLabel">Examples (en):</span></dt>
<dd><a href="../../../../../tomee-9.0/examples/mp-custom-healthcheck.html">mp-custom-healthcheck</a></dd>
<dt><span class="simpleTagLabel">Examples (es):</span></dt>
<dd><a href="../../../../../tomee-9.0/es/examples/mp-custom-healthcheck.html">mp-custom-healthcheck</a></dd>
<dt><span class="simpleTagLabel">Examples (pt):</span></dt>
<dd><a href="../../../../../tomee-9.0/pt/examples/mp-custom-healthcheck.html">mp-custom-healthcheck</a></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>
<ul class="blockList">
<li class="blockList"><a name="nested.classes.inherited.from.class.jakarta.json.JsonValue">
<!-- -->
</a>
<h3>Nested classes/interfaces inherited from interface&nbsp;jakarta.json.<a href="../../jakarta/json/JsonValue.html" title="interface in jakarta.json">JsonValue</a></h3>
<code><a href="../../jakarta/json/JsonValue.ValueType.html" title="enum in jakarta.json">JsonValue.ValueType</a></code></li>
</ul>
</li>
</ul>
<!-- =========== FIELD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="field.summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<ul class="blockList">
<li class="blockList"><a name="fields.inherited.from.class.jakarta.json.JsonValue">
<!-- -->
</a>
<h3>Fields inherited from interface&nbsp;jakarta.json.<a href="../../jakarta/json/JsonValue.html" title="interface in jakarta.json">JsonValue</a></h3>
<code><a href="../../jakarta/json/JsonValue.html#EMPTY_JSON_ARRAY">EMPTY_JSON_ARRAY</a>, <a href="../../jakarta/json/JsonValue.html#EMPTY_JSON_OBJECT">EMPTY_JSON_OBJECT</a>, <a href="../../jakarta/json/JsonValue.html#FALSE">FALSE</a>, <a href="../../jakarta/json/JsonValue.html#NULL">NULL</a>, <a href="../../jakarta/json/JsonValue.html#TRUE">TRUE</a></code></li>
</ul>
</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><span id="t5" class="tableTab"><span><a href="javascript:show(16);">Default 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>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/json/JsonArray.html#getBoolean-int-">getBoolean</a></span>(int&nbsp;index)</code>
<div class="block">Returns the boolean value at the specified position.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/json/JsonArray.html#getBoolean-int-boolean-">getBoolean</a></span>(int&nbsp;index,
boolean&nbsp;defaultValue)</code>
<div class="block">Returns the boolean value at the specified position.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/json/JsonArray.html#getInt-int-">getInt</a></span>(int&nbsp;index)</code>
<div class="block">A convenience method for
<code>getJsonNumber(index).intValue()</code>.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/json/JsonArray.html#getInt-int-int-">getInt</a></span>(int&nbsp;index,
int&nbsp;defaultValue)</code>
<div class="block">Returns the int value of the <code>JsonNumber</code> at the specified position.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code><a href="../../jakarta/json/JsonArray.html" title="interface in jakarta.json">JsonArray</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/json/JsonArray.html#getJsonArray-int-">getJsonArray</a></span>(int&nbsp;index)</code>
<div class="block">Returns the array value at the specified position in this array.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code><a href="../../jakarta/json/JsonNumber.html" title="interface in jakarta.json">JsonNumber</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/json/JsonArray.html#getJsonNumber-int-">getJsonNumber</a></span>(int&nbsp;index)</code>
<div class="block">Returns the number value at the specified position in this array.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code><a href="../../jakarta/json/JsonObject.html" title="interface in jakarta.json">JsonObject</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/json/JsonArray.html#getJsonObject-int-">getJsonObject</a></span>(int&nbsp;index)</code>
<div class="block">Returns the object value at the specified position in this array.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code><a href="../../jakarta/json/JsonString.html" title="interface in jakarta.json">JsonString</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/json/JsonArray.html#getJsonString-int-">getJsonString</a></span>(int&nbsp;index)</code>
<div class="block">Returns the string value at ths specified position in this array.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/json/JsonArray.html#getString-int-">getString</a></span>(int&nbsp;index)</code>
<div class="block">A convenience method for
<code>getJsonString(index).getString()</code>.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/json/JsonArray.html#getString-int-java.lang.String-">getString</a></span>(int&nbsp;index,
java.lang.String&nbsp;defaultValue)</code>
<div class="block">Returns the <code>String</code> value of <code>JsonString</code> at the specified
position in this JSON array values.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code>&lt;T extends <a href="../../jakarta/json/JsonValue.html" title="interface in jakarta.json">JsonValue</a>&gt;<br>java.util.List&lt;T&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/json/JsonArray.html#getValuesAs-java.lang.Class-">getValuesAs</a></span>(java.lang.Class&lt;T&gt;&nbsp;clazz)</code>
<div class="block">Returns a list view of the specified type for the array.</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code>default &lt;T,K extends <a href="../../jakarta/json/JsonValue.html" title="interface in jakarta.json">JsonValue</a>&gt;<br>java.util.List&lt;T&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/json/JsonArray.html#getValuesAs-java.util.function.Function-">getValuesAs</a></span>(java.util.function.Function&lt;K,T&gt;&nbsp;func)</code>
<div class="block">Returns a list view for the array.</div>
</td>
</tr>
<tr id="i12" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../jakarta/json/JsonArray.html#isNull-int-">isNull</a></span>(int&nbsp;index)</code>
<div class="block">Returns <code>true</code> if the value at the specified location in this
array is <code>JsonValue.NULL</code>.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.jakarta.json.JsonStructure">
<!-- -->
</a>
<h3>Methods inherited from interface&nbsp;jakarta.json.<a href="../../jakarta/json/JsonStructure.html" title="interface in jakarta.json">JsonStructure</a></h3>
<code><a href="../../jakarta/json/JsonStructure.html#getValue-java.lang.String-">getValue</a></code></li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.jakarta.json.JsonValue">
<!-- -->
</a>
<h3>Methods inherited from interface&nbsp;jakarta.json.<a href="../../jakarta/json/JsonValue.html" title="interface in jakarta.json">JsonValue</a></h3>
<code><a href="../../jakarta/json/JsonValue.html#asJsonArray--">asJsonArray</a>, <a href="../../jakarta/json/JsonValue.html#asJsonObject--">asJsonObject</a>, <a href="../../jakarta/json/JsonValue.html#getValueType--">getValueType</a>, <a href="../../jakarta/json/JsonValue.html#toString--">toString</a></code></li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.util.List">
<!-- -->
</a>
<h3>Methods inherited from interface&nbsp;java.util.List</h3>
<code>add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray</code></li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.util.Collection">
<!-- -->
</a>
<h3>Methods inherited from interface&nbsp;java.util.Collection</h3>
<code>parallelStream, removeIf, stream</code></li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Iterable">
<!-- -->
</a>
<h3>Methods inherited from interface&nbsp;java.lang.Iterable</h3>
<code>forEach</code></li>
</ul>
</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="getJsonObject-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getJsonObject</h4>
<pre><a href="../../jakarta/json/JsonObject.html" title="interface in jakarta.json">JsonObject</a>&nbsp;getJsonObject(int&nbsp;index)</pre>
<div class="block">Returns the object value at the specified position in this array.
This is a convenience method for <code>(JsonObject)get(index)</code>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>index</code> - index of the value to be returned</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the value at the specified position in this array</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IndexOutOfBoundsException</code> - if the index is out of range</dd>
<dd><code>java.lang.ClassCastException</code> - if the value at the specified position is not
assignable to the JsonObject type</dd>
</dl>
</li>
</ul>
<a name="getJsonArray-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getJsonArray</h4>
<pre><a href="../../jakarta/json/JsonArray.html" title="interface in jakarta.json">JsonArray</a>&nbsp;getJsonArray(int&nbsp;index)</pre>
<div class="block">Returns the array value at the specified position in this array.
This is a convenience method for <code>(JsonArray)get(index)</code>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>index</code> - index of the value to be returned</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the value at the specified position in this array</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IndexOutOfBoundsException</code> - if the index is out of range</dd>
<dd><code>java.lang.ClassCastException</code> - if the value at the specified position is not
assignable to the JsonArray type</dd>
</dl>
</li>
</ul>
<a name="getJsonNumber-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getJsonNumber</h4>
<pre><a href="../../jakarta/json/JsonNumber.html" title="interface in jakarta.json">JsonNumber</a>&nbsp;getJsonNumber(int&nbsp;index)</pre>
<div class="block">Returns the number value at the specified position in this array.
This is a convenience method for <code>(JsonNumber)get(index)</code>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>index</code> - index of the value to be returned</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the value at the specified position in this array</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IndexOutOfBoundsException</code> - if the index is out of range</dd>
<dd><code>java.lang.ClassCastException</code> - if the value at the specified position is not
assignable to the JsonNumber type</dd>
</dl>
</li>
</ul>
<a name="getJsonString-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getJsonString</h4>
<pre><a href="../../jakarta/json/JsonString.html" title="interface in jakarta.json">JsonString</a>&nbsp;getJsonString(int&nbsp;index)</pre>
<div class="block">Returns the string value at ths specified position in this array.
This is a convenience method for <code>(JsonString)get(index)</code>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>index</code> - index of the value to be returned</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the value at the specified position in this array</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IndexOutOfBoundsException</code> - if the index is out of range</dd>
<dd><code>java.lang.ClassCastException</code> - if the value at the specified position is not
assignable to the JsonString type</dd>
</dl>
</li>
</ul>
<a name="getValuesAs-java.lang.Class-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getValuesAs</h4>
<pre>&lt;T extends <a href="../../jakarta/json/JsonValue.html" title="interface in jakarta.json">JsonValue</a>&gt;&nbsp;java.util.List&lt;T&gt;&nbsp;getValuesAs(java.lang.Class&lt;T&gt;&nbsp;clazz)</pre>
<div class="block">Returns a list view of the specified type for the array. This method
does not verify if there is a value of wrong type in the array. Providing
this typesafe view dynamically may cause a program fail with a
<code>ClassCastException</code>, if there is a value of wrong type in this
array. Unfortunately, the exception can occur at any time after this
method returns.</div>
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>T</code> - The type of the List for the array</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>clazz</code> - a JsonValue type</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a list view of the specified type</dd>
</dl>
</li>
</ul>
<a name="getValuesAs-java.util.function.Function-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getValuesAs</h4>
<pre>default&nbsp;&lt;T,K extends <a href="../../jakarta/json/JsonValue.html" title="interface in jakarta.json">JsonValue</a>&gt;&nbsp;java.util.List&lt;T&gt;&nbsp;getValuesAs(java.util.function.Function&lt;K,T&gt;&nbsp;func)</pre>
<div class="block">Returns a list view for the array. The value and the type of the elements
in the list is specified by the <code>func</code> argument.
<p>This method can be used to obtain a list of the unwrapped types, such as
<pre><code>
List&lt;String&gt; strings = ary1.getValuesAs(JsonString::getString);
List&lt;Integer&gt; ints = ary2.getValuesAs(JsonNumber::intValue);
</code> </pre>
or a list of simple projections, such as
<pre> <code>
List&lt;Integer&gt; stringsizes = ary1.getValueAs((JsonString v)-&gt;v.getString().length();
</code> </pre></div>
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>K</code> - The element type (must be a subtype of JsonValue) of this JsonArray.</dd>
<dd><code>T</code> - The element type of the returned List</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>func</code> - The function that maps the elements of this JsonArray to the target elements.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>A List of the specified values and type.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.ClassCastException</code> - if the <code>JsonArray</code> contains a value of wrong type</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
</dl>
</li>
</ul>
<a name="getString-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getString</h4>
<pre>java.lang.String&nbsp;getString(int&nbsp;index)</pre>
<div class="block">A convenience method for
<code>getJsonString(index).getString()</code>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>index</code> - index of the <code>JsonString</code> value</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the String value at the specified position</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IndexOutOfBoundsException</code> - if the index is out of range</dd>
<dd><code>java.lang.ClassCastException</code> - if the value at the specified position is not
assignable to <code>JsonString</code></dd>
</dl>
</li>
</ul>
<a name="getString-int-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getString</h4>
<pre>java.lang.String&nbsp;getString(int&nbsp;index,
java.lang.String&nbsp;defaultValue)</pre>
<div class="block">Returns the <code>String</code> value of <code>JsonString</code> at the specified
position in this JSON array values. If <code>JsonString</code> is found,
its <a href="../../jakarta/json/JsonString.html#getString--"><code>JsonString.getString()</code></a> is returned. Otherwise,
the specified default value is returned.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>index</code> - index of the <code>JsonString</code> value</dd>
<dd><code>defaultValue</code> - the String to return if the <code>JsonValue</code> at the
specified position is not a <code>JsonString</code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the String value at the specified position in this array,
or the specified default value</dd>
</dl>
</li>
</ul>
<a name="getInt-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getInt</h4>
<pre>int&nbsp;getInt(int&nbsp;index)</pre>
<div class="block">A convenience method for
<code>getJsonNumber(index).intValue()</code>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>index</code> - index of the <code>JsonNumber</code> value</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the int value at the specified position</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IndexOutOfBoundsException</code> - if the index is out of range</dd>
<dd><code>java.lang.ClassCastException</code> - if the value at the specified position is not
assignable to <code>JsonNumber</code></dd>
</dl>
</li>
</ul>
<a name="getInt-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getInt</h4>
<pre>int&nbsp;getInt(int&nbsp;index,
int&nbsp;defaultValue)</pre>
<div class="block">Returns the int value of the <code>JsonNumber</code> at the specified position.
If the value at that position is a <code>JsonNumber</code>,
this method returns <a href="../../jakarta/json/JsonNumber.html#intValue--"><code>JsonNumber.intValue()</code></a>. Otherwise
this method returns the specified default value.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>index</code> - index of the <code>JsonNumber</code> value</dd>
<dd><code>defaultValue</code> - the int value to return if the <code>JsonValue</code> at
the specified position is not a <code>JsonNumber</code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the int value at the specified position in this array,
or the specified default value</dd>
</dl>
</li>
</ul>
<a name="getBoolean-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getBoolean</h4>
<pre>boolean&nbsp;getBoolean(int&nbsp;index)</pre>
<div class="block">Returns the boolean value at the specified position.
If the value at the specified position is <code>JsonValue.TRUE</code>
this method returns <code>true</code>. If the value at the specified position
is <code>JsonValue.FALSE</code> this method returns <code>false</code>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>index</code> - index of the JSON boolean value</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the boolean value at the specified position</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IndexOutOfBoundsException</code> - if the index is out of range</dd>
<dd><code>java.lang.ClassCastException</code> - if the value at the specified position is not
<code>JsonValue.TRUE</code> or <code>JsonValue.FALSE</code></dd>
</dl>
</li>
</ul>
<a name="getBoolean-int-boolean-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getBoolean</h4>
<pre>boolean&nbsp;getBoolean(int&nbsp;index,
boolean&nbsp;defaultValue)</pre>
<div class="block">Returns the boolean value at the specified position.
If the value at the specified position is <code>JsonValue.TRUE</code>
this method returns <code>true</code>. If the value at the specified position
is <code>JsonValue.FALSE</code> this method returns <code>false</code>.
Otherwise this method returns the specified default value.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>index</code> - index of the JSON boolean value</dd>
<dd><code>defaultValue</code> - the boolean value to return if the <code>JsonValue</code>
at the specified position is neither TRUE nor FALSE</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the boolean value at the specified position,
or the specified default value</dd>
</dl>
</li>
</ul>
<a name="isNull-int-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>isNull</h4>
<pre>boolean&nbsp;isNull(int&nbsp;index)</pre>
<div class="block">Returns <code>true</code> if the value at the specified location in this
array is <code>JsonValue.NULL</code>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>index</code> - index of the JSON null value</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>return true if the value at the specified location is
<code>JsonValue.NULL</code>, otherwise false</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IndexOutOfBoundsException</code> - if the index is out of range</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="../../jakarta/json/Json.html" title="class in jakarta.json"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../jakarta/json/JsonArrayBuilder.html" title="interface in jakarta.json"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../index.html?jakarta/json/JsonArray.html" target="_top">Frames</a></li>
<li><a href="JsonArray.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>Nested&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>