com.sun.btrace
Class BTraceUtils.Strings

java.lang.Object
  extended by com.sun.btrace.BTraceUtils.Strings
Enclosing class:
BTraceUtils

public static class BTraceUtils.Strings
extends java.lang.Object


Constructor Summary
BTraceUtils.Strings()
           
 
Method Summary
static java.lang.Appendable append(java.lang.Appendable buffer, java.lang.String strToAppend)
          Appends a string to an appendable buffer created by newStringBuilder()
static int compareTo(java.lang.String str1, java.lang.String str2)
          Compares two strings lexicographically.
static int compareToIgnoreCase(java.lang.String str1, java.lang.String str2)
          Compares two strings lexicographically, ignoring case differences.
static java.lang.String concat(java.lang.String str1, java.lang.String str2)
          Concatenates the specified strings together.
static boolean endsWith(java.lang.String s, java.lang.String end)
           
static int indexOf(java.lang.String str1, java.lang.String str2)
           
static int lastIndexOf(java.lang.String str1, java.lang.String str2)
           
static int length(java.lang.Appendable buffer)
          Checks the length of an appendable buffer created by newStringBuilder()
static int length(java.lang.String str)
          Returns the length of the given string.
static boolean matches(java.util.regex.Pattern regex, java.lang.String input)
          Matches the given (precompiled) regular expression and attempts to match the given input against it.
static boolean matches(java.lang.String regex, java.lang.String input)
          Compiles the given regular expression and attempts to match the given input against it.
static java.lang.Appendable newStringBuilder()
          Safely creates a new instance of an appendable string buffer
The buffer will not be thread safe.
static java.lang.Appendable newStringBuilder(boolean threadSafe)
          Safely creates a new instance of an appendable string buffer
static java.util.regex.Pattern pattern(java.lang.String regex)
          This is synonym for "regexp".
static java.util.regex.Pattern pattern(java.lang.String regex, int flags)
          This is synonym for "regexp".
static java.util.regex.Pattern regexp(java.lang.String regex)
          Compiles the given regular expression into a pattern.
static java.util.regex.Pattern regexp(java.lang.String regex, int flags)
          Compiles the given regular expression into a pattern with the given flags.
static boolean startsWith(java.lang.String s, java.lang.String start)
           
static java.lang.String str(boolean b)
          Returns a String object representing the specified boolean.
static java.lang.String str(char c)
          Returns a String object representing the specified char.
static java.lang.String str(double d)
          Returns a string representation of the double argument.
static java.lang.String str(float f)
          Returns a string representation of the float argument.
static java.lang.String str(int i)
          Returns a String object representing the specified integer.
static java.lang.String str(long l)
          Returns a String object representing the specified long.
static java.lang.String str(java.lang.Object obj)
          Returns a string representation of the object.
static java.lang.String strcat(java.lang.String str1, java.lang.String str2)
          This is synonym to "concat".
static int strcmp(java.lang.String str1, java.lang.String str2)
          This is synonym to "compareTo" method.
static int stricmp(java.lang.String str1, java.lang.String str2)
          This is synonym to "compareToIgnoreCase".
static int strlen(java.lang.String str)
          This is synonym for "length".
static int strstr(java.lang.String str1, java.lang.String str2)
          Find String within String
static java.lang.String substr(java.lang.String str, int start)
           
static java.lang.String substr(java.lang.String str, int start, int length)
          Substring
static java.lang.String toHexString(int i)
          Returns a string representation of the integer argument as an unsigned integer in base 16.
static java.lang.String toHexString(long l)
          Returns a string representation of the long argument as an unsigned integer in base 16.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BTraceUtils.Strings

public BTraceUtils.Strings()
Method Detail

startsWith

public static boolean startsWith(java.lang.String s,
                                 java.lang.String start)

endsWith

public static boolean endsWith(java.lang.String s,
                               java.lang.String end)

strcat

public static java.lang.String strcat(java.lang.String str1,
                                      java.lang.String str2)
This is synonym to "concat".

See Also:
concat(String, String)

concat

public static java.lang.String concat(java.lang.String str1,
                                      java.lang.String str2)
Concatenates the specified strings together.


compareTo

public static int compareTo(java.lang.String str1,
                            java.lang.String str2)
Compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings. The character sequence represented by the first String object is compared lexicographically to the character sequence represented by the second string. The result is a negative integer if the first String object lexicographically precedes the second string. The result is a positive integer if the first String object lexicographically follows the second string. The result is zero if the strings are equal; compareTo returns 0 exactly when the String.equals(Object) method would return true.


