com.go.tea.runtime
Interface UtilityContext

All Superinterfaces:
Context, OutputReceiver
All Known Subinterfaces:
AdminHttpContext, HttpContext
All Known Implementing Classes:
DefaultContext

public interface UtilityContext
extends Context

Extends the basic context to provide generic utility functions that most templates will need to use for formatting.

Version:
12 , 9/07/00
Author:
Brian S O'Neill

Method Summary
 java.lang.String cardinal(long n)
          A function that converts an integer to a cardinal value.
 java.lang.String cardinal(java.lang.Long n)
          A function that converts an integer to a cardinal value.
 java.util.Date currentDate()
          Returns a Date object with the current date and time.
 boolean endsWith(java.lang.String str, java.lang.String suffix)
          Tests if the given string ends with the given suffix.
 int[] find(java.lang.String str, java.lang.String search)
          Finds the indices for each occurrence of the given search string in the source string.
 int[] find(java.lang.String str, java.lang.String search, int fromIndex)
          Finds the indices for each occurrence of the given search string in the source string, starting from the given index.
 int findFirst(java.lang.String str, java.lang.String search)
          Finds the index of the first occurrence of the given search string in the source string, or -1 if not found.
 int findFirst(java.lang.String str, java.lang.String search, int fromIndex)
          Finds the index of the first occurrence of the given search string in the source string, starting from the given index, or -1 if not found.
 int findLast(java.lang.String str, java.lang.String search)
          Finds the index of the last occurrence of the given search string in the source string, or -1 if not found.
 int findLast(java.lang.String str, java.lang.String search, int fromIndex)
          Finds the index of the last occurrence of the given search string in the source string, starting from the given index, or -1 if not found.
 java.lang.String ordinal(long n)
          A function that converts an integer to an ordinal value.
 java.lang.String ordinal(java.lang.Long n)
          A function that converts an integer to an ordinal value.
 java.lang.String replace(java.lang.String source, java.util.Map patternReplacements)
          Applies string replacements using the pattern-replacement pairs provided by the given map (associative array).
 java.lang.String replace(java.lang.String source, java.lang.String pattern, java.lang.String replacement)
          Replaces all exact matches of the given pattern in the source string with the provided replacement.
 java.lang.String replace(java.lang.String source, java.lang.String pattern, java.lang.String replacement, int fromIndex)
          Replaces all exact matches of the given pattern in the source string with the provided replacement, starting from the given index.
 java.lang.String replaceFirst(java.lang.String source, java.lang.String pattern, java.lang.String replacement)
          Replaces the first exact match of the given pattern in the source string with the provided replacement.
 java.lang.String replaceFirst(java.lang.String source, java.lang.String pattern, java.lang.String replacement, int fromIndex)
          Replaces the first exact match of the given pattern in the source string with the provided replacement, starting from the given index.
 java.lang.String replaceLast(java.lang.String source, java.lang.String pattern, java.lang.String replacement)
          Replaces the last exact match of the given pattern in the source string with the provided replacement.
 java.lang.String replaceLast(java.lang.String source, java.lang.String pattern, java.lang.String replacement, int fromIndex)
          Replaces the last exact match of the given pattern in the source string with the provided replacement, starting from the given index.
 java.lang.String shortOrdinal(long n)
          A function that converts an integer to a short ordinal value.
 java.lang.String shortOrdinal(java.lang.Long n)
          A function that converts an integer to a short ordinal value.
 boolean startsWith(java.lang.String str, java.lang.String prefix)
          Tests if the given string starts with the given prefix.
 java.lang.String substring(java.lang.String str, int startIndex)
          Returns the trailing end of the given string, starting from the given index.
 java.lang.String substring(java.lang.String str, int startIndex, int endIndex)
          Returns a sub-portion of the given string for the characters that are at or after the starting index, and are before the end index.
 java.lang.String toLowerCase(java.lang.String str)
          Converts all the characters in the given string to lowercase.
 java.lang.String toUpperCase(java.lang.String str)
          Converts all the characters in the given string to uppercase.
 java.lang.String trim(java.lang.String str)
          Trims all leading and trailing whitespace characters from the given string.
 java.lang.String trimLeading(java.lang.String str)
          Trims all leading whitespace characters from the given string.
 java.lang.String trimTrailing(java.lang.String str)
          Trims all trailing whitespace characters from the given string.
 
