DRCL JavaSim API

drcl.util
Class StringUtil

java.lang.Object
  |
  +--drcl.util.StringUtil

public class StringUtil
extends java.lang.Object

Some commonly-used string utilities.


Field Summary
static java.lang.String DEFAULT_DELIMITERS
           
static java.lang.String EMPTY_STRING
           
static char[] HEX
           
 
Constructor Summary
StringUtil()
           
 
Method Summary
static java.lang.String addEscape(java.lang.String s_, java.lang.String escapeSet_)
           
static int compare(java.lang.StringBuffer s, java.lang.StringBuffer t)
          Returns 1 if s > t, -1 if s < t, 0 otherwise.
static int compare(java.lang.String s, java.lang.String t)
          Returns 1 if s > t, -1 if s < t, 0 otherwise.
static java.lang.String finalPortionClassName(java.lang.Class class_)
          Extract final portion of a full class name.
static java.lang.String findCommonPrefix(java.lang.String[] ss_)
          Returns null if nothing to do.
static java.lang.String getAcronym(java.lang.String s)
           
static java.lang.String lastSubstring(java.lang.String target_, java.lang.String separator_)
          Extract substring after the last appearance of the separator string.
static void main(java.lang.String[] arg)
           
static boolean match(java.lang.String str, java.lang.String pat)
          Returns true if the given string matches the given pattern.
static boolean match2(java.lang.String str, java.lang.String pat)
          Returns true if the given string matches the given pattern.
static java.lang.String removeEscape(java.lang.String s_)
           
static void sort(java.lang.Object[] array_, boolean accendingOrder_)
           
static void sort(java.lang.String[] array_, boolean accendingOrder_)
           
static void sort(java.lang.StringBuffer[] array_, boolean accendingOrder_)
           
static java.lang.String[] substrings(java.lang.String db_)
           
static java.lang.String[] substrings(java.lang.String db_, java.lang.String delim_)
           
static java.lang.String[] substrings(java.lang.String db_, java.lang.String delim_, java.lang.String left_)
           
static java.lang.String[] substrings(java.lang.String s_, java.lang.String delim_, java.lang.String left_, java.lang.String right_)
          Breaks the given string according to the delimiters.
static java.lang.String toBinary(int n_)
          Represents an integer in the binary representation.
static java.lang.String toBinary(int n_, boolean skipLeadingZeros_)
          Represents an integer in the binary form.
static java.lang.String toBinary(int n_, int lsb_, int nb_)
          Represents a range of bits in an integer in the binary form.
static java.lang.String toBinary(long n_)
          Represents a long integer in the binary form.
static java.lang.String toBinary(long n_, boolean skipLeadingZeros_)
          Represents a long integer in the binary form.
static java.lang.String toBinary(long n_, int lsb_, int nb_)
          Represents a range of bits in a long integer in the binary form.
static java.lang.String toHex(int n_)
          Represents an integer in the hex form.
static java.lang.String toHex(int n_, boolean skipLeadingZeros_)
          Represents an integer in the hex form.
static java.lang.String toHex(int n_, int lsb_, int nb_)
          Represents a range of bits in an integer in the hex form.
static java.lang.String toHex(long n_)
          Represents a long integer in the hex form.
static java.lang.String toHex(long n_, boolean skipLeadingZeros_)
          Represents a long integer in the hex form.
static java.lang.String toHex(long n_, int lsb_, int nb_)
          Represents a range of bits in a long integer in the hex form.
static java.lang.String toString(boolean[] a_)
           
static java.lang.String toString(boolean[] a_, java.lang.String separator_, int maxcount_)
           
static java.lang.String toString(byte[] a_)
           
static java.lang.String toString(byte[] a_, java.lang.String separator_, int maxcount_)
           
static java.lang.String toString(char[] a_)
           
static java.lang.String toString(char[] a_, java.lang.String separator_, int maxcount_)
           
static java.lang.String toString(java.lang.Class class_)
           
static java.lang.String toString(double[] a_)
           
