public final class Util
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG |
static boolean |
JAVA_COMPRESS |
Modifier and Type | Method and Description |
---|---|
static int |
canonicalHashKey(java.lang.String text)
Computes a hash key on a canonical (OS independent) form of a text.
|
static java.lang.String |
compress(java.lang.String str)
Compress a string.
|
static java.lang.String |
compress(java.lang.String src,
java.lang.StringBuffer dest)
Compress a string.
|
static java.lang.String |
compressJava(java.lang.String str)
Compress a string.
|
static java.lang.String |
compressJava(java.lang.String str,
boolean addHeader)
Compress a string.
|
static void |
debug(java.lang.String s)
Deprecated.
|
static java.lang.String |
firstLine(java.lang.String text)
Deprecated.
Moved to class ifs.fnd.util.Str
|
static java.lang.String |
formatDuration(long durationMillis)
Format time duration as a string using format "[days:]HH:mm:ss.SSS".
|
static java.lang.String |
formatElapsedTime(long milliseconds)
Format time showing separately hours, minutes and seconds.
|
static java.lang.String |
formatMessage(java.lang.String message,
java.lang.Object... p)
Deprecated.
Moved to class ifs.fnd.util.Str
|
static byte[] |
fromBase64Text(java.lang.String text)
Perform the BASE64 decoding of the specified string.
|
static byte[] |
fromHexText(java.lang.String text)
Transform a hexadecimal string into an array of bytes.
|
static java.text.NumberFormat |
getIntegerFormat()
Get a new number formatter suitable for big integer numbers.
|
static java.lang.String |
getShortDescription(java.lang.Throwable t)
Returns short description of a Throwable.
|
static java.lang.String |
getShortMessage(java.lang.Throwable t)
Returns short message from a Throwable.
|
static java.lang.String |
getStackTrace(java.lang.Throwable t)
Returns the current stack formatted as one String.
|
static void |
initClass(java.lang.Class cls)
Forces the initialization of a class.
|
static boolean |
isDebugEnabled()
Check if debugging is enabled.
|
static boolean |
isDebugEnabled(java.lang.String className)
Check if debugging of a specific class is enabled.
|
static boolean |
isTraceFileDebugEnabled()
Check if debug text should be written to the trace file.
|
static java.lang.String |
lpad(java.lang.String str,
int length)
Deprecated.
Moved to class ifs.fnd.util.Str
|
static java.lang.String |
lpad(java.lang.String str,
int length,
char ch)
Deprecated.
Moved to class ifs.fnd.util.Str
|
static <E> java.util.ArrayList<E> |
newArrayList()
Factory method for generic ArrayList.
|
static <E> java.util.ArrayList<E> |
newArrayList(int initialCapacity)
Factory method for generic ArrayList.
|
static <K,V> java.util.HashMap<K,V> |
newHashMap()
Factory method for generic HashMap.
|
static <K,V> java.util.HashMap<K,V> |
newHashMap(int initialCapacity)
Factory method for generic HashMap.
|
static <E> java.util.HashSet<E> |
newHashSet()
Factory method for generic HashSet.
|
static <K,V> java.util.LinkedHashMap<K,V> |
newLinkedHashMap()
Factory method for generic LinkedHashMap.
|
static <E> java.util.LinkedHashSet<E> |
newLinkedHashSet()
Factory method for generic LinkedHashSet.
|
static <E> SimpleStack<E> |
newSimpleStack()
Factory method for generic SimpleStack.
|
static <K,V> java.util.TreeMap<K,V> |
newTreeMap()
Factory method for generic TreeMap.
|
static <E> java.util.TreeSet<E> |
newTreeSet()
Factory method for generic TreeSet.
|
static java.lang.String |
readAndTrimFile(java.lang.String filename)
Deprecated.
Moved to the new utility class ifs.fnd.util.IoUtil
|
static java.lang.String |
rpad(java.lang.String str,
int length)
Deprecated.
Moved to class ifs.fnd.util.Str
|
static java.lang.String |
rpad(java.lang.String str,
int length,
char ch)
Deprecated.
Moved to class ifs.fnd.util.Str
|
static void |
showException(java.lang.Throwable t)
Output the details of the specified exception to standard output.
|
static java.lang.String |
toBase64Text(byte[] data)
Perform the BASE64 encoding of the specified array of bytes.
|
static java.lang.String |
toHexText(byte[] data)
Transform an array of bytes into its hexadecimal representation.
|
static java.lang.String |
trimLine(java.lang.String value)
Deprecated.
Moved to class ifs.fnd.util.Str
|
static java.lang.String |
uncompress(java.lang.String str)
Uncompress a string.
|
static java.lang.String |
uncompress(java.lang.String src,
java.lang.StringBuffer dest)
Uncompress a string.
|
static java.lang.String |
uncompressJava(java.lang.String str)
Uncompress a string.
|
static void |
writeFile(java.lang.String filename,
java.lang.String str)
Deprecated.
Moved to the new utility class ifs.fnd.util.IoUtil
|
public static final boolean DEBUG
public static final boolean JAVA_COMPRESS
public static void debug(java.lang.String s)
s
- a text to print to the consolepublic static java.lang.String compress(java.lang.String str) throws FndException, java.io.IOException, java.util.zip.ZipException
str
- a string to compressFndException
java.io.IOException
java.util.zip.ZipException
public static java.lang.String uncompress(java.lang.String str) throws FndException, java.io.IOException, java.util.zip.ZipException
str
- a string to uncompressFndException
java.io.IOException
java.util.zip.ZipException
public static java.lang.String compress(java.lang.String src, java.lang.StringBuffer dest) throws FndException, java.io.IOException, java.util.zip.ZipException
src
- a string to compressdest
- destination bufferFndException
java.io.IOException
java.util.zip.ZipException
public static java.lang.String uncompress(java.lang.String src, java.lang.StringBuffer dest) throws FndException, java.io.IOException, java.util.zip.ZipException
src
- a compressed stringFndException
java.io.IOException
java.util.zip.ZipException
public static java.lang.String compressJava(java.lang.String str) throws java.io.IOException, java.util.zip.ZipException
str
- a string to compressjava.io.IOException
java.util.zip.ZipException
public static java.lang.String compressJava(java.lang.String str, boolean addHeader) throws java.io.IOException, java.util.zip.ZipException
str
- a string to compressjava.io.IOException
java.util.zip.ZipException
public static java.lang.String uncompressJava(java.lang.String str) throws java.io.IOException, java.util.zip.ZipException
str
- a compressed stringjava.io.IOException
java.util.zip.ZipException
public static java.lang.String toBase64Text(byte[] data) throws java.io.IOException
java.io.IOException
public static byte[] fromBase64Text(java.lang.String text) throws java.io.IOException
java.io.IOException
public static java.lang.String toHexText(byte[] data)
public static byte[] fromHexText(java.lang.String text)
public static boolean isDebugEnabled(java.lang.String className)
public static boolean isDebugEnabled()
public static boolean isTraceFileDebugEnabled()
public static void initClass(java.lang.Class cls)
cls
- the class to initializepublic static java.lang.String formatElapsedTime(long milliseconds)
milliseconds
- the number of milliseconds to formatpublic static java.lang.String formatDuration(long durationMillis)
durationMillis
- the duration to formatpublic static java.text.NumberFormat getIntegerFormat()
public static int canonicalHashKey(java.lang.String text)
text
- a text to compute the hash key onpublic static <E> java.util.HashSet<E> newHashSet()
E
- the type of set elementspublic static <E> java.util.TreeSet<E> newTreeSet()
E
- the type of set elementspublic static <E> java.util.LinkedHashSet<E> newLinkedHashSet()
E
- the type of set elementspublic static <K,V> java.util.HashMap<K,V> newHashMap()
K
- the type of map keysV
- the type of map valuespublic static <K,V> java.util.HashMap<K,V> newHashMap(int initialCapacity)
K
- the type of map keysV
- the type of map valuesinitialCapacity
- the initial capacity of the listpublic static <K,V> java.util.TreeMap<K,V> newTreeMap()
K
- the type of map keysV
- the type of map valuespublic static <K,V> java.util.LinkedHashMap<K,V> newLinkedHashMap()
K
- the type of map keysV
- the type of map valuespublic static <E> java.util.ArrayList<E> newArrayList()
E
- the type of array elementspublic static <E> java.util.ArrayList<E> newArrayList(int initialCapacity)
E
- the type of array elementsinitialCapacity
- the initial capacity of the listpublic static <E> SimpleStack<E> newSimpleStack()
E
- the type of stack elementspublic static java.lang.String getStackTrace(java.lang.Throwable t)
t
- a Throwablepublic static java.lang.String getShortDescription(java.lang.Throwable t)
t
- Throwable to extract description frompublic static java.lang.String getShortMessage(java.lang.Throwable t)
t
- Throwable to extract message frompublic static void showException(java.lang.Throwable t)
t
- an exceptionpublic static java.lang.String readAndTrimFile(java.lang.String filename) throws FndException
filename
- a file nameFndException
IoUtil.readAndTrimFile(java.lang.String)
public static void writeFile(java.lang.String filename, java.lang.String str) throws java.io.IOException
filename
- file namestr
- file contentsjava.io.IOException
IoUtil.writeFile(java.lang.String, java.lang.String)
public static java.lang.String formatMessage(java.lang.String message, java.lang.Object... p)
public static java.lang.String lpad(java.lang.String str, int length)
Str.lpad(java.lang.String, int)
public static java.lang.String lpad(java.lang.String str, int length, char ch)
Str.lpad(java.lang.String, int, char)
public static java.lang.String rpad(java.lang.String str, int length)
Str.rpad(java.lang.String, int)
public static java.lang.String rpad(java.lang.String str, int length, char ch)
Str.rpad(java.lang.String, int, char)
public static java.lang.String trimLine(java.lang.String value)
value
- a string to trimStr.trimLine(java.lang.String)
public static java.lang.String firstLine(java.lang.String text)
text
- a textStr.firstLine(java.lang.String)