| <!DOCTYPE HTML> |
| <html lang="en"> |
| <head> |
| <!-- Generated by javadoc (21) on Thu Oct 05 19:54:57 CEST 2023 --> |
| <title>TreeTable.Node (Apache SIS 1.4 API)</title> |
| <meta name="viewport" content="width=device-width, initial-scale=1"> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <meta name="dc.created" content="2023-10-05"> |
| <meta name="description" content="declaration: module: org.apache.sis.util, package: org.apache.sis.util.collection, interface: TreeTable, interface: Node"> |
| <meta name="generator" content="javadoc/ClassWriterImpl"> |
| <meta name="keywords" content="org.apache.sis.util.collection.TreeTable.Node interface"> |
| <meta name="keywords" content="getParent()"> |
| <meta name="keywords" content="isLeaf()"> |
| <meta name="keywords" content="getChildren()"> |
| <meta name="keywords" content="newChild()"> |
| <meta name="keywords" content="getValue()"> |
| <meta name="keywords" content="setValue()"> |
| <meta name="keywords" content="isEditable()"> |
| <meta name="keywords" content="getUserObject()"> |
| <meta name="keywords" content="equals()"> |
| <meta name="keywords" content="hashCode()"> |
| <link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style"> |
| <link rel="stylesheet" type="text/css" href="../../../../../../sis.css" title="Style"> |
| <link rel="stylesheet" type="text/css" href="../../../../../../script-dir/jquery-ui.min.css" title="Style"> |
| <script type="text/javascript" src="../../../../../../script.js"></script> |
| <script type="text/javascript" src="../../../../../../script-dir/jquery-3.6.1.min.js"></script> |
| <script type="text/javascript" src="../../../../../../script-dir/jquery-ui.min.js"></script> |
| </head> |
| <body class="class-declaration-page"> |
| <script type="text/javascript">var pathtoroot = "../../../../../../"; |
| loadScripts(document, 'script');</script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| <div class="flex-box"> |
| <header role="banner" class="flex-header"> |
| <nav role="navigation"> |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="top-nav" id="navbar-top"><button id="navbar-toggle-button" aria-controls="navbar-top" aria-expanded="false" aria-label="Toggle navigation links"><span class="nav-bar-toggle-icon"> </span><span class="nav-bar-toggle-icon"> </span><span class="nav-bar-toggle-icon"> </span></button> |
| <div class="skip-nav"><a href="#skip-navbar-top" title="Skip navigation links">Skip navigation links</a></div> |
| <ul id="navbar-top-firstrow" class="nav-list" title="Navigation"> |
| <li><a href="../../../../../../index.html">Overview</a></li> |
| <li><a href="../../../../../module-summary.html">Module</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="nav-bar-cell1-rev">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#class">Help</a></li> |
| </ul> |
| <ul class="sub-nav-list-small"> |
| <li> |
| <p>Summary:</p> |
| <ul> |
| <li>Nested</li> |
| <li>Field</li> |
| <li>Constr</li> |
| <li><a href="#method-summary">Method</a></li> |
| </ul> |
| </li> |
| <li> |
| <p>Detail:</p> |
| <ul> |
| <li>Field</li> |
| <li>Constr</li> |
| <li><a href="#method-detail">Method</a></li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| <div class="sub-nav"> |
| <div id="navbar-sub-list"> |
| <ul class="sub-nav-list"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li>Constr | </li> |
| <li><a href="#method-summary">Method</a></li> |
| </ul> |
| <ul class="sub-nav-list"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li>Constr | </li> |
| <li><a href="#method-detail">Method</a></li> |
| </ul> |
| </div> |
| <div class="nav-list-search"><a href="../../../../../../search.html">SEARCH</a> |
| <input type="text" id="search-input" disabled placeholder="Search"> |
| <input type="reset" id="reset-button" disabled value="reset"> |
| </div> |
| </div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| <span class="skip-nav" id="skip-navbar-top"></span></nav> |
| </header> |
| <div class="flex-content"> |
| <main role="main"> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <div class="header"> |
| <div class="sub-title"><span class="module-label-in-type">Module</span> <a href="../../../../../module-summary.html">org.apache.sis.util</a></div> |
| <div class="sub-title"><span class="package-label-in-type">Package</span> <a href="package-summary.html">org.apache.sis.util.collection</a></div> |
| <h1 title="Interface TreeTable.Node" class="title">Interface TreeTable.Node</h1> |
| </div> |
| <section class="class-description" id="class-description"> |
| <dl class="notes"> |
| <dt>All Known Implementing Classes:</dt> |
| <dd><code><a href="DefaultTreeTable.Node.html" title="class in org.apache.sis.util.collection">DefaultTreeTable.Node</a></code></dd> |
| </dl> |
| <dl class="notes"> |
| <dt>Enclosing interface:</dt> |
| <dd><code><a href="TreeTable.html" title="interface in org.apache.sis.util.collection">TreeTable</a></code></dd> |
| </dl> |
| <hr> |
| <div class="type-signature"><span class="modifiers">public static interface </span><span class="element-name type-name-label">TreeTable.Node</span></div> |
| <div class="block">A node in a tree combined with a row in a table. A <code>TreeTable.Node</code> can be seen as a |
| tree node associated to a single <a href="#getUserObject()">user object</a> (like ordinary trees), |
| augmented with the capability to describe some aspects of the user object in predefined columns. |
| The list of allowed columns is given by the <a href="TreeTable.html#getColumns()"><code>TreeTable.getColumns()</code></a> method. |
| |
| <p>The following table summarizes the tree-related and table-related methods:</p> |
| |
| <table class="sis"> |
| <caption>Tree-table methods</caption> |
| <tr> |
| <th>Tree-related methods</th> |
| <th>Table-related methods</th> |
| </tr> |
| <tr><td><ul> |
| <li><a href="#getParent()"><code>getParent()</code></a></li> |
| <li><a href="#getChildren()"><code>getChildren()</code></a></li> |
| <li><a href="#newChild()"><code>newChild()</code></a></li> |
| </ul></td> |
| <td><ul> |
| <li><a href="#getValue(org.apache.sis.util.collection.TableColumn)"><code>getValue(TableColumn)</code></a></li> |
| <li><a href="#setValue(org.apache.sis.util.collection.TableColumn,V)"><code>setValue(TableColumn, Object)</code></a></li> |
| <li><a href="#isEditable(org.apache.sis.util.collection.TableColumn)"><code>isEditable(TableColumn)</code></a></li> |
| </ul></td></tr> |
| </table> |
| |
| In addition, each <code>Node</code> can be associated to an arbitrary object by the |
| <a href="#getUserObject()"><code>getUserObject()</code></a> method. This object is not used directly by the tree tables.</div> |
| <dl class="notes"> |
| <dt>Since:</dt> |
| <dd>0.3</dd> |
| </dl> |
| </section> |
| <section class="summary"> |
| <ul class="summary-list"> |
| <!-- ========== METHOD SUMMARY =========== --> |
| <li> |
| <section class="method-summary" id="method-summary"> |
| <h2>Method Summary</h2> |
| <div id="method-summary-table"> |
| <div class="table-tabs" role="tablist" aria-orientation="horizontal"><button id="method-summary-table-tab0" role="tab" aria-selected="true" aria-controls="method-summary-table.tabpanel" tabindex="0" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table', 3)" class="active-table-tab">All Methods</button><button id="method-summary-table-tab2" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab2', 3)" class="table-tab">Instance Methods</button><button id="method-summary-table-tab3" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab3', 3)" class="table-tab">Abstract Methods</button></div> |
| <div id="method-summary-table.tabpanel" role="tabpanel"> |
| <div class="summary-table three-column-summary" aria-labelledby="method-summary-table-tab0"> |
| <div class="table-header col-first">Modifier and Type</div> |
| <div class="table-header col-second">Method</div> |
| <div class="table-header col-last">Description</div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>boolean</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#equals(java.lang.Object)" class="member-name-link">equals</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a> other)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Returns <code>true</code> if the given object is a node with the same content than this node.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a><wbr><<a href="TreeTable.Node.html" title="interface in org.apache.sis.util.collection">TreeTable.Node</a>></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#getChildren()" class="member-name-link">getChildren</a>()</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Returns the children of this node.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="TreeTable.Node.html" title="interface in org.apache.sis.util.collection">TreeTable.Node</a></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#getParent()" class="member-name-link">getParent</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Returns the parent node, or <code>null</code> if this node is the root of the tree.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#getUserObject()" class="member-name-link">getUserObject</a>()</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Returns the user object associated to this node.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><V> V</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#getValue(org.apache.sis.util.collection.TableColumn)" class="member-name-link">getValue</a><wbr>(<a href="TableColumn.html" title="class in org.apache.sis.util.collection">TableColumn</a><V> column)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Returns the value in the given column, or <code>null</code> if none.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>int</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#hashCode()" class="member-name-link">hashCode</a>()</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Returns a hash code value consistent with the <code>equals(Object)</code> implementation for this node.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>boolean</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#isEditable(org.apache.sis.util.collection.TableColumn)" class="member-name-link">isEditable</a><wbr>(<a href="TableColumn.html" title="class in org.apache.sis.util.collection">TableColumn</a><?> column)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Determines whether the value in the specified column is editable.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>boolean</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#isLeaf()" class="member-name-link">isLeaf</a>()</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Returns <code>true</code> if this node cannot have any children.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="TreeTable.Node.html" title="interface in org.apache.sis.util.collection">TreeTable.Node</a></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#newChild()" class="member-name-link">newChild</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Creates a new child with the same columns than the other children, and adds it to |
| the <a href="#getChildren()">children collection</a>.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><V> void</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#setValue(org.apache.sis.util.collection.TableColumn,V)" class="member-name-link">setValue</a><wbr>(<a href="TableColumn.html" title="class in org.apache.sis.util.collection">TableColumn</a><V> column, |
| V value)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Sets the value for the given column (optional operation).</div> |
| </div> |
| </div> |
| </div> |
| </div> |
| </section> |
| </li> |
| </ul> |
| </section> |
| <section class="details"> |
| <ul class="details-list"> |
| <!-- ============ METHOD DETAIL ========== --> |
| <li> |
| <section class="method-details" id="method-detail"> |
| <h2>Method Details</h2> |
| <ul class="member-list"> |
| <li> |
| <section class="detail" id="getParent()"> |
| <h3>getParent</h3> |
| <div class="member-signature"><span class="return-type"><a href="TreeTable.Node.html" title="interface in org.apache.sis.util.collection">TreeTable.Node</a></span> <span class="element-name">getParent</span>()</div> |
| <div class="block">Returns the parent node, or <code>null</code> if this node is the root of the tree. |
| |
| <p>There is intentionally no <code>setParent(Node)</code> method, as children and parent managements |
| are highly implementation-dependant. If the <a href="#getChildren()">children collection</a> is |
| modifiable, then implementations are encouraged to update automatically the parent when a child |
| is <em>added to</em> or <em>removed from</em> that collection.</p></div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>the parent, or <code>null</code> if none.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="isLeaf()"> |
| <h3>isLeaf</h3> |
| <div class="member-signature"><span class="return-type">boolean</span> <span class="element-name">isLeaf</span>()</div> |
| <div class="block">Returns <code>true</code> if this node cannot have any children. The <a href="#getChildren()">children |
| collection</a> of a leaf node can only be empty, and adding <a href="#newChild()">new child</a> |
| is an unsupported operation. |
| |
| <p>This value is provided as a tip for graphical user interfaces, in order to determine if |
| a node is expandable (even if empty). <a href="TreeTableFormat.html" title="class in org.apache.sis.util.collection"><code>TreeTableFormat</code></a> does not use this value.</p></div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd><code>true</code> if this node cannot have any children.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="getChildren()"> |
| <h3>getChildren</h3> |
| <div class="member-signature"><span class="return-type"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a><<a href="TreeTable.Node.html" title="interface in org.apache.sis.util.collection">TreeTable.Node</a>></span> <span class="element-name">getChildren</span>()</div> |
| <div class="block">Returns the children of this node. The returned collection may or may not be modifiable, at |
| implementation choice. If the collection is modifiable, then it shall be <em>live</em>, |
| i.e. any modification to the returned collection are reflected immediately in the tree. |
| This allows addition or removal of child nodes as below: |
| |
| |
| <div class="snippet-container"><button class="copy snippet-copy" aria-label="Copy snippet" onclick="copySnippet(this)"><span data-copied="Copied!">Copy</span><img src="../../../../../../copy.svg" alt="Copy snippet"></button> |
| <pre class="snippet"><code class="language-java">TreeTable.Node newNode = new ...; // Create a new node here. |
| parent.getChildren().add(newNode); |
| </code></pre> |
| </div> |
| |
| |
| The collection is often a <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link"><code>List</code></a>, but not necessarily. For some implementations like the |
| <a href="../../../../../../org.apache.sis.metadata/org/apache/sis/metadata/AbstractMetadata.html#asTreeTable()">metadata tree table view</a>, |
| compliance to the <code>List</code> contract is impractical or inefficient.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>the children, or an empty collection if none.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="newChild()"> |
| <h3>newChild</h3> |
| <div class="member-signature"><span class="return-type"><a href="TreeTable.Node.html" title="interface in org.apache.sis.util.collection">TreeTable.Node</a></span> <span class="element-name">newChild</span>() |
| throws <span class="exceptions"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/UnsupportedOperationException.html" title="class or interface in java.lang" class="external-link">UnsupportedOperationException</a></span></div> |
| <div class="block">Creates a new child with the same columns than the other children, and adds it to |
| the <a href="#getChildren()">children collection</a>. The new child is typically added at |
| the end of the collection, but this is not mandatory: implementations can add the child |
| at whatever position they see fit.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>the new child.</dd> |
| <dt>Throws:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/UnsupportedOperationException.html" title="class or interface in java.lang" class="external-link">UnsupportedOperationException</a></code> - if this node cannot add new children.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="getValue(org.apache.sis.util.collection.TableColumn)"> |
| <h3>getValue</h3> |
| <div class="member-signature"><span class="type-parameters"><V></span> <span class="return-type">V</span> <span class="element-name">getValue</span><wbr><span class="parameters">(<a href="TableColumn.html" title="class in org.apache.sis.util.collection">TableColumn</a><V> column)</span></div> |
| <div class="block">Returns the value in the given column, or <code>null</code> if none.</div> |
| <dl class="notes"> |
| <dt>Type Parameters:</dt> |
| <dd><code>V</code> - the base type of values in the given column.</dd> |
| <dt>Parameters:</dt> |
| <dd><code>column</code> - identifier of the column from which to get the value.</dd> |
| <dt>Returns:</dt> |
| <dd>the value in the given column, or <code>null</code> if none.</dd> |
| <dt>See Also:</dt> |
| <dd> |
| <ul class="tag-list"> |
| <li><a href="TreeTable.html#getColumns()"><code>TreeTable.getColumns()</code></a></li> |
| </ul> |
| </dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="setValue(org.apache.sis.util.collection.TableColumn,V)"> |
| <h3 id="setValue(org.apache.sis.util.collection.TableColumn,java.lang.Object)">setValue</h3> |
| <div class="member-signature"><span class="type-parameters"><V></span> <span class="return-type">void</span> <span class="element-name">setValue</span><wbr><span class="parameters">(<a href="TableColumn.html" title="class in org.apache.sis.util.collection">TableColumn</a><V> column, |
| V value)</span> |
| throws <span class="exceptions"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a>, |
| <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/UnsupportedOperationException.html" title="class or interface in java.lang" class="external-link">UnsupportedOperationException</a></span></div> |
| <div class="block">Sets the value for the given column (optional operation). |
| The <a href="#isEditable(org.apache.sis.util.collection.TableColumn)"><code>isEditable(TableColumn)</code></a> method can be invoked before this setter method |
| for determining if the given column is modifiable.</div> |
| <dl class="notes"> |
| <dt>Type Parameters:</dt> |
| <dd><code>V</code> - the base type of values in the given column.</dd> |
| <dt>Parameters:</dt> |
| <dd><code>column</code> - identifier of the column into which to set the value.</dd> |
| <dd><code>value</code> - the value to set.</dd> |
| <dt>Throws:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a></code> - if the given column is not a legal column for this node.</dd> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/UnsupportedOperationException.html" title="class or interface in java.lang" class="external-link">UnsupportedOperationException</a></code> - if values in the given column cannot be modified.</dd> |
| <dt>See Also:</dt> |
| <dd> |
| <ul class="tag-list"> |
| <li><a href="TreeTable.html#getColumns()"><code>TreeTable.getColumns()</code></a></li> |
| <li><a href="#isEditable(org.apache.sis.util.collection.TableColumn)"><code>isEditable(TableColumn)</code></a></li> |
| </ul> |
| </dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="isEditable(org.apache.sis.util.collection.TableColumn)"> |
| <h3>isEditable</h3> |
| <div class="member-signature"><span class="return-type">boolean</span> <span class="element-name">isEditable</span><wbr><span class="parameters">(<a href="TableColumn.html" title="class in org.apache.sis.util.collection">TableColumn</a><?> column)</span></div> |
| <div class="block">Determines whether the value in the specified column is editable. If the given |
| column is not a legal column for this <code>Node</code> instance, then this method |
| returns <code>false</code>.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>column</code> - the column to query.</dd> |
| <dt>Returns:</dt> |
| <dd><code>true</code> if the given column is a legal column for this <code>Node</code> |
| implementation and the corresponding value is editable, or <code>false</code> |
| otherwise.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="getUserObject()"> |
| <h3>getUserObject</h3> |
| <div class="member-signature"><span class="return-type"><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></span> <span class="element-name">getUserObject</span>()</div> |
| <div class="block">Returns the user object associated to this node. |
| The user object is for information purpose only and does not appear in the rendered tree. |
| It is typically a Java object whose content is splitted into the various table columns. |
| |
| <h4 id="example-heading">Example</h4> |
| If a <code>CityLocation</code> class is defined as a (<var>city name</var>, <var>latitude</var>, |
| <var>longitude</var>) tuple, then a <code>TreeTable.Node</code> could be defined to have 3 columns for the |
| above 3 tuple components, and the user object could be the original <code>CityLocation</code> instance.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>any object stored at this node by the user, or <code>null</code> if none.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="equals(java.lang.Object)"> |
| <h3>equals</h3> |
| <div class="member-signature"><span class="return-type">boolean</span> <span class="element-name">equals</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a> other)</span></div> |
| <div class="block">Returns <code>true</code> if the given object is a node with the same content than this node. |
| For this method, the meaning of <cite>same content</cite> is defined as below: |
| |
| <ul> |
| <li>The given object is also a <code>Node</code>.</li> |
| <li>The list returned by <a href="TreeTable.html#getColumns()"><code>TreeTable.getColumns()</code></a> is equal for both nodes.</li> |
| <li>The objects returned by <a href="#getValue(org.apache.sis.util.collection.TableColumn)"><code>getValue(TableColumn)</code></a> are equal for each column.</li> |
| <li>The list returned by <a href="#getChildren()">children</a> is equal for both node.</li> |
| </ul> |
| |
| The node returned by <a href="#getParent()"><code>getParent()</code></a> shall <strong>not</strong> be taken in account. |
| It is necessary to ignore the parent for consistency with <a href="DefaultTreeTable.html#clone()">clone</a> |
| and for avoiding infinite recursivity when comparing the children. |
| A third reason is given in the <cite>purpose</cite> example below. |
| |
| <h4 id="purpose-of-this-method-example-with-iso-metadata-heading">Purpose of this method: example with ISO metadata</h4> |
| Consider the following tree made of ISO 19115 metadata objects: a platform containing a list of instruments, |
| and an instrument containing a reference to the platform on which the instrument is installed. In this example, |
| nodes 2 and 4 contain a reference to the same <code>Platform</code> instance, so we have a cyclic graph: |
| |
| <table class="compact"> |
| <caption>Metadata tree example</caption> |
| <tr><th>Node 1:</th><td><code> </code><a href="../../../../../../org.apache.sis.metadata/org/apache/sis/metadata/iso/acquisition/DefaultAcquisitionInformation.html" title="class in org.apache.sis.metadata.iso.acquisition">Acquisition information</a></td></tr> |
| <tr><th>Node 2:</th><td><code> └─</code><a href="../../../../../../org.apache.sis.metadata/org/apache/sis/metadata/iso/acquisition/DefaultPlatform.html" title="class in org.apache.sis.metadata.iso.acquisition">Platform</a></td></tr> |
| <tr><th>Node 3:</th><td><code> └─</code><a href="../../../../../../org.apache.sis.metadata/org/apache/sis/metadata/iso/acquisition/DefaultInstrument.html" title="class in org.apache.sis.metadata.iso.acquisition">Instrument</a></td></tr> |
| <tr><th>Node 4:</th><td><code> └─</code><a href="../../../../../../org.apache.sis.metadata/org/apache/sis/metadata/iso/acquisition/DefaultPlatform.html" title="class in org.apache.sis.metadata.iso.acquisition">Platform</a> (same instance than above)</td></tr> |
| <tr><th>Node 5:</th><td><code> └─</code><i>etc…</i></td></tr> |
| </table> |
| |
| The <a href="../../../../../../org.apache.sis.metadata/org/apache/sis/metadata/AbstractMetadata.html#asTreeTable()"><code>AbstractMetadata.asTreeTable()</code></a> method gives a view in which each node |
| has its content fully generated from wrapped metadata object. Consequently, a naive walk over the above tree |
| causes an infinite loop with <code>TreeTable</code> generating nodes with identical content as we bounce between |
| <code>Platform</code> and <code>Instrument</code> metadata objects. To break this loop, we need to know when the |
| <em>content</em> of a node (in this example, the wrapped metadata object) has already been visited. |
| The parent shall <strong>not</strong> be taken in account since node 2 and 4 have different parents |
| despite having the same <code>Platform</code> content. |
| |
| <p>In this use case, the <code>Node.equals(Object)</code> implementation needs only to compare the wrapped |
| metadata (usually given by the <a href="#getUserObject()">user object</a>) since the node content, |
| including the list of children, is fully determined by those metadata. An identity comparison |
| (with <code>==</code>) is sufficient for the purpose of avoiding infinite recursivity.</p> |
| |
| <h4 id="flexibility-in-implementations-heading">Flexibility in implementations</h4> |
| The above list specifies minimal conditions that must be true when two nodes are considered equal. |
| Implementations should not relax those conditions, but are free to make them more restrictive. |
| In particular, many implementations will require that the two nodes are instances of the same class. |
| Some implementations may also perform identity comparisons (with the <code>==</code> operator) between values |
| instead of using <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang" class="external-link"><code>Object.equals(Object)</code></a>. This flexibility means that even if all above conditions |
| are true, this is not a guarantee that this method will return <code>true</code>. |
| |
| <p>It is okay to <em>not</em> override this method at all since the identity comparison inherited from |
| <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang" class="external-link"><code>Object.equals(Object)</code></a> is consistent with this method contract. Alternatively, <code>Node</code> |
| implementations having a content fully determined by the wrapped <a href="#getUserObject()">user |
| object</a> need only the following implementation:</p> |
| |
| |
| <div class="snippet-container"><button class="copy snippet-copy" aria-label="Copy snippet" onclick="copySnippet(this)"><span data-copied="Copied!">Copy</span><img src="../../../../../../copy.svg" alt="Copy snippet"></button> |
| <pre class="snippet"><code class="language-java"> @Override |
| public boolean equals(Object obj) { |
| return (obj instanceof MyNode) && ((MyNode) obj).getUserObject() == getUserObject(); |
| } |
| </code></pre> |
| </div> |
| |
| |
| Implementation details may vary, for example in the way to compare <code>null</code> user objects or by invoking |
| <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang" class="external-link"><code>Object.equals(Object)</code></a> instead of performing identity comparisons. Note however that since this |
| method purpose is to detect cyclic graphs (see above example), user objects should be compared with |
| <code>equals(Object)</code> only if their implementations are known to be safe against infinite recursivity.</div> |
| <dl class="notes"> |
| <dt>Overrides:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang" class="external-link">equals</a></code> in class <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></code></dd> |
| <dt>Parameters:</dt> |
| <dd><code>other</code> - the other object to compare with this node.</dd> |
| <dt>Returns:</dt> |
| <dd>whether the two objects are nodes with equal values and equal children, ignoring parents.</dd> |
| <dt>Since:</dt> |
| <dd>0.8</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="hashCode()"> |
| <h3>hashCode</h3> |
| <div class="member-signature"><span class="return-type">int</span> <span class="element-name">hashCode</span>()</div> |
| <div class="block">Returns a hash code value consistent with the <code>equals(Object)</code> implementation for this node. |
| If the <a href="#equals(java.lang.Object)"><code>equals(Object)</code></a> method has not been overridden, then this <code>hashCode()</code> method |
| should not be overridden neither. Otherwise if this node content (<a href="#getValue(org.apache.sis.util.collection.TableColumn)">values</a> and |
| <a href="#getChildren()">children</a>) is fully generated from the <a href="#getUserObject()">user |
| object</a>, then the <code>equals(…)</code> and <code>hashCode()</code> methods may be implemented like below: |
| |
| |
| <div class="snippet-container"><button class="copy snippet-copy" aria-label="Copy snippet" onclick="copySnippet(this)"><span data-copied="Copied!">Copy</span><img src="../../../../../../copy.svg" alt="Copy snippet"></button> |
| <pre class="snippet"><code class="language-java"> @Override |
| public boolean equals(Object obj) { |
| return (obj instanceof MyNode) && ((MyNode) obj).getUserObject() == getUserObject(); |
| } |
| |
| @Override |
| public int hashCode() { |
| return System.identityHashCode(getUserObject()); |
| } |
| </code></pre> |
| </div> |
| |
| |
| Otherwise this method should compute a hash code based on values and children of this node, ignoring parent.</div> |
| <dl class="notes"> |
| <dt>Overrides:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#hashCode()" title="class or interface in java.lang" class="external-link">hashCode</a></code> in class <code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></code></dd> |
| <dt>Returns:</dt> |
| <dd>a hash code for this node, potentially based on values and children but ignoring parent.</dd> |
| <dt>Since:</dt> |
| <dd>0.8</dd> |
| </dl> |
| </section> |
| </li> |
| </ul> |
| </section> |
| </li> |
| </ul> |
| </section> |
| <!-- ========= END OF CLASS DATA ========= --> |
| </main> |
| </div> |
| </div> |
| </body> |
| </html> |