public abstract class BadHandler extends Object
Obtain an instance of this class using the getHandler(uk.ac.starlink.array.Type, java.lang.Number)
static method.
It is not expected to be necessary to extend this class for normal
purposes, but there is a protected constructor in case this is
required. Such subclassing might be useful to provided specialised
bad value handlers in which, for instance, floating NaN
values do not count as bad, or infinite values do. Such subclassing
should be done and used with care.
Modifier and Type | Class and Description |
---|---|
static interface |
BadHandler.ArrayHandler
Class provided for testing and setting bad values in a given
primitive array.
|
Modifier | Constructor and Description |
---|---|
protected |
BadHandler(Type type,
Number badValue)
Constructor which may be used for subclassing.
|
Modifier and Type | Method and Description |
---|---|
abstract BadHandler.ArrayHandler |
arrayHandler(Object array)
Returns an
ArrayHandler object for testing/setting
bad values
in a given primitive array according to the bad value handling
rules of this BadHandler . |
boolean |
equals(Object other) |
Number |
getBadValue()
Gets the bad data value.
|
static BadHandler |
getHandler(Type type,
Number badValue)
Returns an instance of this class capable of dealing with primitives
of a given type and using a given bad value.
|
Type |
getType()
Gets the Type of this handler.
|
int |
hashCode() |
abstract boolean |
isBad(Object array,
int pos)
Indicates whether an element of an array represents a bad value
for this NDArray.
|
abstract Number |
makeNumber(Object array,
int pos)
Turns a single element of an array into a
Number
object of the appropriate type. |
abstract void |
putBad(Object array,
int pos)
Writes a single bad value into an array.
|
abstract void |
putBad(Object array,
int start,
int size)
Writes a sequence of bad values into an array.
|
String |
toString() |
public abstract boolean isBad(Object array, int pos)
array
- the array in which the pixel residespos
- the position in array of the pixel to be tested.ClassCastException
- if array is not an array of primitives with
type matching the type of this handlerIndexOutOfBoundsException
- if pos is outside the bounds of arraypublic abstract void putBad(Object array, int start, int size)
array
- array into which to write bad values, which must be
an array of primitive type matching this handler's
Type with at least start+length elementsstart
- the position in array at which to start writing
bad valuessize
- the number of elements of array to write bad values toClassCastException
- if array is not an array of primitives with
type matching the type of this handlerIndexOutOfBoundsException
- if access outside the bounds of the
array is attemptedpublic abstract void putBad(Object array, int pos)
array
- array into which to write a bad value; it must be
an array of primitive type matching this handler's
Type with at least pos-1 elementspos
- the position at which to write the bad valueClassCastException
- if array is not an array of primitives with
type matching the type of this handlerIndexOutOfBoundsException
- if access outside the bounds of the
array is attemptedpublic abstract Number makeNumber(Object array, int pos)
Number
object of the appropriate type. The return value will be
one of the wrapper types Byte, Short, Integer, Float or Double
wrapping the value in question, unless the array element is
bad, in which case the null value will be returned.array
- array containing the value to be convertedpos
- the index into array at which the element of interest
is to be foundIndexOutOfBoundsException
- if access outside the bounds of the
array is attemptedpublic abstract BadHandler.ArrayHandler arrayHandler(Object array)
ArrayHandler
object for testing/setting
bad values
in a given primitive array according to the bad value handling
rules of this BadHandler
. The same functionality can
be achieved by use of the isBad(java.lang.Object, int)
and putBad(Object,int)
methods of this class, but using an ArrayHandler
can avoid
repeated typecasts and provide better performance.ClassCastException
- if array is not an array of primitives with
type matching the type of this handlerpublic Type getType()
public Number getBadValue()
public static BadHandler getHandler(Type type, Number badValue)
type
- a Type object determining what kind of primitive
data this handler will deal withbadValue
- a Number object giving the magic bad value.
This will be an instance of the primitive wrapper
class corresponding to this array's type.
The value may be null, in which case no data
of integer type is considered bad, but floating
point values which are NaN still are.
In this case a default bad value will be written
if the putBad methods are invokedCopyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.