|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.clazzes.util.lang.Util
public class Util
Nested Class Summary | |
---|---|
static class |
Util.OperatingSystem
Enumeration of all OS we are able to detect |
Field Summary | |
---|---|
static java.lang.String |
CHARSET_ASCII
|
static java.lang.String |
CHARSET_ISO88591
|
static java.lang.String |
CHARSET_UTF8
|
Method Summary | |
---|---|
static byte[] |
asBCD16(int pin)
Computes an byte[2] containing the BCD representation of the given int |
static java.lang.String |
asHex(byte[] buf)
Turns array of bytes into string. |
static java.lang.String |
asHex(byte[] buf,
java.lang.String sep)
Turns array of bytes into string. |
static int |
byteToU8(byte b)
Converts a (pseudo-signed) byte to an unsigned 8 bit value. |
static byte[] |
concat(byte[] a,
byte[] b)
Copy two Byte arrays into a single resulting Byte array. |
static byte[] |
createZeroTerminatedString(java.lang.String s)
Converts a String object to an byte[] containing the ASCII coded string and a 0 byte. |
static byte[] |
createZeroTerminatedString(java.lang.String s,
java.lang.String charset)
Converts a String object to an byte[] containing the string coded with the given charset and a 0 byte. |
static int |
decodeBCD(byte[] ba)
Decodes a BCD coded integer |
static byte[] |
decodeHexstring(java.lang.String s)
Decodes a string contain hex digits to a byte[] |
static boolean |
equals(byte[] a,
byte[] b)
Test if two Byte arrays are equal. |
static boolean |
equalsNullAware(java.lang.Object a,
java.lang.Object b)
Compares a and b and returns true, if both values are null or both are equal. |
static byte[] |
filledByteArray(int length,
byte fillWith)
Procudes an explicitely filled byte array with the given length. |
static byte[] |
fillUp(byte[] src,
int length,
byte fillWith)
Fills up a Byte Array to a multiple of x Bytes. fillUp(byte[12], 16, 0x00) will produce a byte[16], the last 4 Bytes are 0x00. |
static java.util.Calendar |
getCalendar(int year,
int month,
int day)
Get a Calendar-Object for the given date (starting at 00:00:00.000. |
static int |
getCRC32(byte[] data)
Calculate a standard CRC32 Checksum using java.util.zip.CRC32. |
static Util.OperatingSystem |
getOperatingSystem()
Returns which type of OS we have, after dedecting if necessary |
static byte[] |
getRandom(int len)
Give me a SecureRandom of a desired length. |
static byte[] |
getSHA1hash(byte[] input)
Give me the SHA1 Value of a Byte array. |
static java.lang.String |
getSHA1hash(java.lang.String str)
Give me the SHA1 Value of a String. |
static java.util.Calendar |
getUTCnow()
|
static java.util.Calendar |
getUTCtimestamp(long millis)
|
static byte[] |
invert(byte[] a)
Invert a Byte array. |
static boolean |
inWindows()
Tells if we are under M$ Windows, after checking if necessary |
static java.lang.String |
parseZeroTerminatedString(byte[] ba)
Converts a zero terminated ASCII string to a java String object, suggesting ASCII charset. |
static java.lang.String |
parseZeroTerminatedString(byte[] ba,
java.lang.String charset)
Converts a zero terminated ASCII string to a java String object, using the given charset. |
static byte[] |
subArray(byte[] src,
int offset,
int length)
|
static byte |
u8ToByte(int u)
Converts an unsigned 8 bit value to a (pseudo-signed) byte. |
static byte[] |
xor(byte[] a,
byte[] b)
Calculate the XOR between two Byte arrays; |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CHARSET_ASCII
public static final java.lang.String CHARSET_ISO88591
public static final java.lang.String CHARSET_UTF8
Method Detail |
---|
public static boolean equalsNullAware(java.lang.Object a, java.lang.Object b)
a
- The first object to compare.b
- The second object to compare.
true
, if a==null && b==null
or a.equals(b)
.public static int getCRC32(byte[] data)
data
- The Bytes to calculate the Checksum from.
public static byte[] fillUp(byte[] src, int length, byte fillWith)
src
- The Byte Array to fill up.length
- The src ByteArray will be filled up to a length of n*length
Bytes.fillWith
- The value of the extra Bytes.
public static byte[] filledByteArray(int length, byte fillWith)
length
- The length of the byte array to be created.fillWith
- The value of all bytes of the new byte array.
public static java.util.Calendar getUTCnow()
public static java.util.Calendar getUTCtimestamp(long millis)
public static java.util.Calendar getCalendar(int year, int month, int day)
year
- The human readable year (2006)month
- The human readable month (April = 4)day
- The day of the month.
public static byte[] xor(byte[] a, byte[] b)
a
- b
-
java.lang.Exception
public static byte[] invert(byte[] a)
a
-
java.lang.Exception
public static byte[] getRandom(int len)
len
- The Length of the random value.
public static byte[] getSHA1hash(byte[] input) throws java.lang.Exception
input
-
java.lang.Exception
public static java.lang.String getSHA1hash(java.lang.String str) throws java.lang.Exception
input
-
java.lang.Exception
public static boolean equals(byte[] a, byte[] b) throws java.lang.NullPointerException
a
- b
-
java.lang.NullPointerException
public static byte[] concat(byte[] a, byte[] b)
a
- b
-
public static byte[] subArray(byte[] src, int offset, int length)
public static java.lang.String asHex(byte[] buf)
buf
- Array of bytes to convert to hex string, with a space between
each byte.
public static java.lang.String asHex(byte[] buf, java.lang.String sep)
buf
- Array of bytes to convert to hex string.sep
- Separator to put between each byte, null stands for ""
public static byte[] decodeHexstring(java.lang.String s)
s
- The string to decode.
some
- runtimeexceptions if the string is invalidpublic static int byteToU8(byte b)
u
-
public static byte u8ToByte(int u)
u
-
public static byte[] createZeroTerminatedString(java.lang.String s)
s
-
public static byte[] createZeroTerminatedString(java.lang.String s, java.lang.String charset)
s
- charset
- We recommend to use this class' CHARSET_* constants
public static java.lang.String parseZeroTerminatedString(byte[] ba)
ba
-
public static java.lang.String parseZeroTerminatedString(byte[] ba, java.lang.String charset)
ba
- charset
- We recommend to use this class' CHARSET_* constants
public static Util.OperatingSystem getOperatingSystem()
public static boolean inWindows()
public static byte[] asBCD16(int pin)
pin
- The pin to encodde, 1 .. 9999
public static int decodeBCD(byte[] ba)
ba
- The bytearray containing the BCD bytes
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |