public final class Util
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
Util.Comparable |
static class |
Util.IntegerSortAsc |
static class |
Util.IntegerSortDesc |
static class |
Util.LongSortAsc |
static class |
Util.LongSortDesc |
static class |
Util.StringSortAsc |
Modifier and Type | Field and Description |
---|---|
static int |
MAX_FORMAT_ALL |
static int |
MAX_FORMAT_BYTES |
static int |
MAX_FORMAT_GBIT_PER_SEC |
static int |
MAX_FORMAT_GBYTES |
static int |
MAX_FORMAT_KBIT_PER_SEC |
static int |
MAX_FORMAT_KBYTES |
static int |
MAX_FORMAT_MBIT_PER_SEC |
static int |
MAX_FORMAT_MBYTES |
static java.lang.String |
VERSION_FORMAT
Defines the format of version numbers in the AN.ON project.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
arraysEqual(byte[] arrayOne,
byte[] arrayTwo)
Tests if two byte arrays are equal.
|
static boolean |
arraysEqual(byte[] a_arrayA,
int a_Aoff,
byte[] a_arrayB,
int a_Boff,
int a_length)
Tests if a_length positions of two arrays are equal.
|
static boolean |
arraysEqual(char[] arrayOne,
char[] arrayTwo)
Tests if two charactet arrays are equal.
|
static boolean |
assertNotNull(java.lang.Object a_oneObject,
java.lang.Object a_otherObject) |
static void |
closeStream(java.io.InputStream a_input) |
static void |
closeStream(java.io.OutputStream a_input) |
static java.lang.String |
colonizeSKI(java.lang.String a_ski) |
static long |
convertVersionStringToNumber(java.lang.String a_version)
Converts a version string of the form xx.xx.xxx to a number
|
static void |
copyStream(java.io.InputStream a_input,
java.io.OutputStream a_output) |
static void |
copyStream(java.io.InputStream a_input,
java.io.OutputStream a_output,
IProgressCallback a_callback) |
static InfoServiceDBEntry[] |
createDefaultInfoServices(java.lang.String[] a_defaultNames,
java.lang.String[] a_defaultHostNames,
int[][] a_defaultPortNumbers) |
static java.lang.String |
cutString(java.lang.String a_string,
int a_maxLength) |
static java.lang.String |
decodeString(java.lang.String a_compressed)
Gets the stack trace of a Throwable as String.
|
static HTTPClient.HTTPResponse |
doHttpGetRequest(ListenerInterface a_targetInterface,
ImmutableProxyInterface a_proxyInterface,
java.lang.String a_file) |
static java.lang.String |
encodeWhiteSpaces(java.lang.String stringWithWhitespaces) |
static boolean |
equals(java.lang.Object a_oneObject,
java.lang.Object a_otherObject)
Compares to objects, even if one of them or both are null.
|
static java.lang.String |
formatBytesValueOnlyUnit(long c) |
static java.lang.String |
formatBytesValueOnlyUnit(long c,
int a_maxFormat) |
static java.lang.String |
formatBytesValueWithoutUnit(long c) |
static java.lang.String |
formatBytesValueWithoutUnit(long c,
int a_maxFormat)
Returns a formated number which respects different units (Bytes, kBytes, MBytes, GBytes)
|
static java.lang.String |
formatBytesValueWithUnit(long c)
Returns the desired unit for this amount of Bytes (Bytes, kBytes, MBytes,GBytes)
|
static java.lang.String |
formatBytesValueWithUnit(long c,
int a_maxFormat) |
static java.lang.String |
formatKbitPerSecValueOnlyUnit(long c) |
static java.lang.String |
formatKbitPerSecValueOnlyUnit(long c,
int a_maxFormat) |
static java.lang.String |
formatKbitPerSecValueWithoutUnit(long c) |
static java.lang.String |
formatKbitPerSecValueWithoutUnit(long c,
int a_maxFormat) |
static java.lang.String |
formatKbitPerSecValueWithUnit(long c) |
static java.lang.String |
formatKbitPerSecValueWithUnit(long c,
int a_maxFormat) |
static java.lang.String |
formatTimestamp(java.util.Date date,
boolean withTime)
formats a timestamp in an easily readable format.
|
static java.lang.String |
formatTimestamp(java.util.Date date,
boolean withTime,
java.lang.String a_language)
formatTimestamp
|
static java.net.InetAddress |
getLocalHost() |
static java.lang.String |
getStaticFieldValue(java.lang.Class a_class,
java.lang.String a_fieldName)
Uses the reflection API to get the value of a static field in the given class, if the field
is present.
|
static void |
interrupt(java.lang.Thread a_thread) |
static void |
interrupt(java.lang.Thread a_thread,
long a_timeout) |
static double |
parseDouble(java.lang.String a_string)
Implementation of parseFloat not implemented in JDK 1.1.8
|
static int |
readInt(java.io.InputStream a_inputStream) |
static int |
readUnsignedShort(java.io.InputStream a_inputStream) |
static java.lang.String |
replaceAll(java.lang.String a_source,
java.lang.String a_toReplace,
java.lang.String a_replaceWith)
Since JDK 1.1.8 does not provide String.replaceAll(),
this is an equivalent method.
|
static java.lang.String |
replaceAll(java.lang.String a_source,
java.lang.String a_toReplace,
java.lang.String a_replaceWith,
java.lang.String[] omit)
String replace algorithm.
|
static void |
sort(java.lang.String[] a_ids,
java.lang.String[] a_values) |
static void |
sort(java.util.Vector a_vec,
Util.Comparable c) |
static java.util.Vector |
sortStrings(java.util.Vector a_vector)
Sorts a Vector alphabetically using the toString() method of each object.
|
static java.lang.String |
stripString(java.lang.String a_string,
java.lang.String a_charactersToStrip) |
static java.lang.Object[] |
toArray(java.lang.Object a_object)
Creates an Object array from a single Object.
|
static java.lang.String |
toHTMLEntities(java.lang.String buf) |
static java.util.Vector |
toVector(java.lang.Object a_object)
Creates a Vector from a single Object.
|
public static final java.lang.String VERSION_FORMAT
public static final int MAX_FORMAT_BYTES
public static final int MAX_FORMAT_KBYTES
public static final int MAX_FORMAT_MBYTES
public static final int MAX_FORMAT_GBYTES
public static final int MAX_FORMAT_KBIT_PER_SEC
public static final int MAX_FORMAT_MBIT_PER_SEC
public static final int MAX_FORMAT_GBIT_PER_SEC
public static final int MAX_FORMAT_ALL
public static boolean assertNotNull(java.lang.Object a_oneObject, java.lang.Object a_otherObject)
public static boolean equals(java.lang.Object a_oneObject, java.lang.Object a_otherObject)
a_oneObject,
- may be nulla_otherObject,
- may be nullpublic static java.lang.String cutString(java.lang.String a_string, int a_maxLength)
public static java.lang.String stripString(java.lang.String a_string, java.lang.String a_charactersToStrip)
public static java.lang.String decodeString(java.lang.String a_compressed)
a_t
- a Throwablepublic static boolean arraysEqual(byte[] arrayOne, byte[] arrayTwo)
arrayOne
- a byte arrayarrayTwo
- another byte arraypublic static boolean arraysEqual(char[] arrayOne, char[] arrayTwo)
arrayOne
- a charactet arrayarrayTwo
- another charactet arraypublic static final boolean arraysEqual(byte[] a_arrayA, int a_Aoff, byte[] a_arrayB, int a_Boff, int a_length)
a_arrayA
- byte[]a_Aoff
- inta_arrayB
- byte[]a_Boff
- inta_length
- intpublic static java.util.Vector toVector(java.lang.Object a_object)
a_object
- an Objectpublic static java.lang.Object[] toArray(java.lang.Object a_object)
a_object
- an Objectpublic static java.util.Vector sortStrings(java.util.Vector a_vector)
a_vector
- a Vectorpublic static double parseDouble(java.lang.String a_string) throws java.lang.NumberFormatException
a_string
- Stringjava.lang.NumberFormatException
public static void sort(java.lang.String[] a_ids, java.lang.String[] a_values)
public static void sort(java.util.Vector a_vec, Util.Comparable c)
public static void interrupt(java.lang.Thread a_thread, long a_timeout)
public static void interrupt(java.lang.Thread a_thread)
public static long convertVersionStringToNumber(java.lang.String a_version) throws java.lang.NumberFormatException
a_version
- a version string of the form xx.xx.xxxjava.lang.NumberFormatException
- if the version has an illegal formatpublic static java.lang.String replaceAll(java.lang.String a_source, java.lang.String a_toReplace, java.lang.String a_replaceWith)
public static java.lang.String replaceAll(java.lang.String a_source, java.lang.String a_toReplace, java.lang.String a_replaceWith, java.lang.String[] omit)
a_source
- Source Stringa_toReplace
- substring which is to be replaceda_replaceWith
- string which should replace a_toReplaceomit
- Strings that not be replaced when their prefix matches a_toReplacepublic static java.lang.String encodeWhiteSpaces(java.lang.String stringWithWhitespaces)
public static void closeStream(java.io.InputStream a_input)
public static void closeStream(java.io.OutputStream a_input)
public static void copyStream(java.io.InputStream a_input, java.io.OutputStream a_output) throws java.io.IOException
java.io.IOException
public static void copyStream(java.io.InputStream a_input, java.io.OutputStream a_output, IProgressCallback a_callback) throws java.io.IOException
java.io.IOException
public static java.lang.String getStaticFieldValue(java.lang.Class a_class, java.lang.String a_fieldName)
a_class
- a Classa_fieldName
- the field to read the value frompublic static java.lang.String colonizeSKI(java.lang.String a_ski)
public static InfoServiceDBEntry[] createDefaultInfoServices(java.lang.String[] a_defaultNames, java.lang.String[] a_defaultHostNames, int[][] a_defaultPortNumbers) throws java.lang.Exception
java.lang.Exception
public static java.lang.String formatKbitPerSecValueWithUnit(long c)
public static java.lang.String formatKbitPerSecValueWithUnit(long c, int a_maxFormat)
public static java.lang.String formatKbitPerSecValueOnlyUnit(long c)
public static java.lang.String formatKbitPerSecValueOnlyUnit(long c, int a_maxFormat)
public static java.lang.String formatKbitPerSecValueWithoutUnit(long c)
public static java.lang.String formatKbitPerSecValueWithoutUnit(long c, int a_maxFormat)
public static java.lang.String formatBytesValueWithUnit(long c)
public static java.lang.String formatBytesValueWithUnit(long c, int a_maxFormat)
public static java.lang.String formatBytesValueOnlyUnit(long c)
public static java.lang.String formatBytesValueOnlyUnit(long c, int a_maxFormat)
public static java.lang.String formatBytesValueWithoutUnit(long c)
public static java.lang.String formatBytesValueWithoutUnit(long c, int a_maxFormat)
public static java.net.InetAddress getLocalHost() throws java.net.UnknownHostException
java.net.UnknownHostException
public static java.lang.String toHTMLEntities(java.lang.String buf)
public static java.lang.String formatTimestamp(java.util.Date date, boolean withTime)
date
- TimestampwithTime
- boolean if true, the date+time is returned, otherwise date only.public static java.lang.String formatTimestamp(java.util.Date date, boolean withTime, java.lang.String a_language)
date
- TimestampwithTime
- booleana_language
- String: 2-letter codepublic static HTTPClient.HTTPResponse doHttpGetRequest(ListenerInterface a_targetInterface, ImmutableProxyInterface a_proxyInterface, java.lang.String a_file) throws java.io.IOException, HTTPClient.ModuleException
java.io.IOException
HTTPClient.ModuleException
public static int readUnsignedShort(java.io.InputStream a_inputStream) throws java.io.EOFException, java.io.IOException
java.io.EOFException
java.io.IOException
public static int readInt(java.io.InputStream a_inputStream) throws java.io.EOFException, java.io.IOException
java.io.EOFException
java.io.IOException
Copyright © 2023. All rights reserved.