| java.lang.Object de.mcs.utils.StringFormat
StringFormat | final public class StringFormat (Code) | | Implements missing String format functions as a function library.
version: $Revision: 1.1 $ |
Method Summary | |
public static void | byte2hex(byte b, StringBuffer buf) Converts a byte to hex digit and writes to the supplied buffer. | public static String | containsChars(String source, String chars) Reads a string and searches for every occurence of one of the characters
in chars . | public static String | convertEscapes(String s) Converts some special characters (tab, CR, LF, 0 etc) from java escape
sequences to characters.
Parameters: s - the string to convert. | public static int | countsChars(String searchString, char character) Anzahl derr zeichen zählen. | public static String | filterString(String input, char left, char right) filters a string from the given characters. | public static String | filterString(String input, char filterchar) filters a string from the given characters. | public static String | filterWhiteSpace(String s) Removes white spaces (>=ascii 32) from a string and all spaces at the
end. | public static String | formatLong(long l, int length, char fill) Format the String representation of the given long to the given length
and fills up at the beginning with the given fill value. | public static String | formatString(String x, int length, char fill) Format the String representation of the given long to the given length
and fills up at the beginning with the given fill value. | public static String | formatStringLeading(String x, int length, char fill) Format the String representation of the given long to the given length
and fills up at the beginning with the given fill value. | public static String[] | fromCollection(Collection r) | public static byte[] | fromHexString(String str) Converts the given hex string to a byte array. | public static String | getList(Collection col, char sep) Creates a String that contains all element of the given collection,
seperated by the given seperator. | public static Collection | getMultiLineString(String input) Holt aus einer Stringliste (mit CRLF getrennt) eine Collection von
Strings. | public static String | getPathFromString(String string, int directoryDepth) Returns a each 2 characters separated PathString from a MD5 HexString The
used separator is System.getProperty("file.separator"). | public static Map<String, String> | getProperties(Collection col) Gets a Map of properties from a collection that contains strings like
"prop=value". | public static String | getProperty(String property, String defaultValue, Collection col) Returns the value of a property. | public static String | getPropertyString(Map props) Creates a property string ( a list of comma separated key=value items)
from a HashMap. | public static String | getStackTrace(Throwable cause) getting a stack trace as a string like in exception.printStackTrace.
Parameters: cause - the exception to convert. | public static String | left(String string, int pos) | public static String | md5String(String s) Method md5String. | public static List | parseList(String col, char sep) Parses the given String and returns a collection of String elements. | public static String | replaceString(String newString, String source, String searchStr) Method replaceString. | public static String | right(String string, int pos) | public static String | rtrim(String s) rightrim. | public static String | saveConvert(String theString, boolean escapeSpace) converting a string so that it can be saved into a human readable file.
Parameters: theString - the string to convert Parameters: escapeSpace - spaces must be escaped. | public static String | setProperty(String property, String value, String propertyString) Sets a property in a property string list. | public static String[] | splitFirst(String string, String search) | public static int | strToInt(String strNum) Converts a string to its int equivalent. | public static String | toHexString(byte[] block) Converts a byte array to hex string. | public static String | wellForm(String g) Creates a well formed XML string. |
byte2hex | public static void byte2hex(byte b, StringBuffer buf)(Code) | | Converts a byte to hex digit and writes to the supplied buffer.
Parameters: b - byte to convert Parameters: buf - StringBuffer to append to |
containsChars | public static String containsChars(String source, String chars)(Code) | | Reads a string and searches for every occurence of one of the characters
in chars . If the character occurs in chars
it will be added to the result. If none of the characters in
chars occurs in source , the method will
return null .
Parameters: source - the source to check Parameters: chars - a string that contains every character to check for. the result of occurences of characters from chars in source or null . |
convertEscapes | public static String convertEscapes(String s)(Code) | | Converts some special characters (tab, CR, LF, 0 etc) from java escape
sequences to characters.
Parameters: s - the string to convert. the converted string |
countsChars | public static int countsChars(String searchString, char character)(Code) | | Anzahl derr zeichen zählen.
Parameters: searchString - the string to count chars Parameters: character - the character to count the count of chars |
filterString | public static String filterString(String input, char left, char right)(Code) | | filters a string from the given characters. Example: filterString
("{blabla}", " {", "}") returns blabla
Parameters: input - input String Parameters: left - linke Begrenzung Parameters: right - rechte Begrenzung the_filtered_string |
filterString | public static String filterString(String input, char filterchar)(Code) | | filters a string from the given characters. Example: filterString
("'blabla'", " '") returns blabla
Parameters: input - zu filternder String Parameters: filterchar - begrenzungszeichen the_filtered_string |
filterWhiteSpace | public static String filterWhiteSpace(String s)(Code) | | Removes white spaces (>=ascii 32) from a string and all spaces at the
end.
Parameters: s - the input string a string without whitespaces |
formatLong | public static String formatLong(long l, int length, char fill)(Code) | | Format the String representation of the given long to the given length
and fills up at the beginning with the given fill value. l=654, length=5,
fill='0' will lead to '00654'. If the result of l is longer than length,
the full length of l is return
Parameters: l - the long to be converted Parameters: length - the length of the result Parameters: fill - the fill value of the result the formatted string |
formatString | public static String formatString(String x, int length, char fill)(Code) | | Format the String representation of the given long to the given length
and fills up at the beginning with the given fill value. l=654, length=5,
fill='0' will lead to '00654'. If the result of l is longer than length,
the full length of l is return
Parameters: x - the long to be converted Parameters: length - the length of the result Parameters: fill - the fill value of the result the formatted string |
formatStringLeading | public static String formatStringLeading(String x, int length, char fill)(Code) | | Format the String representation of the given long to the given length
and fills up at the beginning with the given fill value. l=654, length=5,
fill='0' will lead to '00654'. If the result of l is longer than length,
the full length of l is return
Parameters: x - the long to be converted Parameters: length - the length of the result Parameters: fill - the fill value of the result the formatted string |
fromCollection | public static String[] fromCollection(Collection r)(Code) | | Parameters: r - a colletion that contains strings a String array |
fromHexString | public static byte[] fromHexString(String str)(Code) | | Converts the given hex string to a byte array. The hex string is
interpreted as a sequence of hex digit pairs in high, low order. For odd
length strings the last digit is interpreted as low value.
Parameters: str - The hex string to convert to a byte array. A byte array containing the byte values of the hex string. throwsNumberFormatException if the given string isn't a hex string |
getList | public static String getList(Collection col, char sep)(Code) | | Creates a String that contains all element of the given collection,
seperated by the given seperator.
Parameters: col - a collection of objects Parameters: sep - the seperator result String |
getMultiLineString | public static Collection getMultiLineString(String input)(Code) | | Holt aus einer Stringliste (mit CRLF getrennt) eine Collection von
Strings.
Parameters: input - EingangsString Collection |
getPathFromString | public static String getPathFromString(String string, int directoryDepth)(Code) | | Returns a each 2 characters separated PathString from a MD5 HexString The
used separator is System.getProperty("file.separator").
Parameters: string - der String der gewandelt werden soll Parameters: directoryDepth - Die Anzahl der Unterverzeichisse String |
getProperties | public static Map<String, String> getProperties(Collection col)(Code) | | Gets a Map of properties from a collection that contains strings like
"prop=value".
Parameters: col - the properties a map |
getProperty | public static String getProperty(String property, String defaultValue, Collection col)(Code) | | Returns the value of a property. The given collection should contain
strings with "name=value" entries. The method looks for the name and
returns the value, else returns the default value
Parameters: property - ??? Parameters: defaultValue - ??? Parameters: col - ??? the value of the property or the default |
getPropertyString | public static String getPropertyString(Map props)(Code) | | Creates a property string ( a list of comma separated key=value items)
from a HashMap.
Parameters: props - the properties a string that contains the key=value list |
getStackTrace | public static String getStackTrace(Throwable cause)(Code) | | getting a stack trace as a string like in exception.printStackTrace.
Parameters: cause - the exception to convert. String |
md5String | public static String md5String(String s)(Code) | | Method md5String.
Parameters: s - String String |
parseList | public static List parseList(String col, char sep)(Code) | | Parses the given String and returns a collection of String elements. If
the separator must be part of the String, the single string element must
be included in '"'
Parameters: col - a string with separated strings Parameters: sep - a seperator a collection of strings |
replaceString | public static String replaceString(String newString, String source, String searchStr)(Code) | | Method replaceString.
Parameters: newString - String Parameters: source - String Parameters: searchStr - String String |
rtrim | public static String rtrim(String s)(Code) | | rightrim.
Parameters: s - inputstring string |
saveConvert | public static String saveConvert(String theString, boolean escapeSpace)(Code) | | converting a string so that it can be saved into a human readable file.
Parameters: theString - the string to convert Parameters: escapeSpace - spaces must be escaped. the converted String. |
setProperty | public static String setProperty(String property, String value, String propertyString)(Code) | | Sets a property in a property string list.
Parameters: property - the name of the property Parameters: value - the value Parameters: propertyString - the property string list the result |
strToInt | public static int strToInt(String strNum)(Code) | | Converts a string to its int equivalent.
Parameters: strNum - The string that should be converted int The int version of the string value throwsNumberFormatException if the given String isn't a textualrepresentation of an int value. |
toHexString | public static String toHexString(byte[] block)(Code) | | Converts a byte array to hex string.
Parameters: block - bytearray to convert String Hexstring representing the block, constisting only fromuppercase letters [0-9A-F]* |
wellForm | public static String wellForm(String g)(Code) | | Creates a well formed XML string.
Parameters: g - original string a well formed string |
|
|