|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jpos.iso.ISOUtil
public class ISOUtil
varios functions needed to pack/unpack ISO-8583 fields
ISOComponent| Field Summary | |
|---|---|
static byte[] |
ASCII2EBCDIC
|
static byte[] |
EBCDIC2ASCII
|
static String |
ENCODING
|
static byte |
ETX
|
static byte |
FS
|
static byte |
GS
|
static String[] |
hexStrings
|
static byte |
RS
|
static byte |
STX
|
static byte |
US
|
| Constructor Summary | |
|---|---|
ISOUtil()
|
|
| Method Summary | |
|---|---|
static byte[] |
asciiToEbcdic(byte[] a)
|
static byte[] |
asciiToEbcdic(String s)
|
static void |
asciiToEbcdic(String s,
byte[] e,
int offset)
|
static String |
bcd2str(byte[] b,
int offset,
int len,
boolean padLeft)
converts a BCD representation of a number to a String |
static byte[] |
bitSet2byte(BitSet b)
converts a BitSet into a binary field used in pack routines |
static byte[] |
bitSet2byte(BitSet b,
int bytes)
converts a BitSet into a binary field used in pack routines |
static byte[] |
bitSet2extendedByte(BitSet b)
Converts a BitSet into an extended binary field used in pack routines. |
static int |
bitSet2Int(BitSet bs)
|
static String |
bitSet2String(BitSet b)
bit representation of a BitSet suitable for dumps and debugging |
static String |
blankUnPad(String s)
Right unPad with ' ' |
static BitSet |
byte2BitSet(BitSet bmap,
byte[] b,
int bitOffset)
Converts a binary representation of a Bitmap field into a Java BitSet |
static BitSet |
byte2BitSet(byte[] b,
int offset,
boolean bitZeroMeansExtended)
Converts a binary representation of a Bitmap field into a Java BitSet |
static BitSet |
byte2BitSet(byte[] b,
int offset,
int maxBits)
Converts a binary representation of a Bitmap field into a Java BitSet |
static String[] |
commaDecode(String s)
Decodes a comma encoded String as encoded by commaEncode |
static String |
commaEncode(String[] ss)
Converts a string[] into a comma-delimited String. |
static byte[] |
concat(byte[] array1,
byte[] array2)
Concatenates two byte arrays (array1 and array2) |
static byte[] |
concat(byte[] array1,
int beginIndex1,
int length1,
byte[] array2,
int beginIndex2,
int length2)
Concatenates two byte arrays (array1 and array2) |
static String |
dumpString(byte[] b)
converts a byte array to printable characters |
static String |
ebcdicToAscii(byte[] e)
|
static String |
ebcdicToAscii(byte[] e,
int offset,
int len)
|
static byte[] |
ebcdicToAsciiBytes(byte[] e)
|
static byte[] |
ebcdicToAsciiBytes(byte[] e,
int offset,
int len)
|
static String |
formatAmount(long l,
int len)
prepare long value used as amount for display (implicit 2 decimals) |
static String |
formatAmountConversionRate(double convRate)
Format a string containing a amount conversion rate in the proper format Format: The leftmost digit (i.e., position 1) of this data element denotes the number of positions the decimal separator must be moved from the right. |
static String |
formatDouble(double d,
int len)
format double value |
static String[] |
getHexStrings()
|
static BitSet |
hex2BitSet(BitSet bmap,
byte[] b,
int bitOffset)
Converts an ASCII representation of a Bitmap field into a Java BitSet |
static BitSet |
hex2BitSet(byte[] b,
int offset,
boolean bitZeroMeansExtended)
Converts an ASCII representation of a Bitmap field into a Java BitSet |
static BitSet |
hex2BitSet(byte[] b,
int offset,
int maxBits)
Converts an ASCII representation of a Bitmap field into a Java BitSet |
static byte[] |
hex2byte(byte[] b,
int offset,
int len)
|
static byte[] |
hex2byte(String s)
|
static String |
hexdump(byte[] b)
|
static String |
hexdump(byte[] b,
int offset,
int len)
|
static String |
hexor(String op1,
String op2)
Bitwise XOR between corresponding byte arrays represented in hex |
static String |
hexString(byte[] b)
converts a byte array to hex string (suitable for dumps and ASCII packaging of Binary fields |
static String |
hexString(byte[] b,
int offset,
int len)
converts a byte array to hex string (suitable for dumps and ASCII packaging of Binary fields |
static BitSet |
int2BitSet(int value)
|
static BitSet |
int2BitSet(int value,
int offset)
|
static boolean |
isAlphaNumeric(String s)
Return true if the string is alphanum. |
static boolean |
isBlank(String s)
|
static boolean |
isNumeric(String s,
int radix)
Return true if the string represent a number in the specified radix. |
static boolean |
isZero(String s)
|
static String |
millisToString(long millis)
|
static String |
normalize(String s)
XML normalizer (default canonical) |
static String |
normalize(String s,
boolean canonical)
XML normalizer |
static String |
padleft(String s,
int len,
char c)
pad to the left |
static String |
padright(String s,
int len,
char c)
pad to the right |
static double |
parseAmountConversionRate(String convRate)
Parse currency amount conversion rate string Suitble for parse fields 10 and 11 |
static int |
parseInt(byte[] bArray)
Converts a byte array to an integer of radix 10. |
static int |
parseInt(byte[] bArray,
int radix)
Converts a byte array to an integer of base radix. |
static int |
parseInt(char[] cArray)
Converts a character array to an integer of radix 10. |
static int |
parseInt(char[] cArray,
int radix)
Converts a character array to an integer of base radix. |
static int |
parseInt(String s)
Converts a String to an integer of radix 10. |
static int |
parseInt(String s,
int radix)
Converts a String to an integer of base radix. |
static String |
protect(String s)
Protects PAN, Track2, CVC (suitable for logs). |
static void |
sleep(long millis)
Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds. |
static byte[] |
str2bcd(String s,
boolean padLeft)
converts to BCD |
static byte[] |
str2bcd(String s,
boolean padLeft,
byte fill)
converts to BCD |
static byte[] |
str2bcd(String s,
boolean padLeft,
byte[] d,
int offset)
converts to BCD |
static String |
strpad(String s,
int len)
pads to the right |
static String |
strpadf(String s,
int len)
pads a string with 'F's (useful for pinoffset management) |
static String |
takeFirstN(String s,
int n)
return the first n characters of the passed String, left padding where required with 0 |
static String |
takeLastN(String s,
int n)
return the last n characters of the passed String, left padding where required with 0 |
static int[] |
toIntArray(String s)
|
static String[] |
toStringArray(String s)
|
static byte[] |
trim(byte[] array,
int length)
Trims a byte[] to a certain length |
static String |
trim(String s)
trim String (if not null) |
static String |
trimf(String s)
reverse the effect of strpadf |
static String |
unPadLeft(String s,
char c)
Unpad from left. |
static String |
unPadRight(String s,
char c)
Unpad from right. |
static byte[] |
xor(byte[] op1,
byte[] op2)
Bitwise XOR between corresponding bytes |
static String |
zeropad(long l,
int len)
zeropads a long without throwing an ISOException (performs modulus operation) |
static String |
zeropad(String s,
int len)
left pad with '0' |
static String |
zeropadRight(String s,
int len)
|
static String |
zeroUnPad(String s)
Left unPad with '0' |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String[] hexStrings
public static final String ENCODING
public static final byte[] EBCDIC2ASCII
public static final byte[] ASCII2EBCDIC
public static final byte STX
public static final byte FS
public static final byte US
public static final byte RS
public static final byte GS
public static final byte ETX
| Constructor Detail |
|---|
public ISOUtil()
| Method Detail |
|---|
public static String[] getHexStrings()
public static String ebcdicToAscii(byte[] e)
public static String ebcdicToAscii(byte[] e,
int offset,
int len)
public static byte[] ebcdicToAsciiBytes(byte[] e)
public static byte[] ebcdicToAsciiBytes(byte[] e,
int offset,
int len)
public static byte[] asciiToEbcdic(String s)
public static byte[] asciiToEbcdic(byte[] a)
public static void asciiToEbcdic(String s,
byte[] e,
int offset)
public static String padleft(String s,
int len,
char c)
throws ISOException
s - - original stringlen - - desired lenc - - padding char
ISOException - on error
public static String padright(String s,
int len,
char c)
throws ISOException
s - -
original stringlen - -
desired lenc - -
padding char
ISOException - if String's length greater than pad lengthpublic static String trim(String s)
s - String to trim
public static String zeropad(String s,
int len)
throws ISOException
s - - original stringlen - - desired len
ISOException - if string's length greater than len
public static String zeropad(long l,
int len)
l - the longlen - the length
public static String strpad(String s,
int len)
s - - original stringlen - - desired len
public static String zeropadRight(String s,
int len)
public static byte[] str2bcd(String s,
boolean padLeft,
byte[] d,
int offset)
s - - the numberpadLeft - - flag indicating left/right paddingd - The byte array to copy into.offset - Where to start copying into.
public static byte[] str2bcd(String s,
boolean padLeft)
s - - the numberpadLeft - - flag indicating left/right padding
public static byte[] str2bcd(String s,
boolean padLeft,
byte fill)
s - - the numberpadLeft - - flag indicating left/right paddingfill - - fill value
public static String bcd2str(byte[] b,
int offset,
int len,
boolean padLeft)
b - - BCD representationoffset - - starting offsetlen - - BCD field lenpadLeft - - was padLeft packed?
public static String hexString(byte[] b)
b - - byte array
public static String dumpString(byte[] b)
b - - byte array
public static String hexString(byte[] b,
int offset,
int len)
b - - byte arrayoffset - - starting positionlen - the length
public static String bitSet2String(BitSet b)
b - - the BitSet
public static byte[] bitSet2byte(BitSet b)
b - - the BitSet
public static byte[] bitSet2byte(BitSet b,
int bytes)
b - - the BitSetbytes - - number of bytes to return
public static int bitSet2Int(BitSet bs)
public static BitSet int2BitSet(int value)
public static BitSet int2BitSet(int value,
int offset)
public static BitSet byte2BitSet(byte[] b,
int offset,
boolean bitZeroMeansExtended)
b - - binary representationoffset - - staring offsetbitZeroMeansExtended - - true for ISO-8583
public static BitSet byte2BitSet(byte[] b,
int offset,
int maxBits)
b - - binary representationoffset - - staring offsetmaxBits - - max number of bits (supports 64,128 or 192)
public static BitSet byte2BitSet(BitSet bmap,
byte[] b,
int bitOffset)
bmap - - BitSetb - - hex representationbitOffset - - (i.e. 0 for primary bitmap, 64 for secondary)
public static BitSet hex2BitSet(byte[] b,
int offset,
boolean bitZeroMeansExtended)
b - - hex representationoffset - - starting offsetbitZeroMeansExtended - - true for ISO-8583
public static BitSet hex2BitSet(byte[] b,
int offset,
int maxBits)
b - - hex representationoffset - - starting offsetmaxBits - - max number of bits (supports 8, 16, 24, 32, 48, 52, 64,.. 128 or 192)
public static BitSet hex2BitSet(BitSet bmap,
byte[] b,
int bitOffset)
bmap - - BitSetb - - hex representationbitOffset - - (i.e. 0 for primary bitmap, 64 for secondary)
public static byte[] hex2byte(byte[] b,
int offset,
int len)
b - source byte arrayoffset - starting offsetlen - number of bytes in destination (processes len*2)
public static byte[] hex2byte(String s)
s - source string (with Hex representation)
public static String formatDouble(double d,
int len)
d - the amountlen - the field len
public static String formatAmount(long l,
int len)
throws ISOException
l - valuelen - display len
ISOException
public static String normalize(String s,
boolean canonical)
s - source Stringcanonical - true if we want to normalize \r and \n as well
public static String normalize(String s)
s - source String
public static String protect(String s)
"40000101010001" is converted to "400001____0001" "40000101010001=020128375" is converted to "400001____0001=0201_____" "40000101010001D020128375" is converted to "400001____0001D0201_____" "123" is converted to "___"
s - string to be protected
public static int[] toIntArray(String s)
public static String[] toStringArray(String s)
public static byte[] xor(byte[] op1,
byte[] op2)
op1 - byteArray1op2 - byteArray2
public static String hexor(String op1,
String op2)
op1 - hexstring 1op2 - hexstring 2
public static byte[] trim(byte[] array,
int length)
array - the byte[] to be trimmedlength - the wanted length
public static byte[] concat(byte[] array1,
byte[] array2)
array1 - array2 -
public static byte[] concat(byte[] array1,
int beginIndex1,
int length1,
byte[] array2,
int beginIndex2,
int length2)
array1 - beginIndex1 - length1 - array2 - beginIndex2 - length2 -
public static void sleep(long millis)
millis - the length of time to sleep in milliseconds.public static String zeroUnPad(String s)
s - - original string
public static String blankUnPad(String s)
s - - original string
public static String unPadRight(String s,
char c)
s - - original stringc - - padding char
public static String unPadLeft(String s,
char c)
s - - original stringc - - padding char
public static boolean isZero(String s)
public static boolean isBlank(String s)
public static boolean isAlphaNumeric(String s)
{letter digit (.) (_) (-) ( ) (?) }
public static boolean isNumeric(String s,
int radix)
public static byte[] bitSet2extendedByte(BitSet b)
b - the BitSet
public static int parseInt(String s,
int radix)
throws NumberFormatException
s - String representation of numberradix - Number base to use
NumberFormatException
public static int parseInt(String s)
throws NumberFormatException
s - String representation of number
NumberFormatException
public static int parseInt(char[] cArray,
int radix)
throws NumberFormatException
cArray - Character Array representation of numberradix - Number base to use
NumberFormatException
public static int parseInt(char[] cArray)
throws NumberFormatException
cArray - Character Array representation of number
NumberFormatException
public static int parseInt(byte[] bArray,
int radix)
throws NumberFormatException
bArray - Byte Array representation of numberradix - Number base to use
NumberFormatException
public static int parseInt(byte[] bArray)
throws NumberFormatException
bArray - Byte Array representation of number
NumberFormatExceptionpublic static String hexdump(byte[] b)
b - a byte[] buffer
public static String hexdump(byte[] b,
int offset,
int len)
b - a byte[] bufferoffset - starting offsetlen - the Length
public static String strpadf(String s,
int len)
s - an [hex]stringlen - desired length
public static String trimf(String s)
s - F padded string
public static String takeLastN(String s,
int n)
throws ISOException
s - String to take fromn - nuber of characters to take
ISOException
public static String takeFirstN(String s,
int n)
throws ISOException
s - String to take fromn - nuber of characters to take
ISOExceptionpublic static String millisToString(long millis)
public static String formatAmountConversionRate(double convRate)
throws ISOException
convRate - - amount conversion rate
ISOExceptionpublic static double parseAmountConversionRate(String convRate)
convRate - amount conversation rate
IllegalArgumentExceptionpublic static String commaEncode(String[] ss)
ss - string array to be comma encoded
commaDecode(String)public static String[] commaDecode(String s)
s - the command encoded String
commaEncode(String[])
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||