/**
  * Returns true if the given key is valid for the
  *
  * @link{TabularType} of this instance.
  * @return true if the key is valid.
  * @throws NullPointerException if <code>key</code> is null.
  */
 private boolean isKeyValid(Object[] key) {
   Iterator<String> it = tabularType.getIndexNames().iterator();
   CompositeType rowType = tabularType.getRowType();
   for (int a = 0; it.hasNext(); ++a) {
     OpenType<?> type = rowType.getType(it.next());
     if (!(type.isValue(key[a]))) return false;
   }
   return true;
 }
 /**
  * Calculates the index the specified {@link CompositeData} value would have, if it was to be
  * added to this {@link TabularData} instance. This method includes a check that the type of the
  * given value is the same as the row type of this instance, but not a check for existing
  * instances of the given value. The value must also not be <code>null</code>. Possible indices
  * are selected by the {@link TabularType#getIndexNames()} method of this instance's tabular type.
  * The returned indices are the values of the fields in the supplied {@link CompositeData}
  * instance that match the names given in the {@link TabularType}.
  *
  * @param val the {@link CompositeData} value whose index should be calculated.
  * @return the index the value would take on, if it were to be added.
  * @throws NullPointerException if the value is <code>null</code>.
  * @throws InvalidOpenTypeException if the value does not match the row type of this instance.
  */
 public Object[] calculateIndex(CompositeData val) {
   if (!(val.getCompositeType().equals(tabularType.getRowType())))
     throw new InvalidOpenTypeException(
         "The type of the given value " + "does not match the row type " + "of this instance.");
   List<String> indexNames = tabularType.getIndexNames();
   List<String> matchingIndicies = new ArrayList<String>(indexNames.size());
   for (String name : indexNames) matchingIndicies.add(val.get(name).toString());
   return matchingIndicies.toArray();
 }
 /**
  * Returns the hash code of the composite data type. This is computed as the sum of the hash codes
  * of each value, together with the hash code of the tabular type. These are the same elements of
  * the type that are compared as part of the {@link #equals(java.lang.Object)} method, thus
  * ensuring that the hashcode is compatible with the equality test.
  *
  * @return the hash code of this instance.
  */
 public int hashCode() {
   return tabularType.hashCode() + dataMap.values().hashCode();
 }
 /**
  * Compares the specified object with this object for equality. The object is judged equivalent if
  * it is non-null, and also an instance of {@link TabularData} with the same row type, and {@link
  * CompositeData} values. The two compared instances may be equivalent even if they represent
  * different implementations of {@link TabularData}.
  *
  * @param obj the object to compare for equality.
  * @return true if <code>obj</code> is equal to <code>this</code>.
  */
 public boolean equals(Object obj) {
   if (!(obj instanceof TabularData)) return false;
   TabularData data = (TabularData) obj;
   return tabularType.equals(data.getTabularType()) && dataMap.values().equals(data.values());
 }
 /**
  * Returns true iff this instance of the {@link TabularData} class contains the specified {@link
  * CompositeData} value. In any other circumstance, including if the given value is <code>null
  * </code> or of the incorrect type, according to the {@link TabularType} of this instance, this
  * method returns false.
  *
  * @param val the value to test for.
  * @return true if the value exists.
  */
 public boolean containsValue(CompositeData val) {
   if (val == null) return false;
   if (!(val.getCompositeType().equals(tabularType.getRowType()))) return false;
   return dataMap.containsValue(val);
 }