static java.lang.String toString(double[] a_, java.lang.String separator_, int maxcount_)
           
static java.lang.String toString(double d, int f)
          Format a double number.
static java.lang.String toString(double d, int nn, int ff)
          Format a double number.
static java.lang.String toString(float[] a_)
           
static java.lang.String toString(float[] a_, java.lang.String separator_, int maxcount_)
           
static java.lang.String toString(java.util.Hashtable ht_)
           
static java.lang.String toString(int[] a_)
           
static java.lang.String toString(int[] a_, java.lang.String separator_, int maxcount_)
           
static java.lang.String toString(long[] a_)
           
static java.lang.String toString(long[] a_, java.lang.String separator_, int maxcount_)
           
static java.lang.String toString(java.lang.Object o_)
           
static java.lang.String toString(java.lang.Object o_, java.lang.String separator_, int maxcount_)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_STRING

public static final java.lang.String EMPTY_STRING

DEFAULT_DELIMITERS

public static final java.lang.String DEFAULT_DELIMITERS

HEX

public static final char[] HEX
Constructor Detail

StringUtil

public StringUtil()
Method Detail

substrings

public static java.lang.String[] substrings(java.lang.String db_)

substrings

public static java.lang.String[] substrings(java.lang.String db_,
                                            java.lang.String delim_)

substrings

public static java.lang.String[] substrings(java.lang.String db_,
                                            java.lang.String delim_,
                                            java.lang.String left_)

substrings

public static java.lang.String[] substrings(java.lang.String s_,
                                            java.lang.String delim_,
                                            java.lang.String left_,
                                            java.lang.String right_)
Breaks the given string according to the delimiters.
Parameters:
s_ - the string.
delim_ - the delimiters; use default set if null is given.
left_ - the "left" delimiters.
right_ - the "right" delimiters.

getAcronym

public static java.lang.String getAcronym(java.lang.String s)

toString

public static java.lang.String toString(double d,
                                        int f)
Format a double number.
Parameters:
f - # of digits in fraction

toString

public static java.lang.String toString(double d,
                                        int nn,
                                        int ff)
Format a double number.
Parameters:
n - length of result
f - # of digits in fraction

finalPortionClassName

public static java.lang.String finalPortionClassName(java.lang.Class class_)
Extract final portion of a full class name.

lastSubstring

public static java.lang.String lastSubstring(java.lang.String target_,
                                             java.lang.String separator_)
Extract substring after the last appearance of the separator string.

toString

public static java.lang.String toString(java.util.Hashtable ht_)

toString

public static java.lang.String toString(java.lang.Object o_)

toString

public static java.lang.String toString(java.lang.Object o_,
                                        java.lang.String separator_,
                                        int maxcount_)

toString

public static java.lang.String toString(double[] a_)

toString

public static java.lang.String toString(double[] a_,
                                        java.lang.String separator_,
                                        int maxcount_)

toString

public static java.lang.String toString(float[] a_)

toString

public static java.lang.String toString(float[] a_,
                                        java.lang.String separator_,
                                        int maxcount_)

toString

public static java.lang.String toString(long[] a_)

toString

public static java.lang.String toString(long[] a_,
                                        java.lang.String separator_,
                                        int maxcount_)

toString

public static java.lang.String toString(int[] a_)

toString

public static java.lang.String toString(int[] a_,
                                        java.lang.String separator_,
                                        int maxcount_)

toString

public static java.lang.String toString(boolean[] a_)

toString

public static java.lang.String toString(boolean[] a_,
                                        java.lang.String separator_,
                                        int maxcount_)

toString

public static java.lang.String toString(byte[] a_)

toString

public static java.lang.String toString(byte[] a_,
                                        java.lang.String separator_,
                                        int maxcount_)

toString

public static java.lang.String toString(char[] a_)

toString

public static java.lang.String toString(char[] a_,
                                        java.lang.String separator_,
                                        int maxcount_)

toString

public static java.lang.String toString(java.lang.Class class_)

removeEscape

