| 
 | Apache JMeter | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.jorphan.util.JOrphanUtils
public final class JOrphanUtils
This class contains frequently-used static utility methods.
| Method Summary | |
|---|---|
| static byte[] | baToHexBytes(byte[] ba)Convert binary byte array to hex string. | 
| static String | baToHexString(byte[] ba)Convert binary byte array to hex string. | 
| static String | booleanToSTRING(boolean value)Convert a boolean to its upper case string representation. | 
| static void | closeQuietly(Closeable cl)Close a Closeable with no error thrown | 
| static void | closeQuietly(ServerSocket sock)close a Socket with no error thrown | 
| static void | closeQuietly(Socket sock)close a Socket with no error thrown | 
| static void | displayThreads(boolean includeDaemons)Display currently running threads on system.out This may be expensive to run. | 
| static byte[] | getByteArraySlice(byte[] array,
                  int begin,
                  int end)Returns a slice of a byte array. | 
| static boolean | isBlank(String value)Check that value is empty (""), null or whitespace only. | 
| static boolean | isXML(byte[] target)Detects if some content starts with the standard XML prefix. | 
| static StringBuilder | leftAlign(StringBuilder in,
          int len)Left aligns some text in a StringBuilder N.B. modifies the input buffer | 
| static String | nullifyIfEmptyTrimmed(String input)Returns null if input is empty, null or contains spaces | 
| static int | read(InputStream is,
     byte[] buffer,
     int offset,
     int length)Read as much as possible into buffer. | 
| static String | replaceAllChars(String source,
                char search,
                String replace)Version of String.replaceAll() for JDK1.3 See below for another version which replaces strings rather than chars | 
| static String | replaceFirst(String source,
             String search,
             String replace)Simple-minded String.replace() for JDK1.3 Should probably be recoded... | 
| static StringBuilder | rightAlign(StringBuilder in,
           int len)Right aligns some text in a StringBuilder N.B. modifies the input buffer | 
| static String[] | split(String splittee,
      String splitChar) | 
| static String[] | split(String splittee,
      String splitChar,
      boolean truncate)This is _almost_ equivalent to the String.split method in JDK 1.4. | 
| 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). | 
| static boolean | startsWith(byte[] target,
           byte[] search,
           int offset)Check if a byte array starts with the given byte array. | 
| static String | substitute(String input,
           String pattern,
           String sub)Replace all patterns in a String | 
| static String | trim(String input,
     String delims)Trim a string by the tokens provided. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Method Detail | 
|---|
public static String[] split(String splittee,
                             String splitChar,
                             boolean truncate)
This piece of code used to be part of JMeterUtils, but was moved here because some JOrphan classes use it too.
splittee - String to be splitsplitChar - Character(s) to split the string on, these are treated as a single unittruncate - Should adjacent and leading/trailing splitChars be removed?
split(String, String, String)
public static String[] split(String splittee,
                             String splitChar)
public static String[] split(String splittee,
                             String delims,
                             String def)
splittee - String to be split.delims - Delimiter character(s) to split the string ondef - Default value to place between two split chars that have
            nothing between them. If null, then ignore omitted elements.
NullPointerException - if splittee or delims are nullsplit(String, String, boolean), 
This is a rewritten version of JMeterUtils.split()
public static StringBuilder rightAlign(StringBuilder in,
                                       int len)
in - StringBuilder containing some textlen - output length desired
public static StringBuilder leftAlign(StringBuilder in,
                                      int len)
in - StringBuilder containing some textlen - output length desired
public static String booleanToSTRING(boolean value)
value - boolean to convert
public static String replaceFirst(String source,
                                  String search,
                                  String replace)
source - input stringsearch - string to look for (no regular expressions)replace - string to replace the search string
public static String replaceAllChars(String source,
                                     char search,
                                     String replace)
source - input stringsearch - char to look for (no regular expressions)replace - string to replace the search string
public static String substitute(String input,
                                String pattern,
                                String sub)
input - - string to be transformedpattern - - pattern to replacesub - - replacement
- JDK1.4 only
public static String trim(String input,
                          String delims)
input - string to trimdelims - list of delimiters
public static byte[] getByteArraySlice(byte[] array,
                                       int begin,
                                       int end)
array - -
            input arraybegin - -
            start of sliceend - -
            end of slice
public static void closeQuietly(Closeable cl)
cl - - Closeable (may be null)public static void closeQuietly(Socket sock)
sock - - Socket (may be null)public static void closeQuietly(ServerSocket sock)
sock - - ServerSocket (may be null)
public static boolean startsWith(byte[] target,
                                 byte[] search,
                                 int offset)
target - array to scansearch - array to search foroffset - starting offset (>=0)
String.startsWith(String, int)public static boolean isXML(byte[] target)
target - the content to check
public static String baToHexString(byte[] ba)
ba - input binary byte array
public static byte[] baToHexBytes(byte[] ba)
ba - input binary byte array
public static int read(InputStream is,
                       byte[] buffer,
                       int offset,
                       int length)
                throws IOException
is - the stream to read frombuffer - output bufferoffset - offset into bufferlength - number of bytes to read
IOExceptionpublic static void displayThreads(boolean includeDaemons)
includeDaemons - whether to include daemon threads or not.public static String nullifyIfEmptyTrimmed(String input)
input - String
public static boolean isBlank(String value)
value - Value
| 
 | Apache JMeter | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||