コード例 #1
0
 /**
  * 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();
   }
 }
コード例 #2
0
  /**
   * 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();
  }
コード例 #3
0
  /**
   * 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();
  }
コード例 #4
0
  /**
   * 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();
  }
コード例 #5
0
  /**
   * 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();
  }
コード例 #6
0
  /**
   * 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();
  }
コード例 #7
0
  /**
   * 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();
  }
コード例 #8
0
  /**
   * 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();
  }
コード例 #9
0
  /**
   * 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();
  }
コード例 #10
0
  /** 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;
  }