sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1406196 - in /sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection: TableColumn.java TreeTable.java
Date Tue, 06 Nov 2012 15:52:15 GMT
Author: desruisseaux
Date: Tue Nov  6 15:52:15 2012
New Revision: 1406196

URL: http://svn.apache.org/viewvc?rev=1406196&view=rev
Log:
Initial draft of a TreeTable interface.

Added:
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
  (with props)
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTable.java
  (with props)

Added: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java?rev=1406196&view=auto
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
(added)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
Tue Nov  6 15:52:15 2012
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.util.collection;
+
+import org.opengis.util.InternationalString;
+
+
+/**
+ * Identifies a column in {@link TreeTable.Node} instances.
+ * Each {@code TableColumn} instance contains the column header and the type of values
+ * for a particular column. {@code TableColumn}s are used for fetching values from nodes
+ * as in the following example:
+ *
+ * {@preformat java
+ *     class CityLocation {
+ *         static final TableColumn<String> CITY_NAME  = new MyColumn<>(String.class);
+ *         static final TableColumn<Float>  LATITUDE   = new MyColumn<>(Float
.class);
+ *         static final TableColumn<Float>  LONGTITUDE = new MyColumn<>(Float
.class);
+ *
+ *         void myMethod(TreeTable.Node myNode) {
+ *             String city      = myNode.getValue(CITY_NAME);
+ *             float  latitude  = myNode.getValue(LATITUDE );
+ *             float  longitude = myNode.getValue(LONGITUDE);
+ *         }
+ *     }
+ * }
+ *
+ * @param <T> Base type of all values in the column identified by this instance.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.3
+ * @version 0.3
+ * @module
+ */
+public interface TableColumn<T> extends CheckedContainer<T> {
+    /**
+     * Returns the text to display as column header.
+     *
+     * @return The text to display as column header.
+     */
+    InternationalString getHeader();
+
+    /**
+     * Returns the base type of all values in any column identified by this {@code TableColumn}
+     * instance.
+     */
+    @Override
+    Class<T> getElementType();
+}

Propchange: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTable.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTable.java?rev=1406196&view=auto
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTable.java
(added)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTable.java
Tue Nov  6 15:52:15 2012
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.util.collection;
+
+import java.util.List;
+
+
+/**
+ * The root of a tree of nodes, together with the definition of table columns.
+ * The {@link #getColumns()} method gives the list of all columns that can be found
+ * in a {@code TreeTable}. Usually some or all of those columns are also available as
+ * {@link TableColumn} constants defined close to the method creating the tree tables.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.3
+ * @version 0.3
+ * @module
+ */
+public interface TreeTable {
+    /**
+     * Returns the table columns, in the order they shall be rendered by default.
+     * This method returns the union of all table columns in every nodes of this
+     * tree. However any {@link Node} instance can return {@code null} for a
+     * particular column if the node doesn't have that column.
+     *
+     * @return The union of all table columns in every tree node.
+     *
+     * @see Node#getValue(TableColumn)
+     */
+    List<TableColumn<?>> getColumns();
+
+    /**
+     * Returns the root node of the tree.
+     *
+     * @return The root node of the tree.
+     */
+    Node getRoot();
+
+    /**
+     * A node in a tree combined with a row in a table. A {@code TreeTable.Node} can be seen
as a
+     * tree node associated to a single {@linkplain #getUserObject() user object} (like ordinary
trees),
+     * augmented with the capability to describe some aspects of the user object in pre-defined
columns.
+     * The list of allowed columns is given by the {@link TreeTable#getColumns()} method.
+     *
+     * <p>The following table summarizes the tree-related and table-related methods:</p>
+     *
+     * <table class="sis">
+     * <tr>
+     *   <th>Tree-related methods</th>
+     *   <th>Table-related methods</th>
+     * </tr>
+     * <tr><td><ul>
+     *   <li>{@link #getParent()}</li>
+     *   <li>{@link #getChildren()}</li>
+     *   <li>{@link #getUserObject()}</li>
+     * </ul></td>
+     * <td><ul>
+     *   <li>{@link #getValue(TableColumn)}</li>
+     *   <li>{@link #setValueAt(TableColumn, Object)}</li>
+     *   <li>{@link #isEditable(TableColumn)}</li>
+     * </ul></td></tr>
+     * </table>
+     *
+     * @author  Martin Desruisseaux (IRD, Geomatys)
+     * @since   0.3 (derived from geotk-3.19)
+     * @version 0.3
+     * @module
+     */
+    public static interface Node {
+        /**
+         * Returns the parent node, or {@code null} if this node is the root of the tree.
+         *
+         * @return The parent, or {@code null} if none.
+         * @category tree
+         */
+        Node getParent();
+
+        /**
+         * Returns the children of this node. The returned list may or may not be modifiable,
at
+         * implementation choice. If the list is modifiable, then it shall be <cite>live</cite>,
+         * i.e. any modification to the returned list are reflected immediately in the tree.
+         *
+         * @return The children, or an empty list if none.
+         * @category tree
+         */
+        List<? extends Node> getChildren();
+
+        /**
+         * Returns the value in the given column, or {@code null} if none.
+         *
+         * @param  <T>    The base type of values in the given column.
+         * @param  column Identifier of the column from which to get the value.
+         * @return The value in the given column, or {@code null} if none.
+         *
+         * @see TreeTable#getColumns()
+         * @category table
+         */
+        <T> T getValue(TableColumn<T> column);
+
+        /**
+         * Sets the value for the given column (optional operation).
+         * The {@link #isEditable(TableColumn)} method can be invoked before this setter
method
+         * for determining if the given column is modifiable.
+         *
+         * @param  <T>    The base type of values in the given column.
+         * @param  column Identifier of the column into which to set the value.
+         * @param  value  The value to set.
+         * @throws UnsupportedOperationException If values in the given column can not be
modified.
+         *
+         * @see TreeTable#getColumns()
+         * @see #isEditable(TableColumn)
+         * @category table
+         */
+        <T> void setValueAt(TableColumn<T> column, T value) throws UnsupportedOperationException;
+
+        /**
+         * Determines whether the specified column is editable.
+         *
+         * @param  column The column to query.
+         * @return {@code true} if the column is editable, {@code false} otherwise.
+         * @category table
+         */
+        boolean isEditable(TableColumn<?> column);
+
+        /**
+         * 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.
+         *
+         * <blockquote><font size="-1"><b>Example:<.b>
+         * If a {@code CityLocation} class is defined as a (<var>city name</var>,
<var>latitude</var>,
+         * <var>longitude</var>) tuple, then a {@code TreeTable.Node} could be
defined to have
+         * 3 columns for the above 3 tuple components, and the user object could be the original
+         * {@code CityLocation} instance.</font></blockquote>
+         *
+         * @return Any object stored at this node by the user, or {@code null} if none.
+         * @category tree
+         */
+        Object getUserObject();
+    }
+}

Propchange: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTable.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message