FileDocCategorySizeDatePackage
StringUtils.javaAPI DocGlassfish v2 API2823Wed Feb 08 12:31:00 GMT 2006persistence.antlr

StringUtils

public class StringUtils extends Object

Fields Summary
Constructors Summary
Methods Summary
public static java.lang.StringstripBack(java.lang.String s, char c)
General-purpose utility function for removing characters from back of string

param
s The string to process
param
c The character to remove
return
The resulting string

        while (s.length() > 0 && s.charAt(s.length() - 1) == c) {
            s = s.substring(0, s.length() - 1);
        }
        return s;
    
public static java.lang.StringstripBack(java.lang.String s, java.lang.String remove)
General-purpose utility function for removing characters from back of string

param
s The string to process
param
remove A string containing the set of characters to remove
return
The resulting string

        boolean changed;
        do {
            changed = false;
            for (int i = 0; i < remove.length(); i++) {
                char c = remove.charAt(i);
                while (s.length() > 0 && s.charAt(s.length() - 1) == c) {
                    changed = true;
                    s = s.substring(0, s.length() - 1);
                }
            }
        } while (changed);
        return s;
    
public static java.lang.StringstripFront(java.lang.String s, char c)
General-purpose utility function for removing characters from front of string

param
s The string to process
param
c The character to remove
return
The resulting string

        while (s.length() > 0 && s.charAt(0) == c) {
            s = s.substring(1);
        }
        return s;
    
public static java.lang.StringstripFront(java.lang.String s, java.lang.String remove)
General-purpose utility function for removing characters from front of string

param
s The string to process
param
remove A string containing the set of characters to remove
return
The resulting string

        boolean changed;
        do {
            changed = false;
            for (int i = 0; i < remove.length(); i++) {
                char c = remove.charAt(i);
                while (s.length() > 0 && s.charAt(0) == c) {
                    changed = true;
                    s = s.substring(1);
                }
            }
        } while (changed);
        return s;
    
public static java.lang.StringstripFrontBack(java.lang.String src, java.lang.String head, java.lang.String tail)
General-purpose utility function for removing characters from the front and back of string

param
s The string to process
param
head exact string to strip from head
param
tail exact string to strip from tail
return
The resulting string

        int h = src.indexOf(head);
        int t = src.lastIndexOf(tail);
        if (h == -1 || t == -1) return src;
        return src.substring(h + 1, t);