public class EPLIConversion
extends java.lang.Object
Constructor and Description |
---|
EPLIConversion() |
Modifier and Type | Method and Description |
---|---|
static int |
annoBIT(java.lang.Object X)
annoBIT - return a field's declared BIT annotation value
|
static int |
annoCHAR(java.lang.Object X)
annoCHAR - return a field's declared CHAR annotation value
|
static int |
annoDECIMALprecision(java.lang.Object X)
annoDECIMALprecision - return a field's declared DECIMAL annotation, precision value
|
static int |
annoDECIMALscale(java.lang.Object X)
annoDECIMALscale - return a field's declared DECIMAL annotation, scale value
|
static java.lang.String |
annoPIC(java.lang.Object X)
annoPIC - return a field's declared CHAR annotation value
|
static boolean |
annoVARY(java.lang.Object X)
annoVARY - return a field's declared CHAR annotation value
|
static BitN |
BitN(BitN inBits)
Runtime copy constructor of BIT(n) since BitN doesn't have one.
|
static BitN |
BitNAnd(BitN op1,
BitN op2)
Runtime & operator for BIT(n) since BitN doesn't have one.
|
static BitN |
BitNNot(BitN inBits)
Runtime ^ operator for BIT(n) since BitN doesn't have one.
|
static BitN |
BitNOr(BitN op1,
BitN op2)
Runtime | operator for BIT(n) since BitN doesn't have one.
|
static java.lang.String |
bitToString(java.lang.String strB)
convert a bit string ('01011101'X) into a Java string
|
static byte |
byteValue(java.lang.Object value)
convert the value to a byte
|
static BitN |
cat(BitN bs1,
BitN bs2)
concatenate BIT(n) & BIT(m) into a BIT(n+m)
|
static double |
CheckSize(double arg)
CheckSize - check invalid IEEE calculation that results in not-a-number
and raise the SIZE CONDITION (my estimate for closest equivalent)
|
static java.math.BigDecimal |
CheckZeroDivide(java.math.BigDecimal arg) |
static java.math.BigInteger |
CheckZeroDivide(java.math.BigInteger arg) |
static boolean |
CheckZeroDivide(boolean arg) |
static byte |
CheckZeroDivide(byte arg) |
static java.lang.Byte |
CheckZeroDivide(java.lang.Byte arg) |
static double |
CheckZeroDivide(double arg) |
static java.lang.Double |
CheckZeroDivide(java.lang.Double arg) |
static FixedBin |
CheckZeroDivide(FixedBin arg) |
static float |
CheckZeroDivide(float arg) |
static java.lang.Float |
CheckZeroDivide(java.lang.Float arg) |
static int |
CheckZeroDivide(int arg)
CheckZeroDivide - check for ZERODIVIDE divisor and throw CONDITION
|
static java.lang.Integer |
CheckZeroDivide(java.lang.Integer arg) |
static long |
CheckZeroDivide(long arg) |
static java.lang.Long |
CheckZeroDivide(java.lang.Long arg) |
static Picture |
CheckZeroDivide(Picture arg) |
static short |
CheckZeroDivide(short arg) |
static java.lang.Short |
CheckZeroDivide(java.lang.Short arg) |
static java.lang.String |
CheckZeroDivide(java.lang.String arg) |
static int |
compareTo(java.lang.String a,
java.lang.String b)
Runtime fixed or variable CHAR comparison following PL/I rules:
IBM PL/I Lang Ref 5.1 pg68: "In the comparison of strings of unequal lengths, the shorter
string is padded on the right"
|
static java.lang.Object |
derefine(java.lang.Object toObj,
java.lang.Object fromObj,
int offset)
derefine (reverse redefine) one object as another.
|
static double |
doubleValue(java.lang.Object value)
convert the value to a double
|
static float |
floatValue(java.lang.Object value)
convert the value to a float
|
static void |
fromBytes(java.lang.Object to,
byte[] from)
fromBytes - static version of the fromBytes() or fromByteArray() non-
static methods that assign a possibly-immutable object's contents
from a byte array
|
static java.lang.Object |
fromBytes(java.lang.Object toModel,
ByteBuilder bb)
fromBytes - static version of the fromBytes() or fromByteArray() or getBytes() non-
static methods that works through a pointer of a specific type (created with
"new Pointer
|
static java.lang.Object |
fromBytes(java.lang.Object toModel,
ByteBuilder bb,
int offset)
fromBytes - static version of the fromBytes() or fromByteArray() or getBytes() non-
static methods that works through a pointer of a specific type (created with
"new Pointer
|
static java.lang.String |
hexToString(java.lang.String strB)
convert a hex string ('12cd'X) into a Java string
|
static int |
intValue(java.lang.Object value)
convert the value to an it
|
static long |
longValue(java.lang.Object value)
convert the value to a long
|
static void |
main(java.lang.String[] args)
unit test for EPLIConversions
|
static Picture |
pictureValue(java.lang.Object value)
convert the value to a Picture
|
static java.lang.Object |
Precision(java.lang.Object arg,
int precision,
int scale)
Precision - adjust the precision and scale of the arg to that provided,
raising the SIZE condition of such adjustment causes loss of precision.
|
static java.lang.Object |
redefine(java.lang.Object toModel,
java.lang.Object fromObj,
int offset)
redefine (overlay) one object as another.
|
static short |
shortValue(java.lang.Object value)
convert the value to a short
|
static java.math.BigDecimal |
toBigDecimal(java.lang.Object value)
convert the value to a BigDecimal
|
static java.math.BigDecimal |
toBigDecimal(java.lang.Object value,
int P,
int Q)
convert the value to a BigDecimal
|
static java.math.BigInteger |
toBigInteger(java.lang.Object value)
convert the value to a BigInteger and return it
|
static java.lang.Boolean |
toBit1(java.lang.String inString)
Runtime conversion from CHAR(m) VARYING to BIT(1)
|
static BitN |
toBitN(BitN inBitN,
int len)
Runtime conversion from BIT(n) to BIT(m)
|
static BitN |
toBitN(long... inLong)
Runtime conversion from Java long to BIT(n), n>1
|
static BitN |
toBitN(java.lang.Object inObj)
Runtime conversion from Java long to BIT(n), n>1
|
static java.lang.Object |
toBitN(java.lang.Object fromValue,
int len)
Runtime conversion from any Object to BIT(m)
|
static BitN |
toBitN(java.lang.String inString,
int N)
Runtime conversion from CHAR(m) VARYING as a straight string "0110" or
PL/I BIT(n) format "'0110'B") to BIT(n), n>1
Note: Java BitNs are considered "little endian" (rightmost is bit 0).
|
static java.lang.Boolean |
toBoolean(java.lang.Object inObj)
Dynamic conversion of any EPLI type to Boolean
|
static java.lang.Byte |
toByte(java.lang.Object value)
convert the value to a Byte
|
static byte[] |
toBytes(EPLITYPES type,
java.lang.Object from)
toBytes - static version of the toBytes() or toByteArray() or getBytes() non-
static methods that assign a possibly-immutable object's contents
from a byte array
|
static byte[] |
toBytes(java.lang.Object from)
toBytes - static version of the toBytes() or toByteArray() or getBytes() non-
static methods that assign a possibly-immutable object's contents
from a byte array
|
static Complex |
toComplex(java.lang.Object value)
convert the value to a Complex
|
static java.lang.Double |
toDouble(java.lang.Object value)
convert the value to a Double
|
static FixedBin |
toFixedBin(java.lang.Object value)
convert the value to an FixedBin and return it
|
static FixedBin |
toFixedBin(java.lang.Object value,
int P,
int Q)
convert the value to an FixedBin and return it
|
static java.lang.String |
toFixedChar(java.lang.String inString,
int len)
Simulate CHAR(n) datatypes by padding or truncating
string to length
|
static java.lang.Float |
toFloat(java.lang.Object value)
convert the value to a Float
|
static java.lang.Integer |
toInteger(java.lang.Object value)
convert the value to an Integer
|
static java.lang.Long |
toLong(java.lang.Object value)
convert the value to a Long
|
static Picture |
toPicture(java.lang.Object value)
convert the value to a Picture
|
static Picture |
toPicture(java.lang.Object value,
java.lang.String pic)
convert the value to an Picture and return it
|
static short |
toshort(java.math.BigDecimal obj) |
static short |
toshort(java.math.BigInteger obj) |
static short |
toshort(BitN obj) |
static short |
toshort(java.lang.Boolean obj)
Runtime conversion to primitive short
while checking SIZE (overflow) Condition.
|
static short |
toshort(java.lang.Byte obj) |
static short |
toshort(java.lang.Double obj) |
static short |
toshort(FixedBin obj) |
static short |
toshort(java.lang.Float obj) |
static short |
toshort(java.lang.Integer obj) |
static short |
toshort(java.lang.Long obj) |
static short |
toshort(java.lang.Object obj) |
static java.lang.Short |
toShort(java.lang.Object value)
convert the value to a Short
|
static short |
toshort(Picture obj) |
static short |
toshort(java.lang.Short obj) |
static short |
toshort(java.lang.String obj) |
static java.lang.String |
toString(byte[] bytes)
Runtime conversion from n-byte byte string to
n byte String
|
static java.lang.String |
toString(java.lang.Object value)
convert the value to an String and return it
|
static java.lang.String |
toString(java.lang.Object value,
int len)
convert the value to a fixed or variable length String
of a certain length and return it
|
static java.lang.String |
toString2(int num)
Runtime conversion from 2-byte integer to
a 2 byte char
|
static java.lang.String |
toVarChar(BitN inBits)
Runtime conversion from BIT(n) to CHAR(m) VARYING
|
static java.lang.String |
toVarChar(BitN inBits,
int N)
Conversion from BIT(n) to CHAR(m) VARYING
|
static java.lang.String |
toVarChar(java.lang.String inString,
int maxLen)
Runtime conversion CHAR(n) or CHAR(n) VARYING to CHAR(m) VARYING
|
static java.lang.String |
toVarData(java.lang.String inString,
int maxLen)
Runtime conversion CHAR(n) or CHAR(n) VARYING to CHAR(m) VARYING
used in PUT DATA such that it is in a form acceptable to a GET DATA,
internal single quotes are doubled
|
public static java.lang.String toFixedChar(java.lang.String inString, int len)
inString
- - input stringlen
- - defined fixed length of the stringpublic static java.lang.String toVarChar(java.lang.String inString, int maxLen)
inString
- - input StringmaxLen
- - the maximum length of this var char, <=0 for no-oppublic static java.lang.String toVarData(java.lang.String inString, int maxLen)
inString
- - input StringmaxLen
- - the maximum length of this var char, <=0 for no-oppublic static java.lang.String toVarChar(BitN inBits)
inBits
- - input BitNpublic static java.lang.String toString(byte[] bytes)
bytes
- - byte arraypublic static java.lang.String hexToString(java.lang.String strB)
strB
- - the input string (quoted or not) in hexpublic static java.lang.String bitToString(java.lang.String strB)
strB
- - the input string (quoted or not) in bitspublic static java.lang.String toString2(int num)
num
- - 2 byte intpublic static BitN toBitN(BitN inBitN, int len)
inBitN
- - input BIT(n) in Java BitN formatlen
- - number of bits in the final BitNpublic static BitN cat(BitN bs1, BitN bs2)
bs1
- - input BIT(n) in Java BitN formatbs2
- - input BIT(n) in Java BitN formatpublic static short toshort(java.lang.Boolean obj)
public static short toshort(java.lang.Byte obj)
public static short toshort(java.lang.Short obj)
public static short toshort(java.lang.Integer obj)
public static short toshort(java.lang.Long obj)
public static short toshort(java.lang.Float obj)
public static short toshort(java.lang.Double obj)
public static short toshort(java.math.BigDecimal obj)
public static short toshort(java.math.BigInteger obj)
public static short toshort(BitN obj)
public static short toshort(FixedBin obj)
public static short toshort(Picture obj)
public static short toshort(java.lang.String obj)
public static short toshort(java.lang.Object obj)
public static java.lang.String toVarChar(BitN inBits, int N)
inBits
- - input BitNN
- - the number of bits to return or 0 meaning
the length of the BitNpublic static BitN BitN(BitN inBits)
inBits
- - input BitNpublic static BitN BitNAnd(BitN op1, BitN op2)
op1
- - input BitN to and with ...op2
- - another input BitNpublic static BitN BitNOr(BitN op1, BitN op2)
op1
- - input BitN to and with ...op2
- - another input BitNpublic static BitN BitNNot(BitN inBits)
inBits
- - input BitNpublic static int compareTo(java.lang.String a, java.lang.String b)
a
- - first Stringb
- - second Stringpublic static java.lang.Boolean toBit1(java.lang.String inString)
inString
- - input string in PL/I bit string formatpublic static BitN toBitN(java.lang.String inString, int N)
inString
- - input string in PL/I bit string formatN
- - number of bits, 0 if N is to be determined from string lengthpublic static BitN toBitN(long... inLong)
inLong
- - input long number in little endian, probably represented as a Java binary constant
in generated source "0b001100". multiple longs can be supplied or a long
array supplied for n>64public static BitN toBitN(java.lang.Object inObj)
inObj
- - input Object of any EPLI type in little endian,
probably represented as a Java binary constant
in generated source "0b001100". multiple longs can be supplied or a long
array supplied for n>64public static java.lang.Object toBitN(java.lang.Object fromValue, int len)
fromValue
- - input Object of any EPLI typelen
- - number of bits in the final BitNpublic static java.lang.Boolean toBoolean(java.lang.Object inObj)
inObj
- - input stringpublic static void fromBytes(java.lang.Object to, byte[] from)
to
- - an EPLI object such as Group, Integer, Short, FixedBin, BigDecimal, Stringfrom
- - the byte arraypublic static java.lang.Object fromBytes(java.lang.Object toModel, ByteBuilder bb, int offset)
toModel
- - an object that is used as a _template only_ or a class
such as Integer.class, which serves as a model for the object to be returned.
For complex types such as FixedBin(p,q) it would have the appropriate scale
and precision or String of a fixed length it will have the @CHAR(n) maximum
size annotation or Picture it would have the @PIC(pic-format) annotation.
Note that "toModel" is not modified, the result of this operation is returned.bb
- - the ByteBilder containing the bytes to use to create the model of "to"offset
- - the starting offset from the current bb "next byte" from which the
model object begins, used in DCL A DEF B POS(offset);public static java.lang.Object fromBytes(java.lang.Object toModel, ByteBuilder bb)
toModel
- - an object that is used as a _template only_ or a class
such as Integer.class, which serves as a model for the object to be returned.
For complex types such as FixedBin(p,q) it would have the appropriate scale
and precision or String of a fixed length it will have the @CHAR(n) maximum
size annotation or Picture it would have the @PIC(pic-format) annotation.
Note that "toModel" is not modified, the result of this operation is returned.bb
- - the ByteBilder containing the bytes to use to create the model of "to"public static byte[] toBytes(java.lang.Object from)
from
- - the object to convertpublic static byte[] toBytes(EPLITYPES type, java.lang.Object from)
type
- - an EPLITYPES corresponding to the fromfrom
- - the object to convertpublic static int CheckZeroDivide(int arg)
arg
- - an object that, when evaluates to a zero, with throw the conditionCondition.CONDITION
- ZERODIVIDE if parameter is zeropublic static long CheckZeroDivide(long arg)
public static short CheckZeroDivide(short arg)
public static byte CheckZeroDivide(byte arg)
public static float CheckZeroDivide(float arg)
public static double CheckZeroDivide(double arg)
public static boolean CheckZeroDivide(boolean arg)
public static java.lang.Integer CheckZeroDivide(java.lang.Integer arg)
public static java.lang.Short CheckZeroDivide(java.lang.Short arg)
public static java.lang.Long CheckZeroDivide(java.lang.Long arg)
public static java.lang.Byte CheckZeroDivide(java.lang.Byte arg)
public static java.lang.Float CheckZeroDivide(java.lang.Float arg)
public static java.lang.Double CheckZeroDivide(java.lang.Double arg)
public static java.math.BigInteger CheckZeroDivide(java.math.BigInteger arg)
public static java.math.BigDecimal CheckZeroDivide(java.math.BigDecimal arg)
public static java.lang.String CheckZeroDivide(java.lang.String arg)
public static double CheckSize(double arg)
arg
- - double to checkCondition.CONDITION
- SIZE if parameter is NaN, +/- infinitypublic static java.lang.Object Precision(java.lang.Object arg, int precision, int scale)
arg
- - CODEDARITHMETIC (Byte, Short, Integer, Long,
BigInteger, Float, Double, BigDecimal, Complex) to checkprecision
- - the total number of binary digits to
restrict arg to before it is returned; if loss of precision
occurs the SIZE condition is raised if it is enabled (default: no).scale
- - the number of binary digits to the right of the decimal to
restrict arg to before it is returned; if loss of precision
occurs the SIZE condition is raised if it is enabled (default: no).
precision and scale values are always in binary digits,
for variables declared DECIMAL(p,q) use the IBM-defined conversion
technique, namely precision=CEIL(p*3.32), scale=CEIL(q*3.32).Condition.CONDITION
- ERROR if parameters are negative;
CONDITION SIZE if loss of precision or scale of the value results;
CONDITION CONVERSION if argument is not a type that can be adjustedpublic static int intValue(java.lang.Object value)
value
- - an Objectpublic static java.lang.Integer toInteger(java.lang.Object value)
value
- - an Objectpublic static short shortValue(java.lang.Object value)
value
- - an Objectpublic static java.lang.Short toShort(java.lang.Object value)
value
- - an Objectpublic static long longValue(java.lang.Object value)
value
- - an Objectpublic static java.lang.Long toLong(java.lang.Object value)
value
- - an Objectpublic static byte byteValue(java.lang.Object value)
value
- - an Objectpublic static java.lang.Byte toByte(java.lang.Object value)
value
- - an Objectpublic static float floatValue(java.lang.Object value)
value
- - an Objectpublic static java.lang.Float toFloat(java.lang.Object value)
value
- - an Objectpublic static double doubleValue(java.lang.Object value)
value
- - an Objectpublic static java.lang.Double toDouble(java.lang.Object value)
value
- - an Objectpublic static Picture pictureValue(java.lang.Object value)
value
- - an Objectpublic static Picture toPicture(java.lang.Object value)
value
- - an Objectpublic static Complex toComplex(java.lang.Object value)
value
- - an Objectpublic static java.lang.String toString(java.lang.Object value)
value
- - an Objectpublic static java.lang.String toString(java.lang.Object value, int len)
value
- - an Object to be converted to a string and trimmed/paddedlen
- - if positive, trim or pad to the fixed length, if
negative, trim to the maximum length of its absolute valuepublic static FixedBin toFixedBin(java.lang.Object value)
value
- - an Objectpublic static FixedBin toFixedBin(java.lang.Object value, int P, int Q)
value
- - an ObjectP
- - int precisionQ
- - int scalepublic static Picture toPicture(java.lang.Object value, java.lang.String pic)
value
- - an Objectpublic static java.math.BigDecimal toBigDecimal(java.lang.Object value)
value
- - an Objectpublic static java.math.BigDecimal toBigDecimal(java.lang.Object value, int P, int Q)
value
- - an ObjectP
- - the precisionQ
- - the scalepublic static java.math.BigInteger toBigInteger(java.lang.Object value)
value
- - an Objectpublic static java.lang.Object redefine(java.lang.Object toModel, java.lang.Object fromObj, int offset)
toModel
- - a model of a overlay destination object (meta-data) orfromObj
- - overlay source object (data)offset
- - the position (offset) within the source the overlay beginspublic static java.lang.Object derefine(java.lang.Object toObj, java.lang.Object fromObj, int offset)
toObj
- - not just a model of the destination (format, length)
as with redefine(), but the contents into which the fromObj is inserted.
will modify mutable objects, will not modify immutable objects (see return)fromObj
- - overlay source object (data)offset
- - the position (offset) within the source the overlay beginspublic static int annoBIT(java.lang.Object X)
X
- - any Object which has @BIT(n) definedpublic static int annoCHAR(java.lang.Object X)
X
- - any Object which has @CHAR(n) definedpublic static int annoDECIMALprecision(java.lang.Object X)
X
- - any Object which has @DECIMAL(precision=p,scale=q) definedpublic static int annoDECIMALscale(java.lang.Object X)
X
- - any Object which has @DECIMAL(precision=p,scale=q) definedpublic static java.lang.String annoPIC(java.lang.Object X)
X
- - any Object which has @PIC(picspec) definedpublic static boolean annoVARY(java.lang.Object X)
X
- - any Object which has @VARY definedpublic static void main(java.lang.String[] args)
args
- - ignored