Package mpi

# Class Struct

java.lang.Object
mpi.Struct

Direct Known Subclasses:
  `DoubleInt`, `FloatInt`, `Int2`, `LongInt`, `ShortInt`

public abstract class Struct extends Object
Base class for defining struct data types.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`class`
`Struct.Data`
Base class for reading/writing data in a struct stored in a byte buffer.

## Constructor Summary

Constructors
Constructor
Description
`Struct()`

## Method Summary

Modifier and Type
Method
Description
`final int`
`addByte()`
Adds a byte field to this struct.
`final int`
`addByte(int length)`
Adds a byte array to this struct.
`final int`
`addChar()`
Adds a char field to this struct.
`final int`
`addChar(int length)`
Adds a char array to this struct.
`final int`
`addData(Datatype type)`
Adds a field of the specified data type.
`final int`
`addData(Datatype type, int length)`
Adds an array of the specified data type.
`final int`
`addDouble()`
Adds a double field to this struct.
`final int`
`addDouble(int length)`
Adds a double array to this struct.
`final int`
`addFloat()`
Adds a float field to this struct.
`final int`
`addFloat(int length)`
Adds a float array to this struct.
`final int`
`addInt()`
Adds an int field to this struct.
`final int`
`addInt(int length)`
Adds an int array to this struct.
`final int`
`addLong()`
Adds a long field to this struct.
`final int`
`addLong(int length)`
Adds a long array to this struct.
`final int`
`addShort()`
Adds a short field to this struct.
`final int`
`addShort(int length)`
Adds a short array to this struct.
`final int`
`addStruct(Struct struct)`
Adds a struct field to this struct.
`final int`
`addStruct(Struct struct, int length)`
Adds an array of structs to this struct.
`final <T extends Struct.Data>
T`
`getData(byte[] array)`
`final <T extends Struct.Data>
T`
`getData(byte[] array, int index)`
`final <T extends Struct.Data>
T`
`getData(ByteBuffer buffer)`
`final <T extends Struct.Data>
T`
`getData(ByteBuffer buffer, int index)`
`final int`
`getExtent()`
Returns the extent of the struct data type.
`final Datatype`
`getType()`
Returns the data type of the struct.
`protected abstract Struct.Data`
`newData()`
Creates a Data object.
`final Struct`
`setOffset(int offset)`
Sets the offset of the next field.

### Methods inherited from class java.lang.Object

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

## Constructor Details

### Struct

public Struct()

## Method Details

### getExtent

public final int getExtent() throws MPIException
Returns the extent of the struct data type.

Returns:
  Extent of the struct data type.
Throws:
  `MPIException` - Signals that an MPI exception of some sort has occurred.

### getType

public final Datatype getType() throws MPIException
Returns the data type of the struct.

Returns:
  The data type of the struct.
Throws:
  `MPIException` - Signals that an MPI exception of some sort has occurred.

### newData

protected abstract Struct.Data newData()
Creates a Data object.

Returns:
  New Data object.

### getData

public final <T extends Struct.Data> T getData(ByteBuffer buffer) throws MPIException

Throws:
  `MPIException`

### getData

public final <T extends Struct.Data> T getData(ByteBuffer buffer, int index) throws MPIException

Throws:
  `MPIException`

### getData

public final <T extends Struct.Data> T getData(byte[] array) throws MPIException

Throws:
  `MPIException`

### getData

public final <T extends Struct.Data> T getData(byte[] array, int index) throws MPIException

Throws:
  `MPIException`

### setOffset

public final Struct setOffset(int offset)
Sets the offset of the next field.

The offset must be greater or equal to the accumulated extent.

Parameters:
  `offset` - offset of the next field
Returns:
  this object in order to allow adding fields in a chained expression

### addByte

public final int addByte()
Adds a byte field to this struct.

Returns:
  Offset of the new field.

### addByte

public final int addByte(int length)
Adds a byte array to this struct.

Parameters:
  `length` - Length of the array.
Returns:
  Offset of the new field.

### addChar

public final int addChar()
Adds a char field to this struct.

Returns:
  Offset of the new field.

### addChar

public final int addChar(int length)
Adds a char array to this struct.

Parameters:
  `length` - Length of the array.
Returns:
  Offset of the new field.

### addShort

public final int addShort()
Adds a short field to this struct.

Returns:
  Offset of the new field.

### addShort

public final int addShort(int length)
Adds a short array to this struct.

Parameters:
  `length` - Length of the array.
Returns:
  Offset of the new field.

### addInt

public final int addInt()
Adds an int field to this struct.

Returns:
  Offset of the new field.

### addInt

public final int addInt(int length)
Adds an int array to this struct.

Parameters:
  `length` - Length of the array.
Returns:
  Offset of the new field.

### addLong

public final int addLong()
Adds a long field to this struct.

Returns:
  Offset of the new field.

### addLong

public final int addLong(int length)
Adds a long array to this struct.

Parameters:
  `length` - Length of the array.
Returns:
  Offset of the new field.

### addFloat

public final int addFloat()
Adds a float field to this struct.

Returns:
  Offset of the new field.

### addFloat

public final int addFloat(int length)
Adds a float array to this struct.

Parameters:
  `length` - Length of the array.
Returns:
  Offset of the new field.

### addDouble

public final int addDouble()
Adds a double field to this struct.

Returns:
  Offset of the new field.

### addDouble

public final int addDouble(int length)
Adds a double array to this struct.

Parameters:
  `length` - Length of the array.
Returns:
  Offset of the new field.

### addStruct

public final int addStruct(Struct struct) throws MPIException
Adds a struct field to this struct.

Parameters:
  `struct` - Type of the field.
Returns:
  Offset of the new field.
Throws:
  `MPIException` - Signals that an MPI exception of some sort has occurred.

### addStruct

public final int addStruct(Struct struct, int length) throws MPIException
Adds an array of structs to this struct.

Parameters:
  `struct` - Type of the array.
  `length` - Length of the array.
Returns:
  Offset of the new field.
Throws:
  `MPIException` - Signals that an MPI exception of some sort has occurred.

### addData

public final int addData(Datatype type) throws MPIException
Adds a field of the specified data type.

Parameters:
  `type` - Data type.
Returns:
  Offset of the new field.
Throws:
  `MPIException` - Signals that an MPI exception of some sort has occurred.

### addData

public final int addData(Datatype type, int length) throws MPIException
Adds an array of the specified data type.

Parameters:
  `type` - Data type.
  `length` - Length of the array.
Returns:
  Offset of the new field.
Throws:
  `MPIException` - Signals that an MPI exception of some sort has occurred.