strcmp

public static int strcmp(java.lang.String str1,
                         java.lang.String str2)
This is synonym to "compareTo" method.

See Also:
compareTo(java.lang.String, java.lang.String)

compareToIgnoreCase

public static int compareToIgnoreCase(java.lang.String str1,
                                      java.lang.String str2)
Compares two strings lexicographically, ignoring case differences. This method returns an integer whose sign is that of calling compareTo with normalized versions of the strings where case differences have been eliminated by calling Character.toLowerCase(Character.toUpperCase(character)) on each character.


stricmp

public static int stricmp(java.lang.String str1,
                          java.lang.String str2)
This is synonym to "compareToIgnoreCase".

See Also:
compareToIgnoreCase(java.lang.String, java.lang.String)

strstr

public static int strstr(java.lang.String str1,
                         java.lang.String str2)
Find String within String


indexOf

public static int indexOf(java.lang.String str1,
                          java.lang.String str2)

lastIndexOf

public static int lastIndexOf(java.lang.String str1,
                              java.lang.String str2)

substr

public static java.lang.String substr(java.lang.String str,
                                      int start,
                                      int length)
Substring


substr

public static java.lang.String substr(java.lang.String str,
                                      int start)

length

public static int length(java.lang.String str)
Returns the length of the given string. The length is equal to the number of Unicode code units in the string.

Parameters:
str - String whose length is calculated.
Returns:
the length of the sequence of characters represented by this object.

strlen

public static int strlen(java.lang.String str)
This is synonym for "length".

See Also:
length(String)

regexp

public static java.util.regex.Pattern regexp(java.lang.String regex)
Compiles the given regular expression into a pattern.

Parameters:
regex - The expression to be compiled
Throws:
java.util.regex.PatternSyntaxException - If the expression's syntax is invalid

pattern

public static java.util.regex.Pattern pattern(java.lang.String regex)
This is synonym for "regexp".

See Also:
regexp(String)

regexp

public static java.util.regex.Pattern regexp(java.lang.String regex,
                                             int flags)
Compiles the given regular expression into a pattern with the given flags.

Parameters:
regex - The expression to be compiled
flags - Match flags, a bit mask that may include Pattern.CASE_INSENSITIVE, Pattern.MULTILINE, Pattern.DOTALL, Pattern.UNICODE_CASE, Pattern.CANON_EQ, Pattern.UNIX_LINES, Pattern.LITERAL and Pattern.COMMENTS
Throws:
java.lang.IllegalArgumentException - If bit values other than those corresponding to the defined match flags are set in flags
java.util.regex.PatternSyntaxException - If the expression's syntax is invalid

pattern

public static java.util.regex.Pattern pattern(java.lang.String regex,
                                              int flags)
This is synonym for "regexp".

See Also:
regexp(String, int)

matches

public static boolean matches(java.util.regex.Pattern regex,
                              java.lang.String input)
Matches the given (precompiled) regular expression and attempts to match the given input against it.


matches

public static boolean matches(java.lang.String regex,
                              java.lang.String input)
Compiles the given regular expression and attempts to match the given input against it.

An invocation of this convenience method of the form

 Pattern.matches(regex, input);
behaves in exactly the same way as the expression
 Pattern.compile(regex).matcher(input).matches()

If a pattern is to be used multiple times, compiling it once and reusing it will be more efficient than invoking this method each time.

Parameters:
regex - The expression to be compiled
input - The character sequence to be matched
Throws:
java.util.regex.PatternSyntaxException - If the expression's syntax is invalid

str

public static java.lang.String str(boolean b)
Returns a String object representing the specified boolean. If the specified boolean is true, then the string "true" will be returned, otherwise the string "false" will be returned.

Parameters:
b - the boolean to be converted
Returns:
the string representation of the specified boolean

str

public static java.lang.String str(char c)
Returns a String object representing the specified char. The result is a string of length 1 consisting solely of the specified char.

Parameters:
c - the char to be converted
Returns:
the string representation of the specified char

str

public static java.lang.String str(int i)
Returns a String object representing the specified integer. The argument is converted to signed decimal representation and returned as a string.

Parameters:
i - an integer to be converted.
Returns:
a string representation of the argument in base 10.

toHexString

public static java.lang.String toHexString(int i)
Returns a string representation of the integer argument as an unsigned integer in base 16.

The unsigned integer value is the argument plus 232 if the argument is negative; otherwise, it is equal to the argument. This value is converted to a string of ASCII digits in hexadecimal (base 16) with no extra leading 0s. If the unsigned magnitude is zero, it is represented by a single zero character '0' ('\u0030'); otherwise, the first character of the representation of the unsigned magnitude will not be the zero character. The following characters are used as hexadecimal digits:

 0123456789abcdef
 
These are the characters '\u0030' through '\u0039' and '\u0061' through '\u0066'.

Parameters:
i - an integer to be converted to a string.
Returns:
the string representation of the unsigned integer value represented by the argument in hexadecimal (base 16).

str

public static java.lang.String str(long l)
Returns a String object representing the specified long. The argument is converted to signed decimal representation and returned as a string.

Parameters:
l - a long to be converted.
Returns:
a string representation of the argument in base 10.

str

public static java.lang.String str(java.lang.Object obj)
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. For bootstrap classes, returns the result of calling Object.toString() override. For non-bootstrap classes, default toString() value [className@hashCode] is returned.

Parameters:
obj - the object whose string representation is returned
Returns:
a string representation of the given object.

toHexString

public static java.lang.String toHexString(long l)
Returns a string representation of the long argument as an unsigned integer in base 16.

The unsigned long value is the argument plus 264 if the argument is negative; otherwise, it is equal to the argument. This value is converted to a string of ASCII digits in hexadecimal (base 16) with no extra leading 0s. If the unsigned magnitude is zero, it is represented by a single zero character '0' ('\u0030'); otherwise, the first character of the representation of the unsigned magnitude will not be the zero character. The following characters are used as hexadecimal digits:

 0123456789abcdef
 
These are the characters '\u0030' through '\u0039' and '\u0061' through '\u0066'.

Parameters:
l - a long to be converted to a string.
Returns:
the string representation of the unsigned long value represented by the argument in hexadecimal (base 16).

str

public static java.lang.String str(float f)
Returns a string representation of the float argument. All characters mentioned below are ASCII characters. How many digits must be printed for the fractional part of m or a? There must be at least one digit to represent the fractional part, and beyond that as many, but only as many, more digits as are needed to uniquely distinguish the argument value from adjacent values of type float. That is, suppose that x is the exact mathematical value represented by the decimal representation produced by this method for a finite nonzero argument f. Then f must be the float value nearest to x; or, if two float values are equally close to x, then f must be one of them and the least significant bit of the significand of f must be 0.

Parameters:
f - the float to be converted.
Returns:
a string representation of the argument.

str

public static java.lang.String str(double d)
Returns a string representation of the double argument. All characters mentioned below are ASCII characters. How many digits must be printed for the fractional part of m or a? There must be at least one digit to represent the fractional part, and beyond that as many, but only as many, more digits as are needed to uniquely distinguish the argument value from adjacent values of type double. That is, suppose that x is the exact mathematical value represented by the decimal representation produced by this method for a finite nonzero argument d. Then d must be the double value nearest to x; or if two double values are equally close to x, then d must be one of them and the least significant bit of the significand of d must be 0.

Parameters:
d - the double to be converted.
Returns:
a string representation of the argument.

newStringBuilder

public static java.lang.Appendable newStringBuilder(boolean threadSafe)
Safely creates a new instance of an appendable string buffer

Parameters:
threadSafe - Specifies whether the buffer should be thread safe
Returns:
Returns either StringBuilder or StringBuffer instance depending on whether the instance is required to be thread safe or not, respectively.
Since:
1.2

newStringBuilder

public static java.lang.Appendable newStringBuilder()
Safely creates a new instance of an appendable string buffer
The buffer will not be thread safe.

Returns:
Returns a new instance of StringBuilder class
Since:
1.2

append

public static java.lang.Appendable append(java.lang.Appendable buffer,
                                          java.lang.String strToAppend)
Appends a string to an appendable buffer created by newStringBuilder()

Parameters:
buffer - The appendable buffer to append to
strToAppend - The string to append
Returns:
Returns the same appendable buffer instance
Since:
1.2

length

public static int length(java.lang.Appendable buffer)
Checks the length of an appendable buffer created by newStringBuilder()

Parameters:
buffer - The appendable buffer instance
Returns:
Returns the length of the text contained by the buffer
Since:
1.2