uk.ac.starlink.array
Interface Converter

All Known Implementing Classes:
TypeConverter

public interface Converter

Converts values between primitive types. The conversion will typically be like a typecast, though conversions involving scaling or other functions may equally be provided. A given Converter object converts, in both directions, between two primitive types which are labelled 1 and 2. Bad value processing is part of the interface; a bad value at the input end of the conversion will result in a bad value at the output end, and a non-bad value at the input end may result in a bad value at the output end, for instance in the case of overflow.

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

Method Summary
 void convert12(Object src1, int srcPos, Object dest2, int destPos, int length)
          Converts a sequence of values of type 1 to a sequence of values of type 2.
 void convert21(Object src2, int srcPos, Object dest1, int destPos, int length)
          Converts a sequence of values of type 2 to a sequence of values of type 1.
 BadHandler getBadHandler1()
          Returns the bad value handler used for type 1.
 BadHandler getBadHandler2()
          Returns the bad value handler used for type 2.
 Type getType1()
          Returns the data type of type 1.
 Type getType2()
          Returns the data type of type 2.
 boolean isUnit12()
          Indicates whether conversion from type 1 to type 2 does any work.
 boolean isUnit21()
          Indicates whether conversion from type 2 to type 1 does any work.
 

Method Detail

getType1

Type getType1()
Returns the data type of type 1.

Returns:
Type object representing primitive type 1

getType2

Type getType2()
Returns the data type of type 2.

Returns:
Type object representing primitive type 2

getBadHandler1

BadHandler getBadHandler1()
Returns the bad value handler used for type 1.

Returns:
the type 1 BadHandler object

getBadHandler2

BadHandler getBadHandler2()
Returns the bad value handler used for type 2.

Returns:
the type 2 BadHandler object

isUnit12

boolean isUnit12()
Indicates whether conversion from type 1 to type 2 does any work. This will return true only if type 1 and type 2 are equivalent, and all values converted from type 1 to type 2 are guaranteed to be element-for-element identical.

Returns:
true if no useful work is done by the convert12 method

isUnit21

boolean isUnit21()
Indicates whether conversion from type 2 to type 1 does any work. This will return true only if type 1 and type 2 are equivalent, and all values converted from type 2 to type 1 are guaranteed to be element-for-element identical.

Returns:
true if no useful work is done by the convert21 method

convert12

void convert12(Object src1,
               int srcPos,
               Object dest2,
               int destPos,
               int length)
Converts a sequence of values of type 1 to a sequence of values of type 2.

Parameters:
src1 - the source array, which must be an array of primitive type 1 with at least srcPos+length elements
srcPos - the position in the source array of the first element to be converted
dest2 - the destination array, which must be an array of primitive type 2 with at least destPos+length elements. If type 1 and type 2 are the same, it is permissible for src1 and dest2 to be references to the same object
destPos - the position in the destination array at which the first converted element will be written
length - the number of elements to convert
Throws:
IndexOutOfBoundsException - if access outside the bounds of the source or destination array is attempted

convert21

void convert21(Object src2,
               int srcPos,
               Object dest1,
               int destPos,
               int length)
Converts a sequence of values of type 2 to a sequence of values of type 1.

Parameters:
src2 - the source array, which must be an array of primitive type 2 with at least srcPos+length elements
srcPos - the position in the source array of the first element to be converted
dest1 - the destination array, which must be an array of primitive type 1 with at least destPos+length elements. If type 1 and type 2 are the same, it is permissible for src2 and dest1 to be references to the same object
destPos - the position in the destination array at which the first converted element will be written
length - the number of elements to convert
Throws:
IndexOutOfBoundsException - if access outside the bounds of the source or destination array is attempted


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.