Package uk.ac.starlink.array

# Class Requirements

java.lang.Object
uk.ac.starlink.array.Requirements

All Implemented Interfaces:
  `Cloneable`

public class Requirements extends Object implements Cloneable
Specifies a set of requirements for an array object. A Requirements object may be passed to a constructor or factory method which returns an array object to indicate some required characteristics of the returned array. In general, any fields which are filled in constitute a requirement for the given attribute, while a null (or false) value indicates that the given attribute is not required; if the method/constructor in question cannot comply it should throw an exception rather than return an object lacking any of the requirements.

The attributes which may be stipulated are as follows:

type
  Numerical data type
window
  Shape of the array to be returned (as a window on the underlying array)
order
  Pixel ordering scheme
badHandler
  Bad value handler
random
  Random access required flag
mode
  Access mode

The `mode` requirement is slightly different from the others; it is examined by some methods to determine the use to which the resulting array object will be put, and controls whether data is copied from a source into it on return, or copied out of it to a sink at close time.

The attribute setter methods are declared to return the Requirements object itself for convenience so that settings may be chained.

Version:
  $Id$
Author:
  Mark Taylor (Starlink)

## Constructor Summary

Constructors
Constructor
Description
`Requirements()`
Constructs a Requirements object with no specifications.
`Requirements(AccessMode mode)`
Constructs a Requirements object specifying a given access mode.

## Method Summary

Modifier and Type
Method
Description
`Object`
`clone()`
Provides a snapshot of this object; modifying the returned object will not affect the object from which it was cloned.
`BadHandler`
`getBadHandler()`
Gets this object's required bad value handler.
`AccessMode`
`getMode()`
Gets an object indicating the use to which the required array will be put.
`Order`
`getOrder()`
Gets this object's required pixel ordering scheme.
`boolean`
`getRandom()`
Gets a flag indicating whether random access is required.
`Type`
`getType()`
Gets this object's required data type.
`NDShape`
`getWindow()`
Gets this object's required window; the shape it must have.
`Requirements`
`setBadHandler(BadHandler handler)`
Sets this object's required bad value handler.
`Requirements`
`setBadValue(Number badValue)`
Sets this object's required bad value handler to be one with a given bad value.
`Requirements`
`setMode(AccessMode mode)`
Sets an object indicating the use to which the required array will be put.
`Requirements`
`setOrder(Order order)`
Sets this object's required pixel ordering scheme.
`Requirements`
`setRandom(boolean random)`
Sets a flag indicating whether random access is required.
`Requirements`
`setShape(OrderedNDShape oshape)`
Sets this object's required ordered shape (pixel sequence).
`Requirements`
`setType(Type type)`
Sets this object's required data type.
`Requirements`
`setWindow(NDShape window)`
Sets this object's required window; the shape it must have.
`String`
`toString()`

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

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

## Constructor Details

### Requirements

public Requirements()
Constructs a Requirements object with no specifications.

### Requirements

public Requirements(AccessMode mode)
Constructs a Requirements object specifying a given access mode.

## Method Details

### getType

public Type getType()
Gets this object's required data type.

Returns:
  this object's required data type

### setType

public Requirements setType(Type type)
Sets this object's required data type. If the BadHandler is set to an incompatible type, this method will clear the BadHandler field (set it to null).

Parameters:
  `type` - the required data type
Returns:
  this object

### getWindow

public NDShape getWindow()
Gets this object's required window; the shape it must have.

Returns:
  this object's required window

### setWindow

public Requirements setWindow(NDShape window)
Sets this object's required window; the shape it must have.

Parameters:
  `window` - the required window
Returns:
  this object

### getOrder

public Order getOrder()
Gets this object's required pixel ordering scheme.

Returns:
  this object's required ordering

### setOrder

public Requirements setOrder(Order order)
Sets this object's required pixel ordering scheme.

Parameters:
  `order` - the required ordering
Returns:
  this object

### setShape

public Requirements setShape(OrderedNDShape oshape)
Sets this object's required ordered shape (pixel sequence). This is simply a shortcut way of calling `setWindow` and `setOrder` in one go.

Parameters:
  `oshape` - the ordered shape (or equivalently, pixel sequence) required
Returns:
  this object

### getBadHandler

public BadHandler getBadHandler()
Gets this object's required bad value handler.

Returns:
  this object's required bad value handler

### setBadHandler

public Requirements setBadHandler(BadHandler handler)
Sets this object's required bad value handler. This must only be set if the Type is already set, and the types must match (`handler.getType()==this.getType()`).

Parameters:
  `handler` - the required handler
Returns:
  this object
Throws:
  `IllegalStateException` - if no type has been set
  `IllegalArgumentException` - if the type of `handler` does not match the type of this object

### setBadValue

public Requirements setBadValue(Number badValue)
Sets this object's required bad value handler to be one with a given bad value. This convenience method does almost exactly the same as

        setBadHandler(BadHandler.getHandler(getType(),badValue))

It may only be called if the type has already been set.

Parameters:
  `badValue` - the bad value which the required bad value handler must use
Returns:
  this object
Throws:
  `IllegalStateException` - if no type has been set
  `IllegalArgumentException` - if the type of `badValue` does not match the reqired type of this object

### getRandom

public boolean getRandom()
Gets a flag indicating whether random access is required.

Returns:
  true if random access is required

### setRandom

public Requirements setRandom(boolean random)
Sets a flag indicating whether random access is required.

Parameters:
  `random` - whether random access will be required

### getMode

public AccessMode getMode()
Gets an object indicating the use to which the required array will be put.

Returns:
  the access mode required

### setMode

public Requirements setMode(AccessMode mode)
Sets an object indicating the use to which the required array will be put.

Parameters:
  `mode` - the required access mode
Returns:
  this object

### clone

public Object clone()
Provides a snapshot of this object; modifying the returned object will not affect the object from which it was cloned.

Overrides:
  `clone` in class `Object`

### toString

public String toString()

Overrides:
  `toString` in class `Object`