public class TypeConverter extends Object implements Converter
Constructor and Description |
---|
TypeConverter(Type type1,
BadHandler handler1,
Type type2,
BadHandler handler2)
Creates a converter from one primitive type to another.
|
TypeConverter(Type type1,
BadHandler handler1,
Type type2,
BadHandler handler2,
Function func)
Creates a converter from one primitive type to another, which will
pass the values through a real function prior to doing the
type conversion.
|
Modifier and Type | Method and Description |
---|---|
void |
convert12(Object src1,
int srcPos,
Object dest2,
int destPos,
int length)
Converts a sequence of elements in an array of type 1 and places the
results in a sequence of elements in an array of type 2.
|
void |
convert21(Object src2,
int srcPos,
Object dest1,
int destPos,
int length)
Converts a sequence of elements in an array of type 2 and places the
results in a sequence of elements in an array of type 1.
|
BadHandler |
getBadHandler1()
Gets the bad value handler for end 1 of the converter.
|
BadHandler |
getBadHandler2()
Gets the bad value handler for end 2 of the converter.
|
Type |
getType1()
Gets the primitive type for end 1 of the converter.
|
Type |
getType2()
Gets the primitive type for end 2 of the converter.
|
boolean |
isUnit12()
Indicates whether the conversion from type 1 to type 2 is known to
be a unit transformation.
|
boolean |
isUnit21()
Indicates whether the conversion from type 2 to type 1 is known to
be a unit transformation.
|
public TypeConverter(Type type1, BadHandler handler1, Type type2, BadHandler handler2, Function func)
type1
- primitive type for data at end 1 of the conversionhandler1
- a bad value handler for the data at end 1 of
the conversiontype2
- primitive type for data at end 2 of the conversionhandler2
- a bad value handler for the data at end 2 of
the conversionfunc
- a Function object representing an additional
double
function to apply
to values in addition to
the type conversion. The forward mapping will
be used for 1->2 conversions, and the inverse
one for 2->1 conversions. If null, a unit
function is used (efficiently)public TypeConverter(Type type1, BadHandler handler1, Type type2, BadHandler handler2)
type1
- primitive type for data at end 1 of the conversionhandler1
- a bad value handler for the data at end 1 of
the conversiontype2
- primitive type for data at end 2 of the conversionhandler2
- a bad value handler for the data at end 2 of
the conversionpublic Type getType1()
public Type getType2()
public BadHandler getBadHandler1()
getBadHandler1
in interface Converter
public BadHandler getBadHandler2()
getBadHandler2
in interface Converter
public boolean isUnit12()
public boolean isUnit21()
public void convert12(Object src1, int srcPos, Object dest2, int destPos, int length)
convert12
in interface Converter
src1
- array of type 1 containing input valuessrcPos
- starting position of elements to convert in src1dest2
- array of type 2 to reaceive output valuesdestPos
- starting position of elements to write in dest2length
- number of elements to convertpublic void convert21(Object src2, int srcPos, Object dest1, int destPos, int length)
convert21
in interface Converter
src2
- array of type 2 containing input valuessrcPos
- starting position of elements to convert in src2dest1
- array of type 1 to reaceive output valuesdestPos
- starting position of elements to write in dest1length
- number of elements to convertCopyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.