# Class TransferType<T extends Buffer>

Object
TransferType<T>

Type Parameters:
  `T` - the type of buffer which can be used for transferring data.

All Implemented Interfaces:
  `Serializable`

public final class TransferType<T extends Buffer> extends Object implements Serializable
The type of data used to transfer pixels. Data transfers happen in various `Raster` methods and in `PixelIterator​.createWindow(TransferType)`. The type used for transferring data is not necessarily the same as the type used by the raster for storing data. In particular, `byte` and `short` (both signed and unsigned) are converted to `int` during the transfer.

`Raster` and `PixelIterator` transfer data in `int[]`, `float[]` and `double[]` arrays. Additionally, `PixelIterator` uses also `IntBuffer`, `FloatBuffer` and `DoubleBuffer`.

## Future evolution

This class may be refactored as an enumeration in a future Java version if JEP 301 is implemented.

Since:
  1.0
See Also:
  - `Raster​.getTransferType()`
  - `PixelIterator​.createWindow(TransferType)`
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final TransferType<DoubleBuffer>`
  `DOUBLE`
  Specifies that sample values are transferred as double-precision floating point number.
  `static final TransferType<FloatBuffer>`
  `FLOAT`
  Specifies that sample values are transferred as single-precision floating point number.
  `static final TransferType<IntBuffer>`
  `INT`
  Specifies that sample values are transferred as 32 bits signed integer.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `toString()`
  Returns the name of this enumeration constant.
  `static TransferType<?>`
  `valueOf(int type)`
  Returns the enumeration value for the given `DataBuffer` constant.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### INT

    public static final TransferType<IntBuffer> INT
    Specifies that sample values are transferred as 32 bits signed integer. If the raster stores sample values as `byte` or `short`, the values are cast by a widening conversion before to be transferred. If the raster stores sample values as `float` or `double`, the values are rounded toward 0 before to be transferred.
    See Also:
      - `PixelIterator​.getSample(int)`
      - `PixelIterator​.getPixel(int[])`

  - ### FLOAT

    public static final TransferType<FloatBuffer> FLOAT
    Specifies that sample values are transferred as single-precision floating point number. Values of other types are cast as needed.
    See Also:
      - `PixelIterator​.getSampleFloat(int)`
      - `PixelIterator​.getPixel(float[])`

  - ### DOUBLE

    public static final TransferType<DoubleBuffer> DOUBLE
    Specifies that sample values are transferred as double-precision floating point number. Values of other types are cast as needed. This is the safest transfer type to use when wanting to avoid any precision lost.
    See Also:
      - `PixelIterator​.getSampleDouble(int)`
      - `PixelIterator​.getPixel(double[])`

- ## Method Details

  - ### valueOf

    public static TransferType<?> valueOf(int type)
    Returns the enumeration value for the given `DataBuffer` constant. This method applies the following mapping:
    - If `type` is `DataBuffer​.TYPE_DOUBLE`, returns `DOUBLE`.
    - If `type` is `DataBuffer​.TYPE_FLOAT`, returns `FLOAT`.
    - If `type` is `DataBuffer​.TYPE_INT`, `TYPE_SHORT`, `TYPE_USHORT` or `TYPE_BYTE`, returns `INT`.
    - If `type` is `DataBuffer​.TYPE_UNDEFINED` or any other value, throws `IllegalArgumentException`.
    The `type` argument given to this method is typically the `Raster​.getTransferType()` value.
    Parameters:
      `type` - one of `DataBuffer` constant.
    Returns:
      the enumeration value for the given constant.
    Throws:
      `IllegalArgumentException` - if (@code type} is not a supported `DataBuffer` constant.

  - ### toString

    public String toString()
    Returns the name of this enumeration constant.
    Overrides:
      `toString` in class `Object`
    Returns:
      the enumeration constant name.