public static java.lang.String removeEscape(java.lang.String s_)

addEscape

public static java.lang.String addEscape(java.lang.String s_,
                                         java.lang.String escapeSet_)

match

public static final boolean match(java.lang.String str,
                                  java.lang.String pat)
Returns true if the given string matches the given pattern. The matching operation permits the following special characters in the pattern: *?\[]. The codes are borrowed from the implementation of the 'string match' command in JACL.

match2

public static final boolean match2(java.lang.String str,
                                   java.lang.String pat)
Returns true if the given string matches the given pattern. The matching operation permits the following special characters in the pattern: *?\[] and +- Most of the codes are borrowed from the implementation of the 'string match' command in JACL to handle *?\[]. We add codes to handle +-.

sort

public static void sort(java.lang.Object[] array_,
                        boolean accendingOrder_)

sort

public static void sort(java.lang.String[] array_,
                        boolean accendingOrder_)

sort

public static void sort(java.lang.StringBuffer[] array_,
                        boolean accendingOrder_)

compare

public static int compare(java.lang.String s,
                          java.lang.String t)
Returns 1 if s > t, -1 if s < t, 0 otherwise.

compare

public static int compare(java.lang.StringBuffer s,
                          java.lang.StringBuffer t)
Returns 1 if s > t, -1 if s < t, 0 otherwise.

findCommonPrefix

public static java.lang.String findCommonPrefix(java.lang.String[] ss_)
Returns null if nothing to do.

toBinary

public static java.lang.String toBinary(int n_)
Represents an integer in the binary representation.

toBinary

public static java.lang.String toBinary(int n_,
                                        boolean skipLeadingZeros_)
Represents an integer in the binary form.
Parameters:
skipLeadingZeros_ - if true, leading zeros are not printed.

toBinary

public static java.lang.String toBinary(int n_,
                                        int lsb_,
                                        int nb_)
Represents a range of bits in an integer in the binary form. The range is specified by the index of the least significant bit and the number of bits in the range.
Parameters:
lsb_ - index of least significant bit.
nb_ - number of bits.

toBinary

public static java.lang.String toBinary(long n_)
Represents a long integer in the binary form.

toBinary

public static java.lang.String toBinary(long n_,
                                        boolean skipLeadingZeros_)
Represents a long integer in the binary form.
Parameters:
skipLeadingZeros_ - if true, leading zeros are not printed.

toBinary

public static java.lang.String toBinary(long n_,
                                        int lsb_,
                                        int nb_)
Represents a range of bits in a long integer in the binary form. The range is specified by the index of the least significant bit and the number of bits in the range.
Parameters:
lsb_ - index of least significant bit.
nb_ - number of bits.

toHex

public static java.lang.String toHex(int n_)
Represents an integer in the hex form.

toHex

public static java.lang.String toHex(int n_,
                                     boolean skipLeadingZeros_)
Represents an integer in the hex form.
Parameters:
skipLeadingZeros_ - if true, leading zeros are not printed.

toHex

public static java.lang.String toHex(int n_,
                                     int lsb_,
                                     int nb_)
Represents a range of bits in an integer in the hex form. The range is specified by the index of the least significant bit and the number of bits in the range.
Parameters:
lsb_ - index of least significant bit.
nb_ - number of bits.

toHex

public static java.lang.String toHex(long n_)
Represents a long integer in the hex form.

toHex

public static java.lang.String toHex(long n_,
                                     boolean skipLeadingZeros_)
Represents a long integer in the hex form.
Parameters:
skipLeadingZeros_ - if true, leading zeros are not printed.

toHex

public static java.lang.String toHex(long n_,
                                     int lsb_,
                                     int nb_)
Represents a range of bits in a long integer in the hex form. The range is specified by the index of the least significant bit and the number of bits in the range.
Parameters:
lsb_ - index of least significant bit.
nb_ - number of bits.

main

public static void main(java.lang.String[] arg)

DRCL JavaSim API

Copyright © 2001 - DRCL, OSU     ~ Back to JavaSim Home ~