/**
  * Returns the object at row # row
  *
  * @param row the row number
  * @return the object at row # row. if no such object exists - returns null.
  */
 public Object getObject(int row) {
   if (elements.containsKey(row)) {
     return elements.get(row);
   } else {
     return SparseDefaultValues.getDefaultObject();
   }
 }
  /**
   * If the item at pos is a Number, return its short value. Otherwise if the item is a char[] or
   * any other type of Object, convert the item to a String and return its short value.
   *
   * @param row the row number
   * @return the short value of the item at row number row. If no such value exists returns a value
   *     signifying the position is empty, as defined by SparseShortColumn.
   */
  public short getShort(int row) {
    Object obj = elements.get(row);
    if (obj != null && isDataNumeric(row)) {
      return SparseShortColumn.toShort(obj);
    }

    return (short) SparseDefaultValues.getDefaultInt();
  }
  /**
   * If the item at pos is a Number, return its int value. Otherwise if the item is a char[] or any
   * other type of Object, convert the item to a String and return its int value.
   *
   * @param row the row number
   * @return the int value of the item at row # row. If no such value exists returns a value
   *     signifying the position is empty, as defined by SparseIntColumn.
   */
  public int getInt(int row) {
    Object obj = elements.get(row);
    if (obj != null && isDataNumeric(row)) {
      return SparseIntColumn.toInt(obj);
    }

    return SparseDefaultValues.getDefaultInt();
  }
  /**
   * If the item at pos is a Number, return its long value. Otherwise if the item is a char[] or any
   * other type of Object, convert the item to a String and return its long value.
   *
   * @param row the row number
   * @return the long value of the item at row # row. If no such value exists returns a value
   *     signifying the position is empty, as defined by SparseLongColumn.
   */
  public long getLong(int row) {
    Object obj = elements.get(row);
    if (obj != null && isDataNumeric(row)) {
      return SparseLongColumn.toLong(obj);
    }

    return (long) SparseDefaultValues.getDefaultInt();
  }
  /**
   * If the item at pos is a Number, return its double value. Otherwise if the item is a char[] or
   * any other type of Object, convert the item to a String and return its double value by calling
   * Double.parseDouble()
   *
   * @param row the row number
   * @return the double value of the item at row # row. if no such item exists returns a value
   *     signifying the position is empty, as defined by SparseDoubleColumn.
   */
  public double getDouble(int row) {
    Object obj = elements.get(row);
    if (obj != null && isDataNumeric(row)) {
      return SparseDoubleColumn.toDouble(obj);
    }

    return SparseDefaultValues.getDefaultDouble();
  }
  /**
   * If the item at pos is a Number, return its float value. Otherwise if the item is a char[] or
   * any other type of Object, convert the item to a String and return its float value.
   *
   * @param row the row number
   * @return the float value of the item at row # row. if no such item exists or if the data is not
   *     numeric - returns a value signifying the position is empty, as defined by
   *     SparseFloatColumn.
   */
  public float getFloat(int row) {
    Object obj = elements.get(row);
    if (obj != null && isDataNumeric(row)) {
      return SparseFloatColumn.toFloat(obj);
    }

    return (float) SparseDefaultValues.getDefaultDouble();
  }
  /**
   * Retrun the value at row #<code>row</code> as a char.
   *
   * @param row the row number
   * @return the item at row as a char, if no such item exists return a value signifying the
   *     position is empty, as defined by SparseCharColumn.
   */
  public char getChar(int row) {
    Object obj = elements.get(row);
    if (obj != null) {
      return SparseCharColumn.toChar(obj);
    }

    return SparseDefaultValues.getDefaultChar();
  }
  /**
   * Returns the item at pos as a boolean. If the item is a Boolean, return its boolean value,
   * otherwise construct a new Boolean by calling the toString() method on the item and return its
   * boolean value.
   *
   * @param row the row number
   * @return the item as pos as a boolean value. If no such item exists returns false.
   */
  public boolean getBoolean(int row) {
    Object obj = elements.get(row);
    if (obj != null) {
      return SparseBooleanColumn.toBoolean(obj);
    }

    return SparseDefaultValues.getDefaultBoolean();
  }
  /**
   * If the object at row # row is a byte array, returns the first item in the array. else - returns
   * a representation of this object as a bytes array.
   *
   * @param row the row number
   */
  public byte getByte(int row) {
    Object obj = elements.get(row);
    if (obj != null && isDataNumeric(row)) {
      return SparseByteColumn.toByte(obj);
    }

    return SparseDefaultValues.getDefaultByte();
  }
  /**
   * Returns the valid values in rows <codE>begin</code> through <codE>end</code>
   *
   * @param begin row number from to begin retrieving of values
   * @param end last row number in the section from which values are retrieved.
   * @return only valid values from rows no. <code>begin</code> through <codE>end</code>, sorted.
   */
  protected Object[] getValuesInRange(int begin, int end) {

    if (end < begin) {
      Object[] retVal = {};
      return retVal;
    }

    int[] indices = VHashService.getIndicesInRange(begin, end, elements);
    Object[] values = new Object[indices.length];
    for (int i = 0; i < indices.length; i++) {
      values[i] = elements.get(indices[i]);
    }
    toComparableArray(values);

    Arrays.sort(values);
    return values;
  }
  /** Returns the internal representation of this column. */
  public Object getInternal() {
    int max_index = -1;
    Object[] internal = null;
    int[] keys = elements.keys();

    for (int i = 0; i < keys.length; i++) {
      if (keys[i] > max_index) {
        max_index = keys[i];
      }
    }

    internal = new Object[max_index + 1];
    for (int i = 0; i < max_index + 1; i++) {
      internal[i] = SparseDefaultValues.getDefaultObject();
    }

    for (int i = 0; i < keys.length; i++) {
      internal[keys[i]] = elements.get(keys[i]);
    }

    return internal;
  }
 /**
  * Returns the value at row # row, represented as a String.
  *
  * @param row the row number
  * @return a String Object representing the value at row # row. if no such value exists returns
  *     null
  */
 public String getString(int row) {
   Object obj = elements.get(row);
   return SparseStringColumn.toStringObject(obj);
 }
 /**
  * If the item at pos is a char[], return it. Otherwise converts it to a char[] using
  * SparseCharArrayColumn's method.
  *
  * @param row the row number
  * @return the value at row # row represented with a chars array. If no such value exists returns
  *     null.
  */
 public char[] getChars(int row) {
   Object obj = elements.get(row);
   return SparseCharArrayColumn.toCharArray(obj);
 }
 /**
  * If the entry at pos is a byte[], return the byte[], otherwise convert the Object to a byte[] by
  * calling ByteUtils.writeObject()
  *
  * @param row the row number
  * @return the entry at pos as a byte[]. if no such entry exists returns null
  */
 public byte[] getBytes(int row) {
   Object obj = elements.get(row);
   return SparseByteArrayColumn.toByteArray(obj);
 }