public class Utils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.text.SimpleDateFormat |
RESULT_FILENAME_FRAGMENT_DATE_FORMAT
A simple date format with the pattern "yyyy-MM-dd@HH-mm-ss".
|
static java.text.SimpleDateFormat |
SIMPLE_DATE_FORMAT
A simple date format with the pattern "yyyy-MM-dd HH:mm:ss".
|
static java.text.SimpleDateFormat |
SIMPLE_DATE_FORMAT_WITH_MILLIS
A simple date format with the pattern "yyyy-MM-dd HH:mm:ss.SSS".
|
static java.text.SimpleDateFormat |
SOURCE_FILE_DATE_FORMAT
A simple date format with the pattern "dd MMM yyyy HH:mm:ss".
|
Modifier and Type | Method and Description |
---|---|
static int |
binaryIndex(byte[] src,
byte[] pattern)
Get the index of a binary pattern within binary data.
|
static int |
binaryIndex(byte[] data,
byte[] searchFragment,
int offset)
Search inside binary data for a fragment of data, starting at a specific offset.
|
static java.lang.String |
bytesToHex(byte[] bytes)
Convert a byte array to a hex string.
|
static int |
caseInsensitiveIndexOf(java.lang.String text,
java.lang.String search)
Perform a case insensitive 'index of'.
|
static java.lang.String |
formatTimestamp(long timestamp)
Format an absolute date and time to a string.
|
static java.lang.String |
formatTimestamp(java.util.TimeZone timeZone,
long timestamp)
Format an absolute date and time to a string by using a specific time zone.
|
static java.lang.String |
formatTimestampInSourceFileFormat(long timestamp)
Format an absolute date and time to a string in 'source file date format'.
|
static java.lang.String |
formatTimestampInSourceFileFormat(java.util.TimeZone timeZone,
long timestamp)
Format an absolute date and time to a string in 'source file date format' by using a specific time zone.
|
static java.lang.String |
formatTimestampResultFileNameFragmentFormat(long timestamp)
Format an absolute date and time to a string in 'result file name fragment format'.
|
static java.lang.String |
formatTimestampResultFileNameFragmentFormat(java.util.TimeZone timeZone,
long timestamp)
Format an absolute date and time to a string in 'result file name fragment format' by using a specific time zone.
|
static java.lang.String |
formatTimestampWithMillis(long timestamp)
Format an absolute date and time to a string which includes also milliseconds.
|
static java.lang.String |
formatTimestampWithMillis(java.util.TimeZone timeZone,
long timestamp)
Format an absolute date and time to a string which includes also milliseconds by using a specific time zone.
|
static java.util.TimeZone |
getDefaultTimeZone()
Get the default time zone.
|
static java.lang.String |
getStrippedFileName(java.io.File file)
Get from a file the file name without extension
|
static byte[] |
gUnZip(byte[] b)
Decompress a byte array which was compressed by the GZIP algorithm.
|
static byte[] |
inflate(byte[] b)
Inflate a byte array which was compressed by the ZLIB algorithm.
|
static boolean |
is90HumanReadableASCII(byte[] bytes)
Get if an array of bytes contains at least 90% human readable ASCII chars.
|
static boolean |
isFormalValidVariableName(java.lang.String variableName)
Verify if the name of a variable is formal valid.
|
static boolean |
matchToWildcardString(java.lang.String checkString,
java.lang.String wildcardString)
Check if a text string mach to another text string which contains one ore more wildcard chars.
|
static java.lang.String |
stripFileExtension(java.lang.String fileName)
Get from a file name with extension the file name without extension
|
public static final java.text.SimpleDateFormat SIMPLE_DATE_FORMAT
public static final java.text.SimpleDateFormat SIMPLE_DATE_FORMAT_WITH_MILLIS
public static final java.text.SimpleDateFormat SOURCE_FILE_DATE_FORMAT
public static final java.text.SimpleDateFormat RESULT_FILENAME_FRAGMENT_DATE_FORMAT
public static java.lang.String formatTimestamp(long timestamp)
timestamp
- the absolute date and time (Unix time)SIMPLE_DATE_FORMAT
public static java.lang.String formatTimestamp(java.util.TimeZone timeZone, long timestamp)
timeZone
- the time zonetimestamp
- the absolute date and time (Unix time)SIMPLE_DATE_FORMAT
public static java.lang.String formatTimestampWithMillis(long timestamp)
timestamp
- the absolute date and time (Unix time)SIMPLE_DATE_FORMAT_WITH_MILLIS
public static java.lang.String formatTimestampWithMillis(java.util.TimeZone timeZone, long timestamp)
timeZone
- the time zonetimestamp
- the absolute date and time (Unix time)SIMPLE_DATE_FORMAT_WITH_MILLIS
public static java.lang.String formatTimestampInSourceFileFormat(long timestamp)
timestamp
- the absolute date and time (Unix time)SOURCE_FILE_DATE_FORMAT
public static java.lang.String formatTimestampInSourceFileFormat(java.util.TimeZone timeZone, long timestamp)
timeZone
- the time zonetimestamp
- the absolute date and time (Unix time)SOURCE_FILE_DATE_FORMAT
public static java.lang.String formatTimestampResultFileNameFragmentFormat(long timestamp)
timestamp
- the absolute date and time (Unix time)RESULT_FILENAME_FRAGMENT_DATE_FORMAT
public static java.lang.String formatTimestampResultFileNameFragmentFormat(java.util.TimeZone timeZone, long timestamp)
timeZone
- the time zonetimestamp
- the absolute date and time (Unix time)RESULT_FILENAME_FRAGMENT_DATE_FORMAT
public static java.util.TimeZone getDefaultTimeZone()
public static boolean matchToWildcardString(java.lang.String checkString, java.lang.String wildcardString)
checkString
- the string to checkwildcardString
- the matching string which can contain wildcards '?' and/or '*'public static byte[] gUnZip(byte[] b) throws java.io.IOException
b
- the byte array to decompressjava.io.IOException
- if the decompression failspublic static byte[] inflate(byte[] b) throws java.io.IOException
b
- the byte array to inflatejava.io.IOException
- if the inflation failspublic static int caseInsensitiveIndexOf(java.lang.String text, java.lang.String search)
text
- the textsearch
- the search fragmentpublic static int binaryIndex(byte[] src, byte[] pattern)
src
- the binary datapattern
- the binary patternpublic static int binaryIndex(byte[] data, byte[] searchFragment, int offset)
data
- the binary datasearchFragment
- the fragment to searchoffset
- the offset where the search starts inside the binary data (0..n-1)public static boolean is90HumanReadableASCII(byte[] bytes)
bytes
- the array of bytespublic static boolean isFormalValidVariableName(java.lang.String variableName)
variableName
- the name of the variablepublic static java.lang.String stripFileExtension(java.lang.String fileName)
fileName
- the file name with extensionpublic static java.lang.String getStrippedFileName(java.io.File file)
file
- the filepublic static java.lang.String bytesToHex(byte[] bytes)
bytes
- the byte array to convert