FileDocCategorySizeDatePackage
Functions.javaAPI DocGlassfish v2 API9015Sat May 05 19:17:24 BST 2007org.apache.taglibs.standard.functions

Functions

public class Functions extends Object

JSTL Functions

author
Pierre Delisle

Fields Summary
Constructors Summary
Methods Summary
public static booleancontains(java.lang.String input, java.lang.String substring)

        return indexOf(input, substring) != -1;
    
public static booleancontainsIgnoreCase(java.lang.String input, java.lang.String substring)

        if (input == null) input = "";
        if (substring == null) substring = "";        
        String inputUC = input.toUpperCase();
        String substringUC = substring.toUpperCase();
        return indexOf(inputUC, substringUC) != -1;
    
public static booleanendsWith(java.lang.String input, java.lang.String substring)

        if (input == null) input = "";
        if (substring == null) substring = "";
        int index = input.indexOf(substring);
        if (index == -1) return false;
        if (index == 0 && substring.length() == 0) return true;
        return (index == input.length() - substring.length());
    
public static java.lang.StringescapeXml(java.lang.String input)

        if (input == null) return "";
        return Util.escapeXml(input);
    
public static intindexOf(java.lang.String input, java.lang.String substring)

        if (input == null) input = "";
        if (substring == null) substring = "";
        return input.indexOf(substring);
    
public static java.lang.Stringjoin(java.lang.String[] array, java.lang.String separator)

        if (array == null) return "";         
        if (separator == null) separator = "";
        
        StringBuffer buf = new StringBuffer();
        for (int i=0; i<array.length; i++) {
            buf.append(array[i]);
            if (i < array.length-1) buf.append(separator);
        }
        
        return buf.toString();
    
public static intlength(java.lang.Object obj)

        if (obj == null) return 0;  
        
        if (obj instanceof String) return ((String)obj).length();
        if (obj instanceof Collection) return ((Collection)obj).size();
        if (obj instanceof Map) return ((Map)obj).size();
        
        int count = 0;
        if (obj instanceof Iterator) {
            Iterator iter = (Iterator)obj;
            count = 0;
            while (iter.hasNext()) {
                count++;
                iter.next();
            }
            return count;
        }            
        if (obj instanceof Enumeration) {
            Enumeration enum_ = (Enumeration)obj;
            count = 0;
            while (enum_.hasMoreElements()) {
                count++;
                enum_.nextElement();
            }
            return count;
        }
        try {
            count = Array.getLength(obj);
            return count;
        } catch (IllegalArgumentException ex) {}
        throw new JspTagException(Resources.getMessage("FOREACH_BAD_ITEMS"));        
    
public static java.lang.Stringreplace(java.lang.String input, java.lang.String substringBefore, java.lang.String substringAfter)

        if (input == null) input = "";
        if (input.length() == 0) return "";
        if (substringBefore == null) substringBefore = "";
        if (substringBefore.length() == 0) return input;
                
        StringBuffer buf = new StringBuffer(input.length());
        int startIndex = 0;
        int index;
        while ((index = input.indexOf(substringBefore, startIndex)) != -1) {
            buf.append(input.substring(startIndex, index)).append(substringAfter);
            startIndex = index + substringBefore.length();
        }
        return buf.append(input.substring(startIndex)).toString();
    
public static java.lang.String[]split(java.lang.String input, java.lang.String delimiters)

        String[] array;
        if (input == null) input = "";
        if (input.length() == 0) {
            array = new String[1];
            array[0] = "";
            return array;
        }
        
        if (delimiters == null) delimiters = "";

        StringTokenizer tok = new StringTokenizer(input, delimiters);
        int count = tok.countTokens();
        array = new String[count];
        int i = 0;
        while (tok.hasMoreTokens()) {
            array[i++] = tok.nextToken();
        }
        return array;
    
public static booleanstartsWith(java.lang.String input, java.lang.String substring)

        if (input == null) input = "";
        if (substring == null) substring = "";
        return input.startsWith(substring);
    
public static java.lang.Stringsubstring(java.lang.String input, int beginIndex, int endIndex)

        if (input == null) input = "";
        if (beginIndex >= input.length()) return "";
        if (beginIndex < 0) beginIndex = 0;
        if (endIndex < 0 || endIndex > input.length()) endIndex = input.length();
        if (endIndex < beginIndex) return "";
        return input.substring(beginIndex, endIndex);
    
public static java.lang.StringsubstringAfter(java.lang.String input, java.lang.String substring)

        if (input == null) input = "";
        if (input.length() == 0) return "";
        if (substring == null) substring = "";
        if (substring.length() == 0) return input;
        
        int index = input.indexOf(substring);
        if (index == -1) {
            return "";
        } else {
            return input.substring(index+substring.length());
        }
    
public static java.lang.StringsubstringBefore(java.lang.String input, java.lang.String substring)

        if (input == null) input = "";
        if (input.length() == 0) return "";
        if (substring == null) substring = "";
        if (substring.length() == 0) return "";

        int index = input.indexOf(substring);
        if (index == -1) {
            return "";
        } else {
            return input.substring(0, index);
        }
    
public static java.lang.StringtoLowerCase(java.lang.String input)
Converts all of the characters of the input string to lower case.

        return input.toLowerCase();
    
public static java.lang.StringtoUpperCase(java.lang.String input)
Converts all of the characters of the input string to upper case.

        return input.toUpperCase();
    
public static java.lang.Stringtrim(java.lang.String input)

        if (input == null) return "";
        return input.trim();