| java.lang.Object org.apache.jorphan.util.JOrphanUtils
JOrphanUtils | final public class JOrphanUtils (Code) | | This class contains frequently-used static utility methods.
|
Method Summary | |
public static String | booleanToSTRING(boolean value) | public static String | booleanToString(boolean value) | public static void | closeQuietly(InputStream is) | public static void | closeQuietly(OutputStream os) | public static void | closeQuietly(Writer wr) | public static void | closeQuietly(Reader rd) | public static void | closeQuietly(Socket sock) | public static void | closeQuietly(ServerSocket sock) | public static byte[] | getByteArraySlice(byte[] array, int begin, int end) Returns a slice of a byte array. | public static StringBuffer | leftAlign(StringBuffer in, int len) Left aligns some text in a StringBuffer N.B. | public static String | replaceAllChars(String source, char search, String replace) | public static String | replaceFirst(String source, String search, String replace) Simple-minded String.replace() for JDK1.3 Should probably be recoded... | public static StringBuffer | rightAlign(StringBuffer in, int len) Right aligns some text in a StringBuffer N.B. | public static String[] | split(String splittee, String splitChar, boolean truncate) This is _almost_ equivalent to the String.split method in JDK 1.4. | public static String[] | split(String splittee, String splitChar) | public static String[] | split(String splittee, String delims, String def) Takes a String and a tokenizer character string, and returns a new array of
strings of the string split by the tokenizer character(s).
Trailing delimiters are significant (unless the default = null)
Parameters: splittee - String to be split. Parameters: delims - Delimiter character(s) to split the string on Parameters: def - Default value to place between two split chars that havenothing between them. | public static String | substitute(String input, String pattern, String sub) | public static String | trim(String input, String delims) Trim a string by the tokens provided. | public static Boolean | valueOf(boolean value) |
booleanToSTRING | public static String booleanToSTRING(boolean value)(Code) | | Convert a boolean to its string representation Equivalent to
Boolean.valueOf(boolean).toString().toUpperCase() but valid also for JDK
1.3, which does not have valueOf(boolean)
Parameters: value - boolean to convert "TRUE" or "FALSE" |
booleanToString | public static String booleanToString(boolean value)(Code) | | Convert a boolean to its string representation Equivalent to
Boolean.toString(boolean) but valid also for JDK 1.3, which
does not have toString(boolean)
Parameters: value - boolean to convert "true" or "false" |
closeQuietly | public static void closeQuietly(InputStream is)(Code) | | close a stream with no error thrown
Parameters: is - - InputStream (may be null) |
closeQuietly | public static void closeQuietly(OutputStream os)(Code) | | close a stream with no error thrown
Parameters: os - - OutputStream (may be null) |
closeQuietly | public static void closeQuietly(Writer wr)(Code) | | close a Writer with no error thrown
Parameters: wr - - Writer (may be null) |
closeQuietly | public static void closeQuietly(Reader rd)(Code) | | close a Reader with no error thrown
Parameters: rd - - Reader (may be null) |
closeQuietly | public static void closeQuietly(Socket sock)(Code) | | close a Socket with no error thrown
Parameters: sock - - Socket (may be null) |
closeQuietly | public static void closeQuietly(ServerSocket sock)(Code) | | close a Socket with no error thrown
Parameters: sock - - ServerSocket (may be null) |
getByteArraySlice | public static byte[] getByteArraySlice(byte[] array, int begin, int end)(Code) | | Returns a slice of a byte array.
TODO - add bounds checking?
Parameters: array - -input array Parameters: begin - -start of slice Parameters: end - -end of slice slice from the input array |
leftAlign | public static StringBuffer leftAlign(StringBuffer in, int len)(Code) | | Left aligns some text in a StringBuffer N.B. modifies the input buffer
Parameters: in - StringBuffer containing some text Parameters: len - output length desired input StringBuffer, with trailing spaces |
replaceAllChars | public static String replaceAllChars(String source, char search, String replace)(Code) | | Version of String.replaceAll() for JDK1.3
See below for another version which replaces strings rather than chars
Parameters: source - input string Parameters: search - char to look for (no regular expressions) Parameters: replace - string to replace the search string the output string |
replaceFirst | public static String replaceFirst(String source, String search, String replace)(Code) | | Simple-minded String.replace() for JDK1.3 Should probably be recoded...
Parameters: source - input string Parameters: search - string to look for (no regular expressions) Parameters: replace - string to replace the search string the output string |
rightAlign | public static StringBuffer rightAlign(StringBuffer in, int len)(Code) | | Right aligns some text in a StringBuffer N.B. modifies the input buffer
Parameters: in - StringBuffer containing some text Parameters: len - output length desired input StringBuffer, with leading spaces |
split | public static String[] split(String splittee, String splitChar, boolean truncate)(Code) | | This is _almost_ equivalent to the String.split method in JDK 1.4. It is
here to enable us to support earlier JDKs.
Note that unlike JDK1.4 split(), it optionally ignores leading split Characters,
and the splitChar parameter is not a Regular expression
This piece of code used to be part of JMeterUtils, but was moved here
because some JOrphan classes use it too.
Parameters: splittee - String to be split Parameters: splitChar - Character(s) to split the string on, these are treated as a single unit Parameters: truncate - Should adjacent and leading/trailing splitChars be removed? Array of all the tokens. See Also: JOrphanUtils.split(String,String,String) |
split | public static String[] split(String splittee, String delims, String def)(Code) | | Takes a String and a tokenizer character string, and returns a new array of
strings of the string split by the tokenizer character(s).
Trailing delimiters are significant (unless the default = null)
Parameters: splittee - String to be split. Parameters: delims - Delimiter character(s) to split the string on Parameters: def - Default value to place between two split chars that havenothing between them. If null, then ignore omitted elements. Array of all the tokens. throws: NullPointerException - if splittee or delims are null See Also: JOrphanUtils.split(String,String,boolean) See Also: JOrphanUtils.split(String,String) See Also: This is a rewritten version of JMeterUtils.split() |
trim | public static String trim(String input, String delims)(Code) | | Trim a string by the tokens provided.
Parameters: input - string to trim Parameters: delims - list of delimiters input trimmed at the first delimiter |
valueOf | public static Boolean valueOf(boolean value)(Code) | | Version of Boolean.valueOf(boolean) for JDK 1.3
Parameters: value - boolean to convert Boolean.TRUE or Boolean.FALSE |
|
|