Package uk.ac.starlink.array
Class Requirements
java.lang.Object
uk.ac.starlink.array.Requirements
- All Implemented Interfaces:
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
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
ConstructorsConstructorDescriptionConstructs a Requirements object with no specifications.Requirements
(AccessMode mode) Constructs a Requirements object specifying a given access mode. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Provides a snapshot of this object; modifying the returned object will not affect the object from which it was cloned.Gets this object's required bad value handler.getMode()
Gets an object indicating the use to which the required array will be put.getOrder()
Gets this object's required pixel ordering scheme.boolean
Gets a flag indicating whether random access is required.getType()
Gets this object's required data type.Gets this object's required window; the shape it must have.setBadHandler
(BadHandler handler) Sets this object's required bad value handler.setBadValue
(Number badValue) Sets this object's required bad value handler to be one with a given bad value.setMode
(AccessMode mode) Sets an object indicating the use to which the required array will be put.Sets this object's required pixel ordering scheme.setRandom
(boolean random) Sets a flag indicating whether random access is required.setShape
(OrderedNDShape oshape) Sets this object's required ordered shape (pixel sequence).Sets this object's required data type.Sets this object's required window; the shape it must have.toString()
-
Constructor Details
-
Requirements
public Requirements()Constructs a Requirements object with no specifications. -
Requirements
Constructs a Requirements object specifying a given access mode.
-
-
Method Details
-
getType
Gets this object's required data type.- Returns:
- this object's required data type
-
setType
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
Gets this object's required window; the shape it must have.- Returns:
- this object's required window
-
setWindow
Sets this object's required window; the shape it must have.- Parameters:
window
- the required window- Returns:
- this object
-
getOrder
Gets this object's required pixel ordering scheme.- Returns:
- this object's required ordering
-
setOrder
Sets this object's required pixel ordering scheme.- Parameters:
order
- the required ordering- Returns:
- this object
-
setShape
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
Gets this object's required bad value handler.- Returns:
- this object's required bad value handler
-
setBadHandler
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 setIllegalArgumentException
- if the type of handler does not match the type of this object
-
setBadValue
Sets this object's required bad value handler to be one with a given bad value. This convenience method does almost exactly the same assetBadHandler(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 setIllegalArgumentException
- 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
Sets a flag indicating whether random access is required.- Parameters:
random
- whether random access will be required
-
getMode
Gets an object indicating the use to which the required array will be put.- Returns:
- the access mode required
-
setMode
Sets an object indicating the use to which the required array will be put.- Parameters:
mode
- the required access mode- Returns:
- this object
-
clone
Provides a snapshot of this object; modifying the returned object will not affect the object from which it was cloned. -
toString
-