All Packages Class Hierarchy This Package Previous Next Index
Class ccl.util.Util
java.lang.Object
|
+----ccl.util.Util
- public class Util
- extends Object
A general purpose class.
There are different groups of methods in this class:
debug and assertion methods
print methods - convenience methods for System.out.print etc. that additionally make sure output is gets flushed immediately.
basic converter methods
string methods
string/vector converter methods
vector methods
sorting and inserting methods
system methods
date methods
random generator methods
miscellaneous methods
Potential candidate classes to move some code over to are:
StringUtil, VectorUtil, SystemUtil, and maybe Debug.
- Version:
- $Id: Util.java 1.63 2000/05/14 14:48:51 clemens Exp clemens $
- Author:
-
Chr. Clemens Lee
<
clemens@kclee.com
>
-
_acUmlaut
-
-
_bDebug
- Used to store the debug state.
-
_bNochKeinIntSwap
-
-
_bNochKeinSwap
-
-
_objSwap
-
-
_rnd
-
-
_swap
-
-
O_CONSTANT
- This could be also private and instead you would have
to use getConstantObject(), but yet you have the
choice.
-
Util()
- This is an utility class, there is (should be) no need
for an instance of this class.
-
assert(boolean)
- Most people are used to assertions.
-
assert(Object)
- Assert pObject is not null.
-
atob(String)
- Converts a String to a boolean.
-
atof(String)
- String to float converter.
-
atoi(String)
- String to int converter.
-
btoi(byte)
- Converts a byte to an int.
Deprecated.
-
bytesToInt(byte[])
- Converts a byte array into an int.
-
byteToChar(byte)
- Converts a byte to a char.
-
byteToInt(byte)
- Converts a byte to an int.
-
byteToString(byte)
- Converts a byte to a String.
-
compare(String, String)
- If you believe it or not, in a very old jdk version
there was a bug in String.compareTo(String) and I did
need this as a workaround.
Deprecated.
-
concat(String, char)
- This function concatenates a String with a char.
-
concat(Vector)
- This function concatenates different Strings into one String.
-
concat(Vector, char)
- This function concatenates different Strings into one String.
-
concat(Vector, String)
- This function concatenates different Strings into one String.
-
concat(Vector, Vector)
- Create a new vector which consists of both given vectors.
-
contains(String, String)
-
Deprecated.
-
contains(Vector, String)
- Test if a vector contains a given string.
-
contains(Vector, Testable)
- Test if a vector contains an element which succeeds
a given test filter.
-
count(String, char)
- How many chars c_ contains the String pString_.
-
cToS(char)
- A character to String converter.
-
debug(int)
- If the debug mode was set with the setDebug function
to true, this debug statements is equal to a printlnErr
statement, otherwise it will be ignored.
-
debug(Object)
- If the debug mode was set with the setDebug function
to true, this debug statements is equal to a printlnErr
statement, otherwise it will be ignored.
-
debug(Object, Object)
- If the debug mode was set with the setDebug function
to true, this debug statements is equal to a printlnErr
statement, otherwise it will be ignored.
-
denullify(String)
-
Deprecated.
-
endsWith(String, char)
- Tests if this string ends with the specified character.
-
endsWith(String, String)
- Tests if this string ends with the second string.
-
enumerationToVector(Enumeration)
- Convert an enumeration to a vector.
-
equals(Vector, Vector)
- Do the elements of two vectors at the same position
equal each other?
-
equalsCaseless(String, String)
- Compares two strings.
-
filter(Vector, Object)
- All object in this vector which equal the bad element
are not copied over to the resulting vector.
-
filter(Vector, Testable)
- Create a new vector and copy all elements of
the pVector_ paramter over which are accepted by the
test filter.
-
filter(Vector, Vector)
- All object in this vector which equal an object in
the bad vector are not copied over to the resulting
vector.
-
firstCharToLowerCase(String)
- Returns the given string with the first char converted
to lower case.
-
firstCharToUpperCase(String)
- Returns the given string with the first char converted
to upper case.
-
gc()
- System.gc() does not always garanty immediate execution.
-
getCalendar()
-
-
getCalendar(String)
- This is a replacement of the SimpleTimeZone.getTimeZone(String)
function that additionally creates a GregorianCalendar of the
given timezone.
-
getConstantObject()
- Sometimes you need a dummy object just to have any
value for a hashtable or so and it doesn't matter at
all if we always use the same object, so here is one
you can use without wasting extra memory.
-
getDate(Calendar)
-
-
getDate(String)
- For example: 1999-11-26.
-
getHeuteSortable()
-
Deprecated.
-
getLocalHostName()
- Get the name of the localhost.
-
getObjectName(Object)
- pObject_.getClass().getName() returns the name including
its package.
-
getOccurances(String, int)
- Count how often a string contains a special char.
-
getSpaces(int)
- Returns a String which consists only of spaces and has the
lenght 'length_' or which is empty if length_ equals zero.
-
getStandardDate(Date)
-
-
getTime(Calendar)
-
-
getTime(Date)
-
-
getTodaySortable()
-
-
indexOfNot(String, char)
-
-
indexOfNot(String, char, int)
-
-
insert(Vector, int, int, Object, Comparable)
- Inert a new object into a vector and keep the
vector sorted.
-
insert(Vector, Object, Comparable)
- Inert a new object into a vector and keep the
vector sorted.
-
insert(Vector, Vector, int)
- Insert at a special offset all elements of the second
vector into the first vector.
-
intToBytes(int)
- Converts an int into a byte array.
-
invert(Vector)
- Create a new vector and invert the order of the
elements.
-
isAlpha(char)
-
-
isDateValid(String)
-
-
isDigit(char)
- Return true for digit characters.
-
isEmpty(String)
- Tests, if a given String equals null or "".
-
isEmpty(Vector)
- Tests, if a given Vector is null or has size 0.
-
isOSLinux()
- Returns true if the current operating system is
Linux.
-
isOSSolaris()
- Returns true if the current operating system is
Sun Microsystem's Solaris.
-
isOSUnix()
- Returns true if the current operating system is
either Linux or Solaris.
-
isOSWindows()
- Returns true if the current operating system is
Microsoft Windows.
-
isSpaceLine(String)
- Tests if a string contains only space, tab, and linefeed
characters.
-
isSwingPackage(String)
- Returns true if sFullPackageName_ is a swing
package, either old com.sun.java.swing or new
javax.swing convention.
-
isTrue(Boolean)
- Boolean to boolean converter.
-
itoa(int)
- Converts an int to a String.
-
ltoa(long)
- Converts an long to a String.
-
ltrim(String)
- Removes space, carriage, linefeed, and tab chars at
the right side of a string.
-
map(Vector, Transformable)
- Convert each element of the vector by a transformation
object.
-
max(int, int)
-
-
max(long, long)
-
-
min(int, int)
-
-
multiplyChar(char, int)
- Create a string by concatenating one char several times.
-
multiplyChar(String, int)
- Create a string by concatenating one string several times.
-
objectsToVector(Object[])
- Convert an array of objects to a vector.
-
paddWith(int, int, char)
- Fill a string with a given char for alignment purposes.
-
paddWith(String, int, char)
- Fill a string with a given char for alignment purposes.
-
paddWithSpace(double, int)
- Fill a string with space chars for alignment purposes.
-
paddWithSpace(int, int)
- Fill a string with space chars for alignment purposes.
-
paddWithSpace(long, int)
- Fill a string with space chars for alignment purposes.
-
paddWithSpace(String, int)
- Fill a string with space chars for alignment purposes.
-
paddWithZero(int, int)
- Fill a string with zero chars for alignment purposes.
-
paddWithZero(long, int)
- Fill a string with zero chars for alignment purposes.
-
paddWithZero(String, int)
- Fill a string with zero chars for alignment purposes.
-
panicIf(boolean)
- panicIf <=> not assert.
-
panicIf(boolean, String)
- panicIf <=> not assert.
-
print(char)
- Prints out a char to System.out.
-
print(Object)
- Prints out the object to System.out.
-
print(String)
- Prints out a String to System.out.
-
printErr(char)
- Prints out a char to System.err.
-
printErr(Object)
- Prints out the object to System.err.
-
printErr(String)
- Prints out a String to System.err.
-
println()
- Same as print('\n').
-
println(Exception)
- Prints out the exception, its stack trace,
and the current thread.
-
println(Object)
- Prints out the object to System.out together with a
new line.
-
println(String)
- Prints out a String to System.out together with a
new line.
-
printlnErr()
- The same as println, except output goes to std err.
-
printlnErr(Object)
- Prints out the object to System.err.
-
printlnErr(Object, Object)
- Prints out a String with a prefix of the oClass_ class
name to System.err.
-
printlnErr(String)
- The same as println, except output goes to std err.
-
quickSort(Object[], int, int, Comparable)
- An implementation of Quicksort using medians of 3 for partitions.
-
quickSort(Vector, int, int, Comparable)
- An implementation of Quicksort using medians of 3 for partitions.
-
removeMultipleSpaces(String)
- What the method name says.
-
replace(String, char, char)
- Replaces all occurences of cOld_ in pString with cNew_.
-
replace(String, char, char, int)
- Replaces all occurences of cOld_ in pString with cNew_.
-
replace(String, String, String)
- Replaces all occurences of sOld_ in pString with sNew_.
-
replace(String, String, String, int)
- Replaces all occurences of sOld_ in pString with sNew_.
-
rnd()
-
-
rnd(double)
- Returns the a pseudorandom double number between
0.0 and excluding the provided double value.
-
rnd(float)
- Returns the a pseudorandom float number between
0.0 and excluding the provided float value.
-
rnd(int)
- Random number in the range [0, end_] (both inclusive).
-
rnd(int, int)
- Random number in the range [start_, end_] (both inclusive).
-
rtrim(String)
- Removes space, carriage, linefeed, and tab chars at
the right side of a string.
-
setDate(Calendar, String)
-
-
setDebug(boolean)
- Sets the debug mode for the running application.
-
setDebug(String)
- Sets the debug mode for the running application.
-
setTime(Calendar, String)
-
-
showLiveSignal()
- For batch applications to indicate progess to the user.
-
showLiveSignal(char)
- For batch applications to indicate progess to the user.
-
sleep(int)
- Current thread sleeps in seconds.
-
sort(Enumeration)
- Quicksort for Enumeration.
-
sort(Enumeration, Comparable)
- Quicksort for Enumeration.
-
sort(Vector)
- Uses Quicksort using medians of 3 for partitions.
-
sort(Vector, Comparable)
- Uses Quicksort using medians of 3 for partitions and the
-
sortCaseSensitive(Vector)
- Uses Quicksort using medians of 3 for partitions
-
sortFast(Vector)
- Uses Quicksort using medians of 3 for partitions.
-
sortFast(Vector, Comparable)
- Like sort but works directly on the input vector.
-
stringToDate(String)
- For example: 1999-11-26.
-
stringToLines(int, String)
- This function takes a String and separates it into different
lines.
-
stringToLines(int, String, char)
- This function takes a String and separates it into different
lines.
-
stringToLines(String)
- This function takes a String and separates it into different
lines.
-
stringToLines(String, char)
- This function takes a String and separates it into different
lines.
-
stringToLines(String, String)
- This function takes a String and separates it into different
lines.
-
stringToLines(String, String, boolean)
- This function takes a String and separates it into different
lines.
-
subtract(Vector, Vector)
- Create a new vector through extracting all elements of
the second vector from the first vector.
-
swap()
-
-
swap(Object, Object)
-
-
swapInt()
-
-
swapInt(int, int)
-
-
system(String)
- This method does return immediately.
-
system(String[])
- Execute an external command.
-
system(Vector)
- Execute an external command.
-
systemAndGetError(Vector)
- Does a system exec and returns the stderr output.
-
systemAndWait(Vector)
- Does a system exec and returns the stdout.
-
toLowerCase(int)
- Works with ints instead of chars.
-
toString(Object)
- Before returning pObject_.toString() it checks if
pObject_ is null.
-
toUpperCase(int)
- Works with ints instead of chars.
-
toVector(Enumeration)
- Enumeration to Vector converter.
-
unifySpaces(String)
- Seems to do the same as 'removeMultipleSpaces(String)'.
-
vectorToObjects(Vector)
- Convenience class for java.util.Vector.copyInto(..).
_rnd
private static Random _rnd
_objSwap
private static Object _objSwap
_bNochKeinSwap
private static boolean _bNochKeinSwap
_swap
private static int _swap
_bNochKeinIntSwap
private static boolean _bNochKeinIntSwap
_acUmlaut
private static final char _acUmlaut[]
_bDebug
private static boolean _bDebug
- Used to store the debug state. Can be changed during
runtime for more flexibility. This is more important
to me than speed.
O_CONSTANT
public static final Object O_CONSTANT
- This could be also private and instead you would have
to use getConstantObject(), but yet you have the
choice.
- See Also:
- getConstantObject
Util
private Util()
- This is an utility class, there is (should be) no need
for an instance of this class.
setDebug
public static void setDebug(boolean bDebug_)
- Sets the debug mode for the running application. When
true, all following debug statements are equal to println
statements, otherwise they are ignored.
- See Also:
- debug
setDebug
public static void setDebug(String sDebug_)
- Sets the debug mode for the running application. When
true, all following debug statements are equal to
printlnErr statements, otherwise they are ignored.
- See Also:
- debug
debug
public static void debug(Object oMessage_)
- If the debug mode was set with the setDebug function
to true, this debug statements is equal to a printlnErr
statement, otherwise it will be ignored.
- See Also:
- setDebug
debug
public static void debug(int i)
- If the debug mode was set with the setDebug function
to true, this debug statements is equal to a printlnErr
statement, otherwise it will be ignored.
- See Also:
- setDebug
debug
public static void debug(Object oOriginator_,
Object oMessage_)
- If the debug mode was set with the setDebug function
to true, this debug statements is equal to a printlnErr
statement, otherwise it will be ignored.
- See Also:
- setDebug, printlnErr
panicIf
public static void panicIf(boolean bPanic_)
- panicIf <=> not assert. Throws ApplicationException if true.
It's not necessary to catch this exception.
- See Also:
- ApplicationException
panicIf
public static void panicIf(boolean bPanic_,
String sMessage_)
- panicIf <=> not assert. Throws ApplicationException if true.
It's not necessary to catch this exception.
- Parameters:
- sMessage_ - The error message for the Exception.
- See Also:
- ApplicationException
assert
public static void assert(boolean bAssert_)
- Most people are used to assertions. But I once came up
with panicIf(boolean) and that's what I still prefer
to use.
assert
public static void assert(Object pObject_)
- Assert pObject is not null.
print
public static void print(char c_)
- Prints out a char to System.out.
print
public static void print(String pString_)
- Prints out a String to System.out.
print
public static void print(Object pObject_)
- Prints out the object to System.out.
println
public static void println(String pString_)
- Prints out a String to System.out together with a
new line.
println
public static void println(Exception e)
- Prints out the exception, its stack trace,
and the current thread.
println
public static void println(Object pObject_)
- Prints out the object to System.out together with a
new line.
println
public static void println()
- Same as print('\n').
printErr
public static void printErr(char c_)
- Prints out a char to System.err.
printErr
public static void printErr(String pString_)
- Prints out a String to System.err.
printErr
public static void printErr(Object pObject_)
- Prints out the object to System.err.
printlnErr
public static void printlnErr()
- The same as println, except output goes to std err.
printlnErr
public static void printlnErr(String sMessage_)
- The same as println, except output goes to std err.
printlnErr
public static void printlnErr(Object pObject_)
- Prints out the object to System.err.
printlnErr
public static void printlnErr(Object oClass_,
Object oMessage_)
- Prints out a String with a prefix of the oClass_ class
name to System.err.
showLiveSignal
public static void showLiveSignal()
- For batch applications to indicate progess to the user.
showLiveSignal
public static void showLiveSignal(char c_)
- For batch applications to indicate progess to the user.
- Parameters:
- c_ - The char that should be printed to
stdout.
atoi
public static int atoi(String pString_)
- String to int converter.
itoa
public static String itoa(int i_)
- Converts an int to a String.
ltoa
public static String ltoa(long l_)
- Converts an long to a String.
atof
public static float atof(String pString_)
- String to float converter. An empty string gets
converted to 0.0, while a string that is not
adequately formatted results in NaN (not a number).
intToBytes
public static byte[] intToBytes(int i_)
- Converts an int into a byte array. First byte has the highest
value.
- See Also:
- bytesToInt
bytesToInt
public static int bytesToInt(byte abInt[])
- Converts a byte array into an int. First byte has the highest
value.
- See Also:
- intToBytes
byteToChar
public static char byteToChar(byte b_)
- Converts a byte to a char.
btoi
public static int btoi(byte b_)
- Note: btoi() is deprecated.
Use byteToInt(byte) instead.
- Converts a byte to an int.
byteToInt
public static int byteToInt(byte b_)
- Converts a byte to an int.
byteToString
public static String byteToString(byte b_)
- Converts a byte to a String.
cToS
public static String cToS(char c_)
- A character to String converter.
toUpperCase
public static int toUpperCase(int character_)
- Works with ints instead of chars.
toLowerCase
public static int toLowerCase(int character_)
- Works with ints instead of chars.
atob
public static boolean atob(String pString_)
- Converts a String to a boolean.
It's true if the string consists of the word "true"
ignoring case, otherwise it returns false.
- Returns:
- ((pString_ != null) && pString_.toLowerCase().equals("true"));
isTrue
public static boolean isTrue(Boolean pBoolean_)
- Boolean to boolean converter.
- Returns:
- true if input is true, false otherwise or if input
is null.
isEmpty
public static boolean isEmpty(String sTest_)
- Tests, if a given String equals null or "".
getOccurances
public static int getOccurances(String source,
int zeichen)
- Count how often a string contains a special char.
multiplyChar
public static String multiplyChar(char c,
int anzahl)
- Create a string by concatenating one char several times.
multiplyChar
public static String multiplyChar(String sFill,
int anzahl)
- Create a string by concatenating one string several times.
The method name should maybe renamed to multiplyString or
something else.
getSpaces
public static String getSpaces(int length_)
- Returns a String which consists only of spaces and has the
lenght 'length_' or which is empty if length_ equals zero.
paddWith
public static String paddWith(int number_,
int stellen_,
char cPadd_)
- Fill a string with a given char for alignment purposes.
paddWith
public static String paddWith(String pString_,
int stellen_,
char cPadd_)
- Fill a string with a given char for alignment purposes.
paddWithSpace
public static String paddWithSpace(int number,
int stellen)
- Fill a string with space chars for alignment purposes.
paddWithSpace
public static String paddWithSpace(long number,
int stellen)
- Fill a string with space chars for alignment purposes.
paddWithSpace
public static String paddWithSpace(double dNumber_,
int stellen)
- Fill a string with space chars for alignment purposes.
paddWithSpace
public static String paddWithSpace(String pString_,
int stellen)
- Fill a string with space chars for alignment purposes.
paddWithZero
public static String paddWithZero(int number,
int stellen)
- Fill a string with zero chars for alignment purposes.
paddWithZero
public static String paddWithZero(long number,
int stellen)
- Fill a string with zero chars for alignment purposes.
paddWithZero
public static String paddWithZero(String sNumber_,
int stellen_)
- Fill a string with zero chars for alignment purposes.
removeMultipleSpaces
public static String removeMultipleSpaces(String pString_)
- What the method name says.
rtrim
public static String rtrim(String s)
- Removes space, carriage, linefeed, and tab chars at
the right side of a string.
ltrim
public static String ltrim(String s)
- Removes space, carriage, linefeed, and tab chars at
the right side of a string.
unifySpaces
public static String unifySpaces(String s)
- Seems to do the same as 'removeMultipleSpaces(String)'.
One should become deprecated.
equalsCaseless
public static boolean equalsCaseless(String sA_,
String sB_)
- Compares two strings. Upper or lower case characters
are not considered differently.
firstCharToUpperCase
public static String firstCharToUpperCase(String pString_)
- Returns the given string with the first char converted
to upper case.
firstCharToLowerCase
public static String firstCharToLowerCase(String pString_)
- Returns the given string with the first char converted
to lower case.
endsWith
public static boolean endsWith(String sThis_,
char cOther_)
- Tests if this string ends with the specified character.
endsWith
public static boolean endsWith(String pString_,
String sEnd_)
- Tests if this string ends with the second string.
replace
public static String replace(String pString_,
char cOld_,
char cNew_)
- Replaces all occurences of cOld_ in pString with cNew_.
- See Also:
- replace
replace
public static String replace(String pString_,
char cOld_,
char cNew_,
int startIndex_)
- Replaces all occurences of cOld_ in pString with cNew_.
replace
public static String replace(String pString_,
String sOld_,
String sNew_)
- Replaces all occurences of sOld_ in pString with sNew_.
replace
public static String replace(String pString_,
String sOld_,
String sNew_,
int startIndex_)
- Replaces all occurences of sOld_ in pString with sNew_.
- Parameters:
- startIndex_ - The startindex_ gives the position in
pString_ where the replace procedure
should start.
isSpaceLine
public static boolean isSpaceLine(String sLine_)
- Tests if a string contains only space, tab, and linefeed
characters.
denullify
public static String denullify(String pString_)
- Note: denullify() is deprecated.
Use toString(Object) instead.
toString
public static String toString(Object pObject_)
- Before returning pObject_.toString() it checks if
pObject_ is null. If so, "null" is returned.
contains
public static int contains(String sToLookIn_,
String sThis_)
- Note: contains() is deprecated.
Well, String.indexOf(String) should be
just fine!?
- Returns:
- -1 if sToLookIn_ does not contain sThis_.
Otherwise the position is returned.
compare
public static int compare(String firstString,
String anotherString)
- Note: compare() is deprecated.
Use String.compare instead.
- If you believe it or not, in a very old jdk version
there was a bug in String.compareTo(String) and I did
need this as a workaround. This method should be of no
use anymore [1999-07-15].
indexOfNot
public static int indexOfNot(String pString_,
char cNot_,
int startIndex_)
- Returns:
- -1 means the string is either "" or contains just the
char cNot_.
indexOfNot
public static int indexOfNot(String pString_,
char cNot_)
- Returns:
- -1 means the string is either "" or contains just the
char cNot_.
count
public static int count(String pString_,
char c_)
- How many chars c_ contains the String pString_.
isDigit
public static boolean isDigit(char c_)
- Return true for digit characters.
concat
public static String concat(Vector pVector_)
- This function concatenates different Strings into one String.
- Parameters:
- pVector_ - Contains the Strings that will be concatenated.
- Returns:
- There is no 'glue' between the Strings.
- See Also:
- stringToLines
concat
public static String concat(Vector pVector_,
String sWith_)
- This function concatenates different Strings into one String.
- Parameters:
- pVector_ - Contains the Strings that will be concatenated.
- sWidth_ - The 'glue' for the other Strings.
- Returns:
- sWith_ is not appended at the end.
- See Also:
- stringToLines
concat
public static String concat(Vector pVector_,
char cWith_)
- This function concatenates different Strings into one String.
- Parameters:
- pVector_ - Contains the Strings that will be concatenated.
- cWidth_ - The 'glue' for the other Strings.
- Returns:
- cWith_ is not appended at the end.
- See Also:
- stringToLines
concat
public static String concat(String pString_,
char cWidth_)
- This function concatenates a String with a char.
stringToLines
public static Vector stringToLines(int lines_,
String pString_,
char cCutter_)
- This function takes a String and separates it into different
lines. The last line does not need to have a separator character.
- Parameters:
- lines_ - The number of lines that should be extracted.
Zero if maximum number of lines is requested.
- cCutter_ - The character that separates pString_ into
different lines
- Returns:
- The single lines do not contain the cCutter_
character at the end.
stringToLines
public static Vector stringToLines(String pString_,
char cCutter_)
- This function takes a String and separates it into different
lines. The last line does not need to have a separator character.
- Parameters:
- cCutter_ - The character that separates pString_ into
different lines
- Returns:
- The single lines do not contain the cCutter_ character
at the end.
- See Also:
- concat
stringToLines
public static Vector stringToLines(String pString_)
- This function takes a String and separates it into different
lines. The last line does not need to have a '\n'. The function
can't handle dos carriage returns.
- Returns:
- The single lines do not contain the '\n' character
at the end.
stringToLines
public static Vector stringToLines(int lines_,
String pString_)
- This function takes a String and separates it into different
lines. The last line does not need to have a '\n'. The function
can't handle dos carriage returns.
- Parameters:
- lines_ - The number of lines that should be extracted.
Zero if maximum number of lines is requested.
- cCutter_ - The character that separates pString_ into
different lines
- Returns:
- The single lines do not contain the cCutter_ character
at the end.
- See Also:
- concat
stringToLines
public static Vector stringToLines(String sLines_,
String sCutter_)
- This function takes a String and separates it into different
lines. The last line does not need to have a separator string.
- Returns:
- Note that the sCutter_ string will be removed from each
line.
- See Also:
- concat
stringToLines
public static Vector stringToLines(String sLines_,
String sTokenizerString_,
boolean bUseTokenizer_)
- This function takes a String and separates it into different
lines. The last line does not need to have a separator string.
- See Also:
- concat
isEmpty
public static boolean isEmpty(Vector vTest_)
- Tests, if a given Vector is null or has size 0.
toVector
public static Vector toVector(Enumeration pEnumeration_)
- Enumeration to Vector converter.
- Returns:
- null in empty vector out
objectsToVector
public static Vector objectsToVector(Object apObjects[])
- Convert an array of objects to a vector.
vectorToObjects
public static Object[] vectorToObjects(Vector pVector_)
- Convenience class for java.util.Vector.copyInto(..).
- Parameters:
- pVector_ - the vector to convert into an array.
- Returns:
- Never returns null, returns at least an array
of length 0.
filter
public static Vector filter(Vector pVector_,
Object oBadElement_)
- All object in this vector which equal the bad element
are not copied over to the resulting vector.
filter
public static Vector filter(Vector pVector_,
Vector vBadElements_)
- All object in this vector which equal an object in
the bad vector are not copied over to the resulting
vector.
filter
public static Vector filter(Vector pVector_,
Testable pFilter_)
- Create a new vector and copy all elements of
the pVector_ paramter over which are accepted by the
test filter.
map
public static Vector map(Vector pVector_,
Transformable pTransformable_)
- Convert each element of the vector by a transformation
object.
contains
public static boolean contains(Vector pVector_,
String sFind_)
- Test if a vector contains a given string.
contains
public static boolean contains(Vector pVector_,
Testable pFilter_)
- Test if a vector contains an element which succeeds
a given test filter.
enumerationToVector
public static Vector enumerationToVector(Enumeration pEnumeration_)
- Convert an enumeration to a vector.
Sometimes you have an enumeration at hand, which you
want to use more than once.
concat
public static Vector concat(Vector vFirst_,
Vector vSecond_)
- Create a new vector which consists of both given vectors.
subtract
public static Vector subtract(Vector vSource_,
Vector vToDelete_)
- Create a new vector through extracting all elements of
the second vector from the first vector.
insert
public static Vector insert(Vector vDestination_,
Vector vOther_,
int destination)
- Insert at a special offset all elements of the second
vector into the first vector. The input vectors are
not changed but a new result vector gets created.
equals
public static boolean equals(Vector vFirst_,
Vector vSecond_)
- Do the elements of two vectors at the same position
equal each other?
invert
public static Vector invert(Vector vSource_)
- Create a new vector and invert the order of the
elements.
quickSort
public static void quickSort(Object s[],
int lo,
int hi,
Comparable cmp)
- An implementation of Quicksort using medians of 3 for partitions.
Used internally by sort.
It is public and static so it can be used to sort plain
arrays as well.
Originally written by Doug Lea and released into the public domain.
Thanks for the assistance and support of Sun Microsystems Labs, Agorics
Inc, Loral, and everyone contributing, testing, and using this code.
History:
Date Who What
2Oct95 dl@cs.oswego.edu refactored from DASeq.java
13Oct95 dl Changed protection statuses
- Parameters:
- s, - the array to sort
- lo, - the least index to sort from
- hi, - the greatest index
- cmp, - the comparator to use for comparing elements
quickSort
public static void quickSort(Vector v,
int lo,
int hi,
Comparable cmp)
- An implementation of Quicksort using medians of 3 for partitions.
Used internally by sort.
It is public and static so it can be used to sort plain
arrays as well.
Originally written by Doug Lea and released into the public domain.
Thanks for the assistance and support of Sun Microsystems Labs, Agorics
Inc, Loral, and everyone contributing, testing, and using this code.
History:
Date Who What
2Oct95 dl@cs.oswego.edu refactored from DASeq.java
13Oct95 dl Changed protection statuses
30Apr97 Clemens.Lahme@gmd.de For use with Vector
- Parameters:
- v, - the vector to sort
- lo, - the least index to sort from
- hi, - the greatest index
- cmp, - the comparator to use for comparing elements
sort
public static Vector sort(Vector vInput_,
Comparable pComparable_)
- Uses Quicksort using medians of 3 for partitions and the
sortFast
public static void sortFast(Vector vInput_,
Comparable pComparable_)
- Like sort but works directly on the input vector.
sort
public static Vector sort(Vector pVector_)
- Uses Quicksort using medians of 3 for partitions.
sortFast
public static void sortFast(Vector pVector_)
- Uses Quicksort using medians of 3 for partitions.
sort
public static Vector sort(Enumeration pEnumeration_)
- Quicksort for Enumeration.
- Returns:
- null in empty vector out
sort
public static Vector sort(Enumeration pEnumeration_,
Comparable pComparable_)
- Quicksort for Enumeration.
- Returns:
- null in empty vector out
sortCaseSensitive
public static Vector sortCaseSensitive(Vector pVector_)
- Uses Quicksort using medians of 3 for partitions
insert
public static int insert(Vector pVector_,
int lowestOffset_,
int highestOffset_,
Object pObject_,
Comparable pComparable_)
- Inert a new object into a vector and keep the
vector sorted.
insert
public static int insert(Vector pVector_,
Object pObject_,
Comparable pComparable_)
- Inert a new object into a vector and keep the
vector sorted.
system
public static Process system(String sCommand_) throws IOException
- This method does return immediately. If you want the
output of the process use either systemAndWait() or
systemAndGetError().
- Throws: IOException
- Whatever can go wrong.
- See Also:
- systemAndWait, systemAndGetError
system
public static Process system(String asCommand_[]) throws IOException
- Execute an external command.
- Throws: IOException
- Whatever Runtime.exec(..) throws.
system
public static Process system(Vector vArgs_) throws IOException
- Execute an external command. Provide arguments inside
a vector.
- Throws: IOException
- Whatever Runtime.exec(..) throws.
systemAndWait
public static String systemAndWait(Vector vArgs_) throws IOException
- Does a system exec and returns the stdout.
- Parameters:
- vArgs_ - the arguments to system.exec().
Should not be null or empty.
- Returns:
- The standard output.
- Throws: IOException
- Whatever might go wrong.
systemAndGetError
public static String systemAndGetError(Vector vArgs_) throws IOException
- Does a system exec and returns the stderr output.
- Parameters:
- vArgs_ - the arguments to system.exec().
Should not be null or empty.
- Returns:
- The standard output.
- Throws: IOException
- Whatever might go wrong.
isOSWindows
public static boolean isOSWindows()
- Returns true if the current operating system is
Microsoft Windows.
isOSLinux
public static boolean isOSLinux()
- Returns true if the current operating system is
Linux.
isOSSolaris
public static boolean isOSSolaris()
- Returns true if the current operating system is
Sun Microsystem's Solaris.
isOSUnix
public static boolean isOSUnix()
- Returns true if the current operating system is
either Linux or Solaris.
gc
public static void gc()
- System.gc() does not always garanty immediate execution.
This method does also a yield for a bigger chance that gc
really does happen.
getLocalHostName
public static String getLocalHostName()
- Get the name of the localhost.
isSwingPackage
public static boolean isSwingPackage(String sFullPackageName_)
- Returns true if sFullPackageName_ is a swing
package, either old com.sun.java.swing or new
javax.swing convention. Accessibilitiy is also
considered to be a swing package.
rnd
public static boolean rnd()
- Returns:
- 50% chance of either true or false.
rnd
public static int rnd(int end_)
- Random number in the range [0, end_] (both inclusive).
rnd
public static int rnd(int start_,
int end_)
- Random number in the range [start_, end_] (both inclusive).
rnd
public static float rnd(float f)
- Returns the a pseudorandom float number between
0.0 and excluding the provided float value.
rnd
public static double rnd(double df)
- Returns the a pseudorandom double number between
0.0 and excluding the provided double value.
getStandardDate
public static String getStandardDate(Date pDate_)
- Returns:
- 1998-12-06 for example.
getDate
public static String getDate(Calendar pCalendar_)
- Returns:
- 1998-12-06 for example.
getTime
public static String getTime(Date pDate_)
- Returns:
- hh:mm:ss
getTime
public static String getTime(Calendar pCalendar_)
- Returns:
- hh:mm:ss
stringToDate
public static Date stringToDate(String sDate_)
- For example: 1999-11-26. Time is undefined and can
have every value.
- Returns:
- null on parse error.
getDate
public static Calendar getDate(String sDate_)
- For example: 1999-11-26. Time is undefined and can
have every value.
- Returns:
- null on parse error.
getCalendar
public static Calendar getCalendar(String sTimeZoneID_)
- This is a replacement of the SimpleTimeZone.getTimeZone(String)
function that additionally creates a GregorianCalendar of the
given timezone. There is a new timezone 'CET' (Central
European Time. It has the official daylight saving time settings
(ranging from the last Sunday in March at 2:00 am to the last
Sunday in October at 2:00 am) and should be preferred over 'ECT'.
- Parameters:
- sTokenizerString_ - If it is null or "" then "GMT" is used.
getCalendar
public static Calendar getCalendar()
- Returns:
- Calendar with local timezone
setTime
public static void setTime(Calendar pCalendar_,
String sTime_)
- Parameters:
- sTime_ - e.g. 23:59:59
setDate
public static void setDate(Calendar pCalendar_,
String sDate_)
- Parameters:
- sDate_ - e.g. 2000-01-26
isDateValid
public static boolean isDateValid(String sDate_)
getHeuteSortable
public static String getHeuteSortable()
- Note: getHeuteSortable() is deprecated.
- See Also:
- getTodaySortable
getTodaySortable
public static String getTodaySortable()
getConstantObject
public static Object getConstantObject()
- Sometimes you need a dummy object just to have any
value for a hashtable or so and it doesn't matter at
all if we always use the same object, so here is one
you can use without wasting extra memory.
sleep
public static void sleep(int seconds_)
- Current thread sleeps in seconds.
isAlpha
public static boolean isAlpha(char c_)
max
public static long max(long a_,
long b_)
max
public static int max(int a_,
int b_)
min
public static int min(int a_,
int b_)
swap
public static Object swap(Object objFirst,
Object objSecond)
swap
public static Object swap()
swapInt
public static int swapInt(int first,
int second)
swapInt
public static int swapInt()
getObjectName
public static String getObjectName(Object pObject_)
- pObject_.getClass().getName() returns the name including
its package. This method returns just the name without
its package.
All Packages Class Hierarchy This Package Previous Next Index