|
||||||||||
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 byte |
ETX
|
static byte |
FS
|
static byte |
GS
|
static byte |
RS
|
static byte |
STX
|
static byte |
US
|
Constructor Summary | |
---|---|
ISOUtil()
|
Method Summary | |
---|---|
static byte[] |
asciiToEbcdic(byte[] a)
|
static byte[] |
asciiToEbcdic(java.lang.String s)
|
static void |
asciiToEbcdic(java.lang.String s,
byte[] e,
int offset)
|
static java.lang.String |
bcd2str(byte[] b,
int offset,
int len,
boolean padLeft)
converts a BCD representation of a number to a String |
static byte[] |
bitSet2byte(java.util.BitSet b)
converts a BitSet into a binary field used in pack routines |
static byte[] |
bitSet2byte(java.util.BitSet b,
int bytes)
converts a BitSet into a binary field used in pack routines |
static byte[] |
bitSet2extendedByte(java.util.BitSet b)
Converts a BitSet into an extended binary field used in pack routines. |
static java.lang.String |
bitSet2String(java.util.BitSet b)
bit representation of a BitSet suitable for dumps and debugging |
static java.lang.String |
blankUnPad(java.lang.String s)
Right unPad with ' ' |
static java.util.BitSet |
byte2BitSet(java.util.BitSet bmap,
byte[] b,
int bitOffset)
Converts a binary representation of a Bitmap field into a Java BitSet |
static java.util.BitSet |
byte2BitSet(byte[] b,
int offset,
boolean bitZeroMeansExtended)
Converts a binary representation of a Bitmap field into a Java BitSet |
static java.util.BitSet |
byte2BitSet(byte[] b,
int offset,
int maxBits)
Converts a binary representation of a Bitmap field into a Java BitSet |
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 java.lang.String |
dumpString(byte[] b)
converts a byte array to printable characters |
static java.lang.String |
ebcdicToAscii(byte[] e)
|
static java.lang.String |
ebcdicToAscii(byte[] e,
int offset,
int len)
|
static byte[] |
ebcdicToAsciiBytes(byte[] e)
|
static byte[] |
ebcdicToAsciiBytes(byte[] e,
int offset,
int len)
|
static java.lang.String |
formatAmount(long l,
int len)
prepare long value used as amount for display (implicit 2 decimals) |
static java.lang.String |
formatDouble(double d,
int len)
format double value |
static java.util.BitSet |
hex2BitSet(java.util.BitSet bmap,
byte[] b,
int bitOffset)
Converts an ASCII representation of a Bitmap field into a Java BitSet |
static java.util.BitSet |
hex2BitSet(byte[] b,
int offset,
boolean bitZeroMeansExtended)
Converts an ASCII representation of a Bitmap field into a Java BitSet |
static java.util.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(java.lang.String s)
|
static java.lang.String |
hexdump(byte[] b)
|
static java.lang.String |
hexdump(byte[] b,
int offset,
int len)
|
static java.lang.String |
hexor(java.lang.String op1,
java.lang.String op2)
Bitwise XOR between corresponding byte arrays represented in hex |
static java.lang.String |
hexString(byte[] b)
converts a byte array to hex string (suitable for dumps and ASCII packaging of Binary fields |
static java.lang.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 boolean |
isAlphaNumeric(java.lang.String s)
Return true if the string is alphanum. |
static boolean |
isBlank(java.lang.String s)
|
static boolean |
isNumeric(java.lang.String s,
int radix)
Return true if the string represent a number in the specified radix. |
static boolean |
isZero(java.lang.String s)
|
static java.lang.String |
normalize(java.lang.String s)
XML normalizer (default canonical) |
static java.lang.String |
normalize(java.lang.String s,
boolean canonical)
XML normalizer |
static java.lang.String |
padleft(java.lang.String s,
int len,
char c)
pad to the left |
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(java.lang.String s)
Converts a String to an integer of radix 10. |
static int |
parseInt(java.lang.String s,
int radix)
Converts a String to an integer of base radix. |
static java.lang.String |
protect(java.lang.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(java.lang.String s,
boolean padLeft)
converts to BCD |
static byte[] |
str2bcd(java.lang.String s,
boolean padLeft,
byte fill)
converts to BCD |
static byte[] |
str2bcd(java.lang.String s,
boolean padLeft,
byte[] d,
int offset)
converts to BCD |
static java.lang.String |
strpad(java.lang.String s,
int len)
pads to the right |
static java.lang.String |
strpadf(java.lang.String s,
int len)
pads a string with 'F's (useful for pinoffset management) |
static int[] |
toIntArray(java.lang.String s)
|
static java.lang.String[] |
toStringArray(java.lang.String s)
|
static byte[] |
trim(byte[] array,
int length)
Trims a byte[] to a certain length |
static java.lang.String |
trim(java.lang.String s)
trim String (if not null) |
static java.lang.String |
trimf(java.lang.String s)
reverse the effect of strpadf |
static java.lang.String |
unPadLeft(java.lang.String s,
char c)
Unpad from left. |
static java.lang.String |
unPadRight(java.lang.String s,
char c)
Unpad from right. |
static byte[] |
xor(byte[] op1,
byte[] op2)
Bitwise XOR between corresponding bytes |
static java.lang.String |
zeropad(java.lang.String s,
int len)
left pad with '0' |
static java.lang.String |
zeropadRight(java.lang.String s,
int len)
|
static java.lang.String |
zeroUnPad(java.lang.String s)
Left unPad with '0' |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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 java.lang.String ebcdicToAscii(byte[] e)
public static java.lang.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(java.lang.String s)
public static byte[] asciiToEbcdic(byte[] a)
public static void asciiToEbcdic(java.lang.String s, byte[] e, int offset)
public static java.lang.String padleft(java.lang.String s, int len, char c) throws ISOException
s
- - original stringlen
- - desired lenc
- - padding char
ISOException
public static java.lang.String trim(java.lang.String s)
s
- String to trim
public static java.lang.String zeropad(java.lang.String s, int len) throws ISOException
s
- - original stringlen
- - desired len
ISOException
public static java.lang.String strpad(java.lang.String s, int len)
s
- - original stringlen
- - desired len
public static java.lang.String zeropadRight(java.lang.String s, int len)
public static byte[] str2bcd(java.lang.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(java.lang.String s, boolean padLeft)
s
- - the numberpadLeft
- - flag indicating left/right padding
public static byte[] str2bcd(java.lang.String s, boolean padLeft, byte fill)
s
- - the numberpadLeft
- - flag indicating left/right paddingfill
- - fill value
public static java.lang.String bcd2str(byte[] b, int offset, int len, boolean padLeft)
b
- - BCD representationoffset
- - starting offsetlen
- - BCD field lenpadLeft
- - was padLeft packed?
public static java.lang.String hexString(byte[] b)
b
- - byte array
public static java.lang.String dumpString(byte[] b)
b
- - byte array
public static java.lang.String hexString(byte[] b, int offset, int len)
b
- - byte arrayoffset
- - starting positionlen
-
public static java.lang.String bitSet2String(java.util.BitSet b)
b
- - the BitSet
public static byte[] bitSet2byte(java.util.BitSet b)
b
- - the BitSet
public static byte[] bitSet2byte(java.util.BitSet b, int bytes)
b
- - the BitSetbytes
- - number of bytes to return
public static java.util.BitSet byte2BitSet(byte[] b, int offset, boolean bitZeroMeansExtended)
b
- - binary representationoffset
- - staring offsetbitZeroMeansExtended
- - true for ISO-8583
public static java.util.BitSet byte2BitSet(byte[] b, int offset, int maxBits)
b
- - binary representationoffset
- - staring offsetmaxBits
- - max number of bits (supports 64,128 or 192)
public static java.util.BitSet byte2BitSet(java.util.BitSet bmap, byte[] b, int bitOffset)
bmap
- - BitSetb
- - hex representationbitOffset
- - (i.e. 0 for primary bitmap, 64 for secondary)
public static java.util.BitSet hex2BitSet(byte[] b, int offset, boolean bitZeroMeansExtended)
b
- - hex representationoffset
- - starting offsetbitZeroMeansExtended
- - true for ISO-8583
public static java.util.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 java.util.BitSet hex2BitSet(java.util.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(java.lang.String s)
s
- source string (with Hex representation)
public static java.lang.String formatDouble(double d, int len)
amount
- the amountfieldLen
- the field len
public static java.lang.String formatAmount(long l, int len) throws ISOException
l
- valuelen
- display len
ISOException
public static java.lang.String normalize(java.lang.String s, boolean canonical)
s
- source Stringcanonical
- true if we want to normalize \r and \n as well
public static java.lang.String normalize(java.lang.String s)
s
- source String
public static java.lang.String protect(java.lang.String s)
"40000101010001" is converted to "400001____0001" "40000101010001=020128375" is converted to "400001____0001=0201_____" "123" is converted to "___"
s
- string to be protected
public static int[] toIntArray(java.lang.String s)
public static java.lang.String[] toStringArray(java.lang.String s)
public static byte[] xor(byte[] op1, byte[] op2)
op1
- byteArray1op2
- byteArray2
public static java.lang.String hexor(java.lang.String op1, java.lang.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 java.lang.String zeroUnPad(java.lang.String s)
s
- - original string
public static java.lang.String blankUnPad(java.lang.String s)
s
- - original string
public static java.lang.String unPadRight(java.lang.String s, char c)
s
- - original stringc
- - padding char
public static java.lang.String unPadLeft(java.lang.String s, char c)
s
- - original stringc
- - padding char
public static boolean isZero(java.lang.String s)
public static boolean isBlank(java.lang.String s)
public static boolean isAlphaNumeric(java.lang.String s)
{letter digit (.) (_) (-) ( ) (?) }
public static boolean isNumeric(java.lang.String s, int radix)
public static byte[] bitSet2extendedByte(java.util.BitSet b)
b
- the BitSet
public static int parseInt(java.lang.String s, int radix) throws java.lang.NumberFormatException
s
- String representation of numberradix
- Number base to use
java.lang.NumberFormatException
public static int parseInt(java.lang.String s) throws java.lang.NumberFormatException
s
- String representation of number
java.lang.NumberFormatException
public static int parseInt(char[] cArray, int radix) throws java.lang.NumberFormatException
cArray
- Character Array representation of numberradix
- Number base to use
java.lang.NumberFormatException
public static int parseInt(char[] cArray) throws java.lang.NumberFormatException
cArray
- Character Array representation of number
java.lang.NumberFormatException
public static int parseInt(byte[] bArray, int radix) throws java.lang.NumberFormatException
bArray
- Byte Array representation of numberradix
- Number base to use
java.lang.NumberFormatException
public static int parseInt(byte[] bArray) throws java.lang.NumberFormatException
bArray
- Byte Array representation of number
java.lang.NumberFormatException
public static java.lang.String hexdump(byte[] b)
b
- a byte[] buffer
public static java.lang.String hexdump(byte[] b, int offset, int len)
b
- a byte[] bufferoffset
- starting offsetlen
- the Length
public static java.lang.String strpadf(java.lang.String s, int len)
s
- an [hex]stringlen
- desired length
public static java.lang.String trimf(java.lang.String s)
s
- F padded string
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |