jdk/src/share/classes/javax/management/openmbean/TabularDataSupport.java
author sherman
Tue, 30 Aug 2011 11:53:11 -0700
changeset 10419 12c063b39232
parent 5506 202f599c92aa
child 14342 8435a30053c1
permissions -rw-r--r--
7084245: Update usages of InternalError to use exception chaining Summary: to use new InternalError constructor with cause chainning Reviewed-by: alanb, ksrini, xuelei, neugens Contributed-by: sebastian.sickelmann@gmx.de
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1510
diff changeset
     2
 * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1510
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1510
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1510
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1510
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1510
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
package javax.management.openmbean;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
// java import
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
//
1018
9f07e65e9653 6334663: TabularDataSupport should be able to return values in the insertion order
emcmanus
parents: 2
diff changeset
    32
import com.sun.jmx.mbeanserver.GetPropertyAction;
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
    33
import com.sun.jmx.mbeanserver.Util;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.io.Serializable;
1018
9f07e65e9653 6334663: TabularDataSupport should be able to return values in the insertion order
emcmanus
parents: 2
diff changeset
    37
import java.security.AccessController;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.util.Arrays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.util.Collection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.util.Collections;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.util.Iterator;
1018
9f07e65e9653 6334663: TabularDataSupport should be able to return values in the insertion order
emcmanus
parents: 2
diff changeset
    44
import java.util.LinkedHashMap;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import java.util.Set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
// jmx import
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * The <tt>TabularDataSupport</tt> class is the <i>open data</i> class which implements the <tt>TabularData</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * and the <tt>Map</tt> interfaces, and which is internally based on a hash map data structure.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
/* It would make much more sense to implement
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
   Map<List<?>,CompositeData> here, but unfortunately we cannot for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
   compatibility reasons.  If we did that, then we would have to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
   define e.g.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
   CompositeData remove(Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
   instead of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
   Object remove(Object).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
   That would mean that if any existing code subclassed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
   TabularDataSupport and overrode
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
   Object remove(Object),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
   it would (a) no longer compile and (b) not actually override
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
   CompositeData remove(Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
   in binaries compiled before the change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
public class TabularDataSupport
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    implements TabularData, Map<Object,Object>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
               Cloneable, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /* Serial version */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    static final long serialVersionUID = 5720150593236309827L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @serial This tabular data instance's contents: a {@link HashMap}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     */
1018
9f07e65e9653 6334663: TabularDataSupport should be able to return values in the insertion order
emcmanus
parents: 2
diff changeset
    86
    // field cannot be final because of clone method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    private Map<Object,CompositeData> dataMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @serial This tabular data instance's tabular type
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     */
1018
9f07e65e9653 6334663: TabularDataSupport should be able to return values in the insertion order
emcmanus
parents: 2
diff changeset
    92
    private final TabularType tabularType;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * The array of item names that define the index used for rows (convenience field)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    private transient String[] indexNamesArray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    /* *** Constructors *** */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * Creates an empty <tt>TabularDataSupport</tt> instance whose open-type is <var>tabularType</var>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * and whose underlying <tt>HashMap</tt> has a default initial capacity (101) and default load factor (0.75).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * This constructor simply calls <tt>this(tabularType, 101, 0.75f);</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @param  tabularType               the <i>tabular type</i> describing this <tt>TabularData</tt> instance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     *                                   cannot be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @throws IllegalArgumentException  if the tabular type is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public TabularDataSupport(TabularType tabularType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
1018
9f07e65e9653 6334663: TabularDataSupport should be able to return values in the insertion order
emcmanus
parents: 2
diff changeset
   117
        this(tabularType, 16, 0.75f);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * Creates an empty <tt>TabularDataSupport</tt> instance whose open-type is <var>tabularType</var>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * and whose underlying <tt>HashMap</tt> has the specified initial capacity and load factor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @param  tabularType               the <i>tabular type</i> describing this <tt>TabularData</tt> instance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *                           cannot be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @param  initialCapacity   the initial capacity of the HashMap.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @param  loadFactor        the load factor of the HashMap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @throws IllegalArgumentException  if the initial capacity is less than zero,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *                                   or the load factor is nonpositive,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *                                   or the tabular type is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    public TabularDataSupport(TabularType tabularType, int initialCapacity, float loadFactor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        // Check tabularType is not null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        if (tabularType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            throw new IllegalArgumentException("Argument tabularType cannot be null.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        // Initialize this.tabularType (and indexNamesArray for convenience)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        this.tabularType = tabularType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        List<String> tmpNames = tabularType.getIndexNames();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        this.indexNamesArray = tmpNames.toArray(new String[tmpNames.size()]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
1018
9f07e65e9653 6334663: TabularDataSupport should be able to return values in the insertion order
emcmanus
parents: 2
diff changeset
   149
        // Since LinkedHashMap was introduced in SE 1.4, it's conceivable even
9f07e65e9653 6334663: TabularDataSupport should be able to return values in the insertion order
emcmanus
parents: 2
diff changeset
   150
        // if very unlikely that we might be the server of a 1.3 client.  In
9f07e65e9653 6334663: TabularDataSupport should be able to return values in the insertion order
emcmanus
parents: 2
diff changeset
   151
        // that case you'll need to set this property.  See CR 6334663.
9f07e65e9653 6334663: TabularDataSupport should be able to return values in the insertion order
emcmanus
parents: 2
diff changeset
   152
        String useHashMapProp = AccessController.doPrivileged(
9f07e65e9653 6334663: TabularDataSupport should be able to return values in the insertion order
emcmanus
parents: 2
diff changeset
   153
                new GetPropertyAction("jmx.tabular.data.hash.map"));
9f07e65e9653 6334663: TabularDataSupport should be able to return values in the insertion order
emcmanus
parents: 2
diff changeset
   154
        boolean useHashMap = "true".equalsIgnoreCase(useHashMapProp);
9f07e65e9653 6334663: TabularDataSupport should be able to return values in the insertion order
emcmanus
parents: 2
diff changeset
   155
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        // Construct the empty contents HashMap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        //
1018
9f07e65e9653 6334663: TabularDataSupport should be able to return values in the insertion order
emcmanus
parents: 2
diff changeset
   158
        this.dataMap = useHashMap ?
9f07e65e9653 6334663: TabularDataSupport should be able to return values in the insertion order
emcmanus
parents: 2
diff changeset
   159
            new HashMap<Object,CompositeData>(initialCapacity, loadFactor) :
9f07e65e9653 6334663: TabularDataSupport should be able to return values in the insertion order
emcmanus
parents: 2
diff changeset
   160
            new LinkedHashMap<Object, CompositeData>(initialCapacity, loadFactor);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    /* *** TabularData specific information methods *** */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * Returns the <i>tabular type</i> describing this <tt>TabularData</tt> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public TabularType getTabularType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        return tabularType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * Calculates the index that would be used in this <tt>TabularData</tt> instance to refer to the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * composite data <var>value</var> parameter if it were added to this instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * This method checks for the type validity of the specified <var>value</var>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * but does not check if the calculated index is already used to refer to a value in this <tt>TabularData</tt> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * @param  value                      the composite data value whose index in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *                                    <tt>TabularData</tt> instance is to be calculated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *                                    must be of the same composite type as this instance's row type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     *                                    must not be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @return the index that the specified <var>value</var> would have in this <tt>TabularData</tt> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @throws NullPointerException       if <var>value</var> is <tt>null</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @throws InvalidOpenTypeException   if <var>value</var> does not conform to this <tt>TabularData</tt> instance's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     *                                    row type definition.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public Object[] calculateIndex(CompositeData value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        // Check value is valid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        checkValueType(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        // Return its calculated index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        return internalCalculateIndex(value).toArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    /* *** Content information query methods *** */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * Returns <tt>true</tt> if and only if this <tt>TabularData</tt> instance contains a <tt>CompositeData</tt> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * (ie a row) whose index is the specified <var>key</var>. If <var>key</var> cannot be cast to a one dimension array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * of Object instances, this method simply returns <tt>false</tt>; otherwise it returns the the result of the call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * <tt>this.containsKey((Object[]) key)</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * @param  key  the index value whose presence in this <tt>TabularData</tt> instance is to be tested.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * @return  <tt>true</tt> if this <tt>TabularData</tt> indexes a row value with the specified key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    public boolean containsKey(Object key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        // if key is not an array of Object instances, return false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        Object[] k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            k = (Object[]) key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        } catch (ClassCastException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        return  this.containsKey(k);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * Returns <tt>true</tt> if and only if this <tt>TabularData</tt> instance contains a <tt>CompositeData</tt> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * (ie a row) whose index is the specified <var>key</var>. If <var>key</var> is <tt>null</tt> or does not conform to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * this <tt>TabularData</tt> instance's <tt>TabularType</tt> definition, this method simply returns <tt>false</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @param  key  the index value whose presence in this <tt>TabularData</tt> instance is to be tested.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * @return  <tt>true</tt> if this <tt>TabularData</tt> indexes a row value with the specified key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    public boolean containsKey(Object[] key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        return  ( key == null ? false : dataMap.containsKey(Arrays.asList(key)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * Returns <tt>true</tt> if and only if this <tt>TabularData</tt> instance contains the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * <tt>CompositeData</tt> value. If <var>value</var> is <tt>null</tt> or does not conform to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * this <tt>TabularData</tt> instance's row type definition, this method simply returns <tt>false</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * @param  value  the row value whose presence in this <tt>TabularData</tt> instance is to be tested.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * @return  <tt>true</tt> if this <tt>TabularData</tt> instance contains the specified row value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    public boolean containsValue(CompositeData value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        return dataMap.containsValue(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * Returns <tt>true</tt> if and only if this <tt>TabularData</tt> instance contains the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * @param  value  the row value whose presence in this <tt>TabularData</tt> instance is to be tested.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * @return  <tt>true</tt> if this <tt>TabularData</tt> instance contains the specified row value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    public boolean containsValue(Object value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        return dataMap.containsValue(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * This method simply calls <tt>get((Object[]) key)</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * @throws NullPointerException  if the <var>key</var> is <tt>null</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @throws ClassCastException    if the <var>key</var> is not of the type <tt>Object[]</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @throws InvalidKeyException   if the <var>key</var> does not conform to this <tt>TabularData</tt> instance's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     *                               <tt>TabularType</tt> definition
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    public Object get(Object key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        return get((Object[]) key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * Returns the <tt>CompositeData</tt> value whose index is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * <var>key</var>, or <tt>null</tt> if there is no value mapping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * to <var>key</var>, in this <tt>TabularData</tt> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * @param key the index of the value to get in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * <tt>TabularData</tt> instance; * must be valid with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * <tt>TabularData</tt> instance's row type definition; * must not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * @return the value corresponding to <var>key</var>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * @throws NullPointerException  if the <var>key</var> is <tt>null</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * @throws InvalidKeyException   if the <var>key</var> does not conform to this <tt>TabularData</tt> instance's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     *                               <tt>TabularType</tt> type definition.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    public CompositeData get(Object[] key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        // Check key is not null and valid with tabularType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        // (throws NullPointerException, InvalidKeyException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        checkKeyType(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        // Return the mapping stored in the parent HashMap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        return dataMap.get(Arrays.asList(key));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    /* *** Content modification operations (one element at a time) *** */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * This method simply calls <tt>put((CompositeData) value)</tt> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * therefore ignores its <var>key</var> parameter which can be <tt>null</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @param key an ignored parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * @param value the {@link CompositeData} to put.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * @return the value which is put
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * @throws NullPointerException  if the <var>value</var> is <tt>null</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * @throws ClassCastException if the <var>value</var> is not of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * the type <tt>CompositeData</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * @throws InvalidOpenTypeException if the <var>value</var> does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * not conform to this <tt>TabularData</tt> instance's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * <tt>TabularType</tt> definition
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * @throws KeyAlreadyExistsException if the key for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * <var>value</var> parameter, calculated according to this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * <tt>TabularData</tt> instance's <tt>TabularType</tt> definition
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * already maps to an existing value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    public Object put(Object key, Object value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        internalPut((CompositeData) value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        return value; // should be return internalPut(...); (5090566)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    public void put(CompositeData value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        internalPut(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    private CompositeData internalPut(CompositeData value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        // Check value is not null, value's type is the same as this instance's row type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        // and calculate the value's index according to this instance's tabularType and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        // check it is not already used for a mapping in the parent HashMap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        List<?> index = checkValueAndIndex(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        // store the (key, value) mapping in the dataMap HashMap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        return dataMap.put(index, value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * This method simply calls <tt>remove((Object[]) key)</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * @param key an <tt>Object[]</tt> representing the key to remove.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * @return previous value associated with specified key, or <tt>null</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     *         if there was no mapping for key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * @throws NullPointerException  if the <var>key</var> is <tt>null</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * @throws ClassCastException    if the <var>key</var> is not of the type <tt>Object[]</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * @throws InvalidKeyException   if the <var>key</var> does not conform to this <tt>TabularData</tt> instance's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     *                               <tt>TabularType</tt> definition
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    public Object remove(Object key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        return remove((Object[]) key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * Removes the <tt>CompositeData</tt> value whose index is <var>key</var> from this <tt>TabularData</tt> instance,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * and returns the removed value, or returns <tt>null</tt> if there is no value whose index is <var>key</var>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * @param  key  the index of the value to get in this <tt>TabularData</tt> instance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     *              must be valid with this <tt>TabularData</tt> instance's row type definition;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     *              must not be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * @return previous value associated with specified key, or <tt>null</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     *         if there was no mapping for key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * @throws NullPointerException  if the <var>key</var> is <tt>null</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * @throws InvalidKeyException   if the <var>key</var> does not conform to this <tt>TabularData</tt> instance's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     *                               <tt>TabularType</tt> definition
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    public CompositeData remove(Object[] key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        // Check key is not null and valid with tabularType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        // (throws NullPointerException, InvalidKeyException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        checkKeyType(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        // Removes the (key, value) mapping in the parent HashMap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        return dataMap.remove(Arrays.asList(key));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    /* ***   Content modification bulk operations   *** */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * Add all the values contained in the specified map <var>t</var>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * to this <tt>TabularData</tt> instance.  This method converts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * the collection of values contained in this map into an array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * <tt>CompositeData</tt> values, if possible, and then call the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * method <tt>putAll(CompositeData[])</tt>. Note that the keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * used in the specified map <var>t</var> are ignored. This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * allows, for example to add the content of another
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * <tt>TabularData</tt> instance with the same row type (but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * possibly different index names) into this instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * @param t the map whose values are to be added as new rows to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * this <tt>TabularData</tt> instance; if <var>t</var> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * <tt>null</tt> or empty, this method returns without doing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * anything.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * @throws NullPointerException if a value in <var>t</var> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * <tt>null</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * @throws ClassCastException if a value in <var>t</var> is not an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * instance of <tt>CompositeData</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * @throws InvalidOpenTypeException if a value in <var>t</var>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * does not conform to this <tt>TabularData</tt> instance's row
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * type definition.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * @throws KeyAlreadyExistsException if the index for a value in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * <var>t</var>, calculated according to this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * <tt>TabularData</tt> instance's <tt>TabularType</tt> definition
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * already maps to an existing value in this instance, or two
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * values in <var>t</var> have the same index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    public void putAll(Map<?,?> t) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        // if t is null or empty, just return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        if ( (t == null) || (t.size() == 0) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        // Convert the values in t into an array of <tt>CompositeData</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        CompositeData[] values;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            values =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                t.values().toArray(new CompositeData[t.size()]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        } catch (java.lang.ArrayStoreException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            throw new ClassCastException("Map argument t contains values which are not instances of <tt>CompositeData</tt>");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        // Add the array of values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        putAll(values);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * Add all the elements in <var>values</var> to this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * <tt>TabularData</tt> instance.  If any element in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * <var>values</var> does not satisfy the constraints defined in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * {@link #put(CompositeData) <tt>put</tt>}, or if any two
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * elements in <var>values</var> have the same index calculated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * according to this <tt>TabularData</tt> instance's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * <tt>TabularType</tt> definition, then an exception describing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * the failure is thrown and no element of <var>values</var> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * added, thus leaving this <tt>TabularData</tt> instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * unchanged.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * @param values the array of composite data values to be added as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * new rows to this <tt>TabularData</tt> instance; if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * <var>values</var> is <tt>null</tt> or empty, this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * returns without doing anything.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * @throws NullPointerException if an element of <var>values</var>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * is <tt>null</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * @throws InvalidOpenTypeException if an element of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * <var>values</var> does not conform to this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * <tt>TabularData</tt> instance's row type definition (ie its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * <tt>TabularType</tt> definition)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * @throws KeyAlreadyExistsException if the index for an element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * of <var>values</var>, calculated according to this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * <tt>TabularData</tt> instance's <tt>TabularType</tt> definition
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * already maps to an existing value in this instance, or two
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * elements of <var>values</var> have the same index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    public void putAll(CompositeData[] values) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        // if values is null or empty, just return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        if ( (values == null) || (values.length == 0) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        // create the list of indexes corresponding to each value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        List<List<?>> indexes =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            new ArrayList<List<?>>(values.length + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        // Check all elements in values and build index list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        List<?> index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        for (int i=0; i<values.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            // check value and calculate index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
            index = checkValueAndIndex(values[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
            // check index is different of those previously calculated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
            if (indexes.contains(index)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
                throw new KeyAlreadyExistsException("Argument elements values["+ i +"] and values["+ indexes.indexOf(index) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                                                    "] have the same indexes, "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                                                    "calculated according to this TabularData instance's tabularType.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
            // add to index list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
            indexes.add(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        // store all (index, value) mappings in the dataMap HashMap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        for (int i=0; i<values.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            dataMap.put(indexes.get(i), values[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * Removes all rows from this <code>TabularDataSupport</code> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    public void clear() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        dataMap.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    /* ***  Informational methods from java.util.Map  *** */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * Returns the number of rows in this <code>TabularDataSupport</code> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * @return the number of rows in this <code>TabularDataSupport</code> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    public int size() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        return dataMap.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * Returns <tt>true</tt> if this <code>TabularDataSupport</code> instance contains no rows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * @return <tt>true</tt> if this <code>TabularDataSupport</code> instance contains no rows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    public boolean isEmpty() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        return (this.size() == 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    /* ***  Collection views from java.util.Map  *** */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * Returns a set view of the keys contained in the underlying map of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * {@code TabularDataSupport} instance used to index the rows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * Each key contained in this {@code Set} is an unmodifiable {@code List<?>}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * so the returned set view is a {@code Set<List<?>>} but is declared as a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * {@code Set<Object>} for compatibility reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * The set is backed by the underlying map of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * {@code TabularDataSupport} instance, so changes to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * {@code TabularDataSupport} instance are reflected in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * set, and vice-versa.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * The set supports element removal, which removes the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * row from this {@code TabularDataSupport} instance, via the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * {@link Iterator#remove}, {@link Set#remove}, {@link Set#removeAll},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * {@link Set#retainAll}, and {@link Set#clear} operations. It does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     *  not support the {@link Set#add} or {@link Set#addAll} operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * @return a set view ({@code Set<List<?>>}) of the keys used to index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * the rows of this {@code TabularDataSupport} instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    public Set<Object> keySet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        return dataMap.keySet() ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * Returns a collection view of the rows contained in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * {@code TabularDataSupport} instance. The returned {@code Collection}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * is a {@code Collection<CompositeData>} but is declared as a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * {@code Collection<Object>} for compatibility reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * The returned collection can be used to iterate over the values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * The collection is backed by the underlying map, so changes to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * {@code TabularDataSupport} instance are reflected in the collection,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * and vice-versa.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     * The collection supports element removal, which removes the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * index to row mapping from this {@code TabularDataSupport} instance, via
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     * the {@link Iterator#remove}, {@link Collection#remove},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     * {@link Collection#removeAll}, {@link Collection#retainAll},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     * and {@link Collection#clear} operations. It does not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * the {@link Collection#add} or {@link Collection#addAll} operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * @return a collection view ({@code Collection<CompositeData>}) of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * the values contained in this {@code TabularDataSupport} instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    @SuppressWarnings("unchecked")  // historical confusion about the return type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    public Collection<Object> values() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   615
        return Util.cast(dataMap.values());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * Returns a collection view of the index to row mappings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * contained in this {@code TabularDataSupport} instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * Each element in the returned collection is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * a {@code Map.Entry<List<?>,CompositeData>} but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * is declared as a {@code Map.Entry<Object,Object>}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * for compatibility reasons. Each of the map entry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * keys is an unmodifiable {@code List<?>}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * The collection is backed by the underlying map of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * {@code TabularDataSupport} instance, so changes to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     * {@code TabularDataSupport} instance are reflected in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * the collection, and vice-versa.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * The collection supports element removal, which removes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * the corresponding mapping from the map, via the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * {@link Iterator#remove}, {@link Collection#remove},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * {@link Collection#removeAll}, {@link Collection#retainAll},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     * and {@link Collection#clear} operations. It does not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * the {@link Collection#add} or {@link Collection#addAll}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     * operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     * <b>IMPORTANT NOTICE</b>: Do not use the {@code setValue} method of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * {@code Map.Entry} elements contained in the returned collection view.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * Doing so would corrupt the index to row mappings contained in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * {@code TabularDataSupport} instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     * @return a collection view ({@code Set<Map.Entry<List<?>,CompositeData>>})
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * of the mappings contained in this map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     * @see java.util.Map.Entry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    @SuppressWarnings("unchecked")  // historical confusion about the return type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    public Set<Map.Entry<Object,Object>> entrySet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   651
        return Util.cast(dataMap.entrySet());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    /* ***  Commodity methods from java.lang.Object  *** */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     * Returns a clone of this <code>TabularDataSupport</code> instance:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     * the clone is obtained by calling <tt>super.clone()</tt>, and then cloning the underlying map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     * Only a shallow clone of the underlying map is made, i.e. no cloning of the indexes and row values is made as they are immutable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    /* We cannot use covariance here and return TabularDataSupport
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
       because this would fail with existing code that subclassed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
       TabularDataSupport and overrode Object clone().  It would not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
       override the new clone().  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    public Object clone() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
            TabularDataSupport c = (TabularDataSupport) super.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
            c.dataMap = new HashMap<Object,CompositeData>(c.dataMap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
            return c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        catch (CloneNotSupportedException e) {
10419
12c063b39232 7084245: Update usages of InternalError to use exception chaining
sherman
parents: 5506
diff changeset
   674
            throw new InternalError(e.toString(), e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * Compares the specified <var>obj</var> parameter with this <code>TabularDataSupport</code> instance for equality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     * Returns <tt>true</tt> if and only if all of the following statements are true:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     * <li><var>obj</var> is non null,</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * <li><var>obj</var> also implements the <code>TabularData</code> interface,</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * <li>their tabular types are equal</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * <li>their contents (ie all CompositeData values) are equal.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * This ensures that this <tt>equals</tt> method works properly for <var>obj</var> parameters which are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * different implementations of the <code>TabularData</code> interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     * <br>&nbsp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     * @param  obj  the object to be compared for equality with this <code>TabularDataSupport</code> instance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     * @return  <code>true</code> if the specified object is equal to this <code>TabularDataSupport</code> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        // if obj is null, return false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        if (obj == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
        // if obj is not a TabularData, return false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
        TabularData other;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
            other = (TabularData) obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        } catch (ClassCastException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        // Now, really test for equality between this TabularData implementation and the other:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        // their tabularType should be equal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        if ( ! this.getTabularType().equals(other.getTabularType()) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
        // their contents should be equal:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
        // . same size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        // . values in this instance are in the other (we know there are no duplicate elements possible)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        // (row values comparison is enough, because keys are calculated according to tabularType)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
        if (this.size() != other.size()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        }
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   729
        for (CompositeData value : dataMap.values()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
            if ( ! other.containsValue(value) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        // All tests for equality were successfull
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     * Returns the hash code value for this <code>TabularDataSupport</code> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     * The hash code of a <code>TabularDataSupport</code> instance is the sum of the hash codes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     * of all elements of information used in <code>equals</code> comparisons
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     * (ie: its <i>tabular type</i> and its content, where the content is defined as all the CompositeData values).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     * This ensures that <code> t1.equals(t2) </code> implies that <code> t1.hashCode()==t2.hashCode() </code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
     * for any two <code>TabularDataSupport</code> instances <code>t1</code> and <code>t2</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
     * as required by the general contract of the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
     * {@link Object#hashCode() Object.hashCode()}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     * However, note that another instance of a class implementing the <code>TabularData</code> interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     * may be equal to this <code>TabularDataSupport</code> instance as defined by {@link #equals},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
     * but may have a different hash code if it is calculated differently.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
     * @return  the hash code value for this <code>TabularDataSupport</code> instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
   public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        int result = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        result += this.tabularType.hashCode();
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   763
        for (Object value : values())
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   764
            result += value.hashCode();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
     * Returns a string representation of this <code>TabularDataSupport</code> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     * The string representation consists of the name of this class (ie <code>javax.management.openmbean.TabularDataSupport</code>),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * the string representation of the tabular type of this instance, and the string representation of the contents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * (ie list the key=value mappings as returned by a call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     * <tt>dataMap.</tt>{@link java.util.HashMap#toString() toString()}).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     * @return  a string representation of this <code>TabularDataSupport</code> instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
        return new StringBuilder()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
            .append(this.getClass().getName())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
            .append("(tabularType=")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
            .append(tabularType.toString())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
            .append(",contents=")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
            .append(dataMap.toString())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
            .append(")")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
            .toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    /* *** TabularDataSupport internal utility methods *** */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     * Returns the index for value, assuming value is valid for this <tt>TabularData</tt> instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     * (ie value is not null, and its composite type is equal to row type).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     * The index is a List, and not an array, so that an index.equals(otherIndex) call will actually compare contents,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     * not just the objects references as is done for an array object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     * The returned List is unmodifiable so that once a row has been put into the dataMap, its index cannot be modified,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     * for example by a user that would attempt to modify an index contained in the Set returned by keySet().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
    private List<?> internalCalculateIndex(CompositeData value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
        return Collections.unmodifiableList(Arrays.asList(value.getAll(this.indexNamesArray)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
     * Checks if the specified key is valid for this <tt>TabularData</tt> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     * @throws  NullPointerException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
     * @throws  InvalidOpenTypeException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
    private void checkKeyType(Object[] key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
        // Check key is neither null nor empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        if ( (key == null) || (key.length == 0) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
            throw new NullPointerException("Argument key cannot be null or empty.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        /* Now check key is valid with tabularType index and row type definitions: */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
        // key[] should have the size expected for an index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
        if (key.length != this.indexNamesArray.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
            throw new InvalidKeyException("Argument key's length="+ key.length +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
                                          " is different from the number of item values, which is "+ indexNamesArray.length +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
                                          ", specified for the indexing rows in this TabularData instance.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
        // each element in key[] should be a value for its corresponding open type specified in rowType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
        OpenType<?> keyElementType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        for (int i=0; i<key.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
            keyElementType = tabularType.getRowType().getType(this.indexNamesArray[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
            if ( (key[i] != null) && (! keyElementType.isValue(key[i])) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
                throw new InvalidKeyException("Argument element key["+ i +"] is not a value for the open type expected for "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
                                              "this element of the index, whose name is \""+ indexNamesArray[i] +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
                                              "\" and whose open type is "+ keyElementType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
     * Checks the specified value's type is valid for this <tt>TabularData</tt> instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
     * (ie value is not null, and its composite type is equal to row type).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
     * @throws  NullPointerException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
     * @throws  InvalidOpenTypeException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
    private void checkValueType(CompositeData value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        // Check value is not null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        if (value == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
            throw new NullPointerException("Argument value cannot be null.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        // if value's type is not the same as this instance's row type, throw InvalidOpenTypeException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
        if (!tabularType.getRowType().isValue(value)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
            throw new InvalidOpenTypeException("Argument value's composite type ["+ value.getCompositeType() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
                                               "] is not assignable to "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
                                               "this TabularData instance's row type ["+ tabularType.getRowType() +"].");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
     * Checks if the specified value can be put (ie added) in this <tt>TabularData</tt> instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
     * (ie value is not null, its composite type is equal to row type, and its index is not already used),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
     * and returns the index calculated for this value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
     * The index is a List, and not an array, so that an index.equals(otherIndex) call will actually compare contents,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
     * not just the objects references as is done for an array object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
     * @throws  NullPointerException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
     * @throws  InvalidOpenTypeException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
     * @throws  KeyAlreadyExistsException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
    private List<?> checkValueAndIndex(CompositeData value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        // Check value is valid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        checkValueType(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
        // Calculate value's index according to this instance's tabularType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        // and check it is not already used for a mapping in the parent HashMap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
        List<?> index = internalCalculateIndex(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
        if (dataMap.containsKey(index)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
            throw new KeyAlreadyExistsException("Argument value's index, calculated according to this TabularData "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
                                                "instance's tabularType, already refers to a value in this table.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
        // The check is OK, so return the index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
        return index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
     * Deserializes a {@link TabularDataSupport} from an {@link ObjectInputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    private void readObject(ObjectInputStream in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
            throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
      in.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
      List<String> tmpNames = tabularType.getIndexNames();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
      indexNamesArray = tmpNames.toArray(new String[tmpNames.size()]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
}