Class ArrayVector.ASCII

All Implemented Interfaces:
Serializable, Iterable<Number>, Collection<Number>, List<Number>, RandomAccess, CheckedContainer<Double>
Enclosing class:
ArrayVector<E extends Number>

private static final class ArrayVector.ASCII extends ArrayVector<Double>
A vector backed by an array of type String[]. This is not recommended, but happen for example in GDAL extensions for GeoTIFF files.
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • array

      private final String[] array
      The backing array.
  • Constructor Details

    • ASCII

      ASCII(String[] array)
      Creates a new vector for the given array.
  • Method Details

    • getElementType

      public final Class<Double> getElementType()
      Returns the type of elements in the backing array.
      Specified by:
      getElementType in interface CheckedContainer<Double>
      Specified by:
      getElementType in class Vector
      Returns:
      the type of elements in this vector.
      See Also:
    • isSinglePrecision

      public final boolean isSinglePrecision()
      Returns whether values are convertible to float type.
      Overrides:
      isSinglePrecision in class Vector
      Returns:
      whether values in this vector can be casted to float primitive type.
      See Also:
    • isNaN

      public boolean isNaN(int index)
      Returns true if the element at the given index is null or NaN.
      Overrides:
      isNaN in class ArrayVector<Double>
      Parameters:
      index - the index in the [0 … size-1] range.
      Returns:
      true if the value at the given index is NaN.
    • size

      public int size()
      Description copied from class: Vector
      Returns the number of elements in this vector.
      Specified by:
      size in interface Collection<Number>
      Specified by:
      size in interface List<Number>
      Specified by:
      size in class Vector
      Returns:
      the number of elements in this vector.
    • stringValue

      public String stringValue(int index)
      Description copied from class: Vector
      Returns a string representation of the value at the given index. Invoking this method is generally equivalent to invoking String.valueOf(get(index)) except if the values are unsigned integers.
      Specified by:
      stringValue in class Vector
      Parameters:
      index - the index in the [0 … size-1] range.
      Returns:
      a string representation of the value at the given index (may be null).
      See Also:
    • doubleValue

      public double doubleValue(int index)
      Description copied from class: Vector
      Returns the value at the given index as a double. This is the safest method since all primitive types supported by Vector are convertible to the double type.
      Specified by:
      doubleValue in class Vector
      Parameters:
      index - the index in the [0 … size-1] range.
      Returns:
      the value at the given index.
      See Also:
    • floatValue

      public float floatValue(int index)
      Description copied from class: Vector
      Returns the value at the given index as a float. This method may result in a lost of precision if this vector stores or computes its values with the double type.

      The default implementation delegates to Vector.doubleValue(int) and cast the result to float.

      Overrides:
      floatValue in class Vector
      Parameters:
      index - the index in the [0 … size-1] range.
      Returns:
      the value at the given index.
      See Also:
    • longValue

      public long longValue(int index)
      Description copied from class: Vector
      Returns the value at the given index as a long. If this vector uses floating point values, the value is rounded to the nearest integer.

      The default implementation delegates to Vector.doubleValue(int) and verifies if the result can be rounded to a long with an error not greater than 0.5. Subclasses that store or compute their values with an integer type should override this method.

      Overrides:
      longValue in class Vector
      Parameters:
      index - the index in the [0 … size-1] range.
      Returns:
      the value at the given index.
    • intValue

      public int intValue(int index)
      Description copied from class: Vector
      Returns the value at the given index as an int. If this vector uses floating point values, the value is rounded to the nearest integer.

      The default implementation delegates to Vector.longValue(int) and verifies if the result fits in the int type. Subclasses that store or compute their values with the int, short or byte type should override this method.

      Overrides:
      intValue in class Vector
      Parameters:
      index - the index in the [0 … size-1] range.
      Returns:
      the value at the given index.
    • shortValue

      public short shortValue(int index)
      Description copied from class: Vector
      Returns the value at the given index as a short. If this vector uses floating point values, the value is rounded to the nearest integer.

      The default implementation delegates to Vector.longValue(int) and verifies if the result fits in the short type. Subclasses that store or compute their values with the short or byte type should override this method.

      Overrides:
      shortValue in class Vector
      Parameters:
      index - the index in the [0 … size-1] range.
      Returns:
      the value at the given index.
    • byteValue

      public byte byteValue(int index)
      Description copied from class: Vector
      Returns the value at the given index as a byte. If this vector uses floating point values, the value is rounded to the nearest integer.

      The default implementation delegates to Vector.longValue(int) and verifies if the result fits in the byte type. Subclasses that store or compute their values with the byte type should override this method.

      Overrides:
      byteValue in class Vector
      Parameters:
      index - the index in the [0 … size-1] range.
      Returns:
      the value at the given index.
    • get

      public Number get(int index)
      Description copied from class: Vector
      Returns the number at the given index, or null if none. The object returned by this method is usually an instance of the class returned by Vector.getElementType(), but may also be an instance of a wider type if this is necessary for representing the values.
      Example: if Vector.getElementType() returns Byte.class but Vector.isUnsigned() returns true, then this method will rather return instances of Short because that type is the smallest Java primitive type capable to hold byte values in the [0 … 255] range. But the elements are still stored internally as byte, and the vector cannot accept values outside the [0 … 255] range even if they are valid Short values.
      The class of returned objects should be stable. For example, this method should not use different types for different range of values. This stability is recommended but not guaranteed because Vector can also wrap arbitrary Number[] arrays.
      Specified by:
      get in interface List<Number>
      Specified by:
      get in class Vector
      Parameters:
      index - the index in the [0 … size-1] range.
      Returns:
      the value at the given index (may be null).
    • set

      public final Number set(int index, Number value)
      Stores the given value in this vector and returns the previous value.
      Specified by:
      set in interface List<Number>
      Specified by:
      set in class Vector
      Parameters:
      index - the index in the [0 … size-1] range.
      value - the value to set at the given index.
      Returns:
      the value previously stored at the given index.
    • fill

      public void fill(int fromIndex, int toIndex, Number value)
      Sets the value of all elements in the given range.
      Overrides:
      fill in class Vector
      Parameters:
      fromIndex - index of the first element (inclusive) to be filled with the specified value.
      toIndex - index of the last element (exclusive) to be filled with the specified value.
      value - the value to be stored in elements of the vector.