Methods inherited from interface com.go.tea.runtime.Context
dateFormat, dateFormat, getAvailableLocales, getAvailableTimeZones, getDateFormat, getDateFormatTimeZone, getLocale, getNullFormat, getNumberFormat, getNumberFormatInfinity, getNumberFormatNaN, nullFormat, numberFormat, numberFormat, print, print, print, print, print, print, print, setLocale, setLocale, setLocale, toString, toString, toString, toString, toString, toString, toString, toString
 

Method Detail

currentDate

public java.util.Date currentDate()
Returns a Date object with the current date and time.

startsWith

public boolean startsWith(java.lang.String str,
                          java.lang.String prefix)
Tests if the given string starts with the given prefix. Returns true if the given string starts with the given prefix.
Parameters:
str - the source string
prefix - the prefix to test for
Returns:
true if the given string starts with the given prefix

endsWith

public boolean endsWith(java.lang.String str,
                        java.lang.String suffix)
Tests if the given string ends with the given suffix. Returns true if the given string ends with the given suffix.
Parameters:
str - the source string
suffix - the suffix to test for
Returns:
true if the given string ends with the given suffix

find

public int[] find(java.lang.String str,
                  java.lang.String search)
Finds the indices for each occurrence of the given search string in the source string. Returns an array of indices, which is empty if the search string wasn't found
Parameters:
str - the source string
search - the string to search for
Returns:
an array of indices, which is empty if the search string wasn't found

find

public int[] find(java.lang.String str,
                  java.lang.String search,
                  int fromIndex)
Finds the indices for each occurrence of the given search string in the source string, starting from the given index.
Parameters:
str - the source string
search - the string to search for
fromIndex - index to start the find
Returns:
an array of indices, which is empty if the search string wasn't found

findFirst

public int findFirst(java.lang.String str,
                     java.lang.String search)
Finds the index of the first occurrence of the given search string in the source string, or -1 if not found.
Parameters:
str - the source string
search - the string to search for
Returns:
the start index of the found string or -1 if not found

findFirst

public int findFirst(java.lang.String str,
                     java.lang.String search,
                     int fromIndex)
Finds the index of the first occurrence of the given search string in the source string, starting from the given index, or -1 if not found.
Parameters:
str - the source string
search - the string to search for
fromIndex - index to start the find
Returns:
the start index of the found string or -1 if not found

findLast

public int findLast(java.lang.String str,
                    java.lang.String search)
Finds the index of the last occurrence of the given search string in the source string, or -1 if not found.
Parameters:
str - the source string
search - the string to search for
Returns:
the start index of the found string or -1 if not found

findLast

public int findLast(java.lang.String str,
                    java.lang.String search,
                    int fromIndex)
Finds the index of the last occurrence of the given search string in the source string, starting from the given index, or -1 if not found.
Parameters:
str - the source string
search - the string to search for
fromIndex - optional index to start the find
Returns:
the start index of the found string or -1 if not found

substring

public java.lang.String substring(java.lang.String str,
                                  int startIndex)
Returns the trailing end of the given string, starting from the given index.
Parameters:
str - the source string
startIndex - the start index, inclusive
Returns:
the specified substring.

substring

public java.lang.String substring(java.lang.String str,
                                  int startIndex,
                                  int endIndex)
Returns a sub-portion of the given string for the characters that are at or after the starting index, and are before the end index.
Parameters:
str - the source string
startIndex - the start index, inclusive
endIndex - the ending index, exclusive
Returns:
the specified substring.

toLowerCase

public java.lang.String toLowerCase(java.lang.String str)
Converts all the characters in the given string to lowercase.
Parameters:
str - the string to convert
Returns:
the string converted to lowercase

toUpperCase

public java.lang.String toUpperCase(java.lang.String str)
Converts all the characters in the given string to uppercase.
Parameters:
str - the string to convert
Returns:
the string converted to uppercase

trim

public java.lang.String trim(java.lang.String str)
Trims all leading and trailing whitespace characters from the given string.
Parameters:
str - the string to trim
Returns:
the trimmed string

trimLeading

public java.lang.String trimLeading(java.lang.String str)
Trims all leading whitespace characters from the given string.
Parameters:
str - the string to trim
Returns:
the trimmed string

trimTrailing

public java.lang.String trimTrailing(java.lang.String str)
Trims all trailing whitespace characters from the given string.
Parameters:
str - the string to trim
Returns:
the trimmed string

replace

public java.lang.String replace(java.lang.String source,
                                java.lang.String pattern,
                                java.lang.String replacement)
Replaces all exact matches of the given pattern in the source string with the provided replacement.
Parameters:
source - the source string
pattern - the simple string pattern to search for
replacement - the string to use for replacing matched patterns.
Returns:
the string with any replacements applied.

replace

public java.lang.String replace(java.lang.String source,
                                java.lang.String pattern,
                                java.lang.String replacement,
                                int fromIndex)
Replaces all exact matches of the given pattern in the source string with the provided replacement, starting from the given index.
Parameters:
source - the source string
pattern - the simple string pattern to search for
replacement - the string to use for replacing matched patterns.
fromIndex - index to start the replace
Returns:
the string with any replacements applied.

replace

public java.lang.String replace(java.lang.String source,
                                java.util.Map patternReplacements)
Applies string replacements using the pattern-replacement pairs provided by the given map (associative array). The longest matching pattern is used for selecting an appropriate replacement.
Parameters:
source - the source string
patternReplacements - pattern-replacement pairs

replaceFirst

public java.lang.String replaceFirst(java.lang.String source,
                                     java.lang.String pattern,
                                     java.lang.String replacement)
Replaces the first exact match of the given pattern in the source string with the provided replacement.
Parameters:
source - the source string
pattern - the simple string pattern to search for
replacement - the string to use for replacing matched patterns
Returns:
the string with any replacements applied

replaceFirst

public java.lang.String replaceFirst(java.lang.String source,
                                     java.lang.String pattern,
                                     java.lang.String replacement,
                                     int fromIndex)
Replaces the first exact match of the given pattern in the source string with the provided replacement, starting from the given index.
Parameters:
source - the source string
pattern - the simple string pattern to search for
replacement - the string to use for replacing matched patterns
fromIndex - index to start the replace
Returns:
the string with any replacements applied

replaceLast

public java.lang.String replaceLast(java.lang.String source,
                                    java.lang.String pattern,
                                    java.lang.String replacement)
Replaces the last exact match of the given pattern in the source string with the provided replacement.
Parameters:
source - the source string
pattern - the simple string pattern to search for
replacement - the string to use for replacing matched patterns
Returns:
the string with any replacements applied

replaceLast

public java.lang.String replaceLast(java.lang.String source,
                                    java.lang.String pattern,
                                    java.lang.String replacement,
                                    int fromIndex)
Replaces the last exact match of the given pattern in the source string with the provided replacement, starting from the given index.
Parameters:
source - the source string
pattern - the simple string pattern to search for
replacement - the string to use for replacing matched patterns
fromIndex - index to start the replace
Returns:
the string with any replacements applied

shortOrdinal

public java.lang.String shortOrdinal(java.lang.Long n)
A function that converts an integer to a short ordinal value. i.e. 1st, 2nd, 3rd etc.
Parameters:
n - the number to convert
Returns:
a String containing the short ordinal value of the specified number

shortOrdinal

public java.lang.String shortOrdinal(long n)
A function that converts an integer to a short ordinal value. i.e. 1st, 2nd, 3rd etc.
Parameters:
n - the number to convert
Returns:
a String containing the short ordinal value of the specified number

ordinal

public java.lang.String ordinal(java.lang.Long n)
A function that converts an integer to an ordinal value. i.e. first, second, third etc.
Parameters:
n - the number to convert
Returns:
a String containing the ordinal value of the specified number

ordinal

public java.lang.String ordinal(long n)
A function that converts an integer to an ordinal value. i.e. first, second, third etc.
Parameters:
n - the number to convert
Returns:
a String containing the ordinal value of the specified number

cardinal

public java.lang.String cardinal(java.lang.Long n)
A function that converts an integer to a cardinal value. i.e. one, two, three etc.
Parameters:
n - the number to convert
Returns:
a String containing the cardinal value of the specified number

cardinal

public java.lang.String cardinal(long n)
A function that converts an integer to a cardinal value. i.e. one, two, three etc.
Parameters:
n - the number to convert
Returns:
a String containing the cardinal value of the specified number