com.go.tea.runtime
Class DefaultContext

java.lang.Object
  |
  +--com.go.tea.runtime.DefaultContext
All Implemented Interfaces:
Context, OutputReceiver, UtilityContext
Direct Known Subclasses:
BeanDocContext, TeaToolsUtils, TestCompiler.Context

public abstract class DefaultContext
extends java.lang.Object
implements UtilityContext

The default runtime context class that Tea templates get compiled to use. All functions callable from a template are defined in the context. To add more or override existing ones, do so when extending this class.

Version:
30 , 01/07/03
Author:
Brian S O'Neill

Constructor Summary
DefaultContext()
           
 
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.
 void dateFormat(java.lang.String format)
          Defines a format to use when printing dates from templates.
 void dateFormat(java.lang.String format, java.lang.String timeZoneID)
          A function that sets the formatted value of dates.
 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.util.Locale[] getAvailableLocales()
          Returns a list of all the available locales.
 java.util.TimeZone[] getAvailableTimeZones()
          Returns a list of all the available time zones.
 java.lang.String getDateFormat()
          Returns the current date format specification.
 java.lang.String getDateFormatTimeZone()
          Returns the current date format time zone.
 java.util.Locale getLocale()
          Returns the current locale setting.
 java.lang.String getNullFormat()
          Returns the current null format specification.
 java.lang.String getNumberFormat()
          Returns the current number format specification.
 java.lang.String getNumberFormatInfinity()
          Returns the current number format for infinity.
 java.lang.String getNumberFormatNaN()
          Returns the current number format for NaN.
 void nullFormat(java.lang.String format)
          A function that sets the formatted value of null object references.
 void numberFormat(java.lang.String format)
          A function that sets the formatted value of numbers.
 void numberFormat(java.lang.String format, java.lang.String infinity, java.lang.String NaN)
          A function that sets the formatted value of numbers.
 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.
 void print(java.util.Date date)
           
 void print(double n)
           
 void print(float n)
           
 void print(int n)
           
 void print(long n)
           
 void print(java.lang.Number n)
           
abstract  void print(java.lang.Object obj)
          Method that is the runtime receiver.
 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.
 void setLocale(java.util.Locale locale)
          Setting the locale resets date and number formats to the default for that locale.
 void setLocale(java.lang.String language, java.lang.String country)
          Setting the locale resets date and number formats to the default for that locale.
 void setLocale(java.lang.String language, java.lang.String country, java.lang.String variant)
          Setting the locale resets date and number formats to the default for that locale.
 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 toString(java.util.Date date)
          A function that converts a date to a string, using the current date format.
 java.lang.String toString(double n)
          A function that converts a number to a string, using the current number format.
 java.lang.String toString(float n)
          A function that converts a number to a string, using the current number format.
 java.lang.String toString(int n)
          A function that converts a number to a string, using the current number format.
 java.lang.String toString(long n)
          A function that converts a number to a string, using the current number format.
 java.lang.String toString(java.lang.Number n)
          A function that converts a number to a string, using the current number format.
 java.lang.String toString(java.lang.Object obj)
          A function that converts an object to a string, applying any applicable formatting settings.
 java.lang.String toString(java.lang.String str)
          A function that converts a string to the null format string if it is null.
 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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultContext

public DefaultContext()
Method Detail

print

public abstract void print(java.lang.Object obj)
                    throws java.lang.Exception
Method that is the runtime receiver. Implementations should call one of the toString methods when converting this object to a string.

NOTE: This method should not be called directly within a template.

Specified by:
print in interface Context
See Also:
Compiler.getRuntimeReceiver()

print

public void print(java.util.Date date)
           throws java.lang.Exception
Specified by:
print in interface Context

print

public void print(java.lang.Number n)
           throws java.lang.Exception
Specified by:
print in interface Context

print

public void print(int n)
           throws java.lang.Exception
Specified by:
print in interface Context

print

public void print(float n)
           throws java.lang.Exception
Specified by:
print in interface Context

print

public void print(long n)
           throws java.lang.Exception
Specified by:
print in interface Context

print

public void print(double n)
           throws java.lang.Exception
Specified by:
print in interface Context

toString

public java.lang.String toString(java.lang.Object obj)
Description copied from interface: Context
A function that converts an object to a string, applying any applicable formatting settings. The returned String is never null.
Specified by:
toString in interface Context
Following copied from interface: com.go.tea.runtime.Context
See Also:
Compiler.getRuntimeStringConverter()

toString

public java.lang.String toString(java.lang.String str)
Description copied from interface: Context
A function that converts a string to the null format string if it is null. Otherwise, it is returned unchanged.
Specified by:
toString in interface Context
Following copied from interface: com.go.tea.runtime.Context
See Also:
Compiler.getRuntimeStringConverter()

toString

public java.lang.String toString(java.util.Date date)
Description copied from interface: Context
A function that converts a date to a string, using the current date format.
Specified by:
toString in interface Context
Following copied from interface: com.go.tea.runtime.Context
See Also:
Compiler.getRuntimeStringConverter()

toString

public java.lang.String toString(java.lang.Number n)
Description copied from interface: Context
A function that converts a number to a string, using the current number format.
Specified by:
toString in interface Context
Following copied from interface: com.go.tea.runtime.Context
See Also:
Compiler.getRuntimeStringConverter()

toString

public java.lang.String toString(int n)
Description copied from interface: Context
A function that converts a number to a string, using the current number format.
Specified by:
toString in interface Context
Following copied from interface: com.go.tea.runtime.Context
See Also:
Compiler.getRuntimeStringConverter()

toString

public java.lang.String toString(float n)
Description copied from interface: Context
A function that converts a number to a string, using the current number format.
Specified by:
toString in interface Context
Following copied from interface: com.go.tea.runtime.Context
See Also:
Compiler.getRuntimeStringConverter()

toString

public java.lang.String toString(long n)
Description copied from interface: Context
A function that converts a number to a string, using the current number format.
Specified by:
toString in interface Context
Following copied from interface: com.go.tea.runtime.Context
See Also:
Compiler.getRuntimeStringConverter()

toString

public java.lang.String toString(double n)
Description copied from interface: Context
A function that converts a number to a string, using the current number format.
Specified by:
toString in interface Context
Following copied from interface: com.go.tea.runtime.Context
See Also:
Compiler.getRuntimeStringConverter()

setLocale

public void setLocale(java.util.Locale locale)
Description copied from interface: Context
Setting the locale resets date and number formats to the default for that locale. Setting a locale of null resets date and number formats to the system defaults.

See getAvailableLocales to get all the available language, country and variant codes.

Specified by:
setLocale in interface Context
Following copied from interface: com.go.tea.runtime.Context
Parameters:
locale - pre-constructed locale object

setLocale

public void setLocale(java.lang.String language,
                      java.lang.String country)
Description copied from interface: Context
Setting the locale resets date and number formats to the default for that locale.
Specified by:
setLocale in interface Context
Following copied from interface: com.go.tea.runtime.Context
Parameters:
language - language code
country - country code

setLocale

public void setLocale(java.lang.String language,
                      java.lang.String country,
                      java.lang.String variant)
Description copied from interface: Context
Setting the locale resets date and number formats to the default for that locale.
Specified by:
setLocale in interface Context
Following copied from interface: com.go.tea.runtime.Context
Parameters:
language - language code
country - country code
variant - optional variant code

getLocale

public java.util.Locale getLocale()
Description copied from interface: Context
Returns the current locale setting.
Specified by:
getLocale in interface Context

getAvailableLocales

public java.util.Locale[] getAvailableLocales()
Description copied from interface: Context
Returns a list of all the available locales.
Specified by:
getAvailableLocales in interface Context

nullFormat

public void nullFormat(java.lang.String format)
Description copied from interface: Context
A function that sets the formatted value of null object references.
Specified by:
nullFormat in interface Context
Following copied from interface: com.go.tea.runtime.Context
Parameters:
format - string to print in place of "null".

getNullFormat

public java.lang.String getNullFormat()
Description copied from interface: Context
Returns the current null format specification.
Specified by:
getNullFormat in interface Context

dateFormat

public void dateFormat(java.lang.String format)
Description copied from interface: Context
Defines a format to use when printing dates from templates. Passing null sets the format back to the default.

Time Format Syntax:

To specify the time format use a time pattern string. In this pattern, all ASCII letters are reserved as pattern letters, which are defined as the following:

 
 Symbol   Meaning                 Presentation        Example 
 ------   -------                 ------------        ------- 
 G        era designator          (Text)              AD 
 y        year                    (Number)            1996 
 M        month in year           (Text & Number)     July & 07 
 d        day in month            (Number)            10 
 h        hour in am/pm (1~12)    (Number)            12 
 H        hour in day (0~23)      (Number)            0 
 m        minute in hour          (Number)            30 
 s        second in minute        (Number)            55 
 S        millisecond             (Number)            978 
 E        day in week             (Text)              Tuesday 
 D        day in year             (Number)            189 
 F        day of week in month    (Number)            2 (2nd Wed in July)
 w        week in year            (Number)            27 
 W        week in month           (Number)            2 
 a        am/pm marker            (Text)              PM 
 k        hour in day (1~24)      (Number)            24 
 K        hour in am/pm (0~11)    (Number)            0 
 z        time zone               (Text)              Pacific Standard Time 
 '        escape for text         (Delimiter) 
 ''       single quote            (Literal)           ' 
 
The count of pattern letters determine the format.

(Text): 4 or more pattern letters--use full form, less than 4--use short or abbreviated form if one exists.

(Number): the minimum number of digits. Shorter numbers are zero-padded to this amount. Year is handled specially; that is, if the count of 'y' is 2, the Year will be truncated to 2 digits.

(Text & Number): 3 or over, use text, otherwise use number.

Any characters in the pattern that are not in the ranges of ['a'..'z'] and ['A'..'Z'] will be treated as quoted text. For instance, characters like ':', '.', ' ', '#' and '@' will appear in the resulting time text even they are not embraced within single quotes.

A pattern containing any invalid pattern letter will result in a thrown exception during formatting or parsing.

Examples:

 
 Format Pattern                         Result 
 --------------                         ------- 
 "yyyy.MM.dd G 'at' hh:mm:ss z"    ->>  1996.07.10 AD at 15:08:56 PDT 
 "EEE, MMM d, ''yy"                ->>  Wed, July 10, '96 
 "h:mm a"                          ->>  12:08 PM 
 "hh 'o''clock' a, zzzz"           ->>  12 o'clock PM, Pacific Daylight Time 
 "K:mm a, z"                       ->>  0:00 PM, PST 
 "yyyyy.MMMMM.dd GGG hh:mm aaa"    ->>  1996.July.10 AD 12:08 PM 
 
Specified by:
dateFormat in interface Context
Following copied from interface: com.go.tea.runtime.Context
Parameters:
format - date format specification string

dateFormat

public void dateFormat(java.lang.String format,
                       java.lang.String timeZoneID)
Description copied from interface: Context
A function that sets the formatted value of dates.
Specified by:
dateFormat in interface Context
Following copied from interface: com.go.tea.runtime.Context
Parameters:
format - date format specification string
timeZoneID - time zone ID, i.e. "PST"

getDateFormat

public java.lang.String getDateFormat()
Description copied from interface: Context
Returns the current date format specification.
Specified by:
getDateFormat in interface Context

getDateFormatTimeZone

public java.lang.String getDateFormatTimeZone()
Description copied from interface: Context
Returns the current date format time zone.
Specified by:
getDateFormatTimeZone in interface Context

getAvailableTimeZones

public java.util.TimeZone[] getAvailableTimeZones()
Description copied from interface: Context
Returns a list of all the available time zones.
Specified by:
getAvailableTimeZones in interface Context

numberFormat

public void numberFormat(java.lang.String format)
Description copied from interface: Context
A function that sets the formatted value of numbers. Defines a format to use when printing numbers from templates. Passing null sets the format back to the default. The format string is of the form "#.#".

Here are the special characters used in the parts of the format string, with notes on their usage.

 
 Symbol   Meaning 
 ------   ------- 
 0        a digit 
 #        a digit, zero shows as absent 
 .        placeholder for decimal separator. 
 ,        placeholder for grouping separator. 
 ;        separates formats. 
 -        default negative prefix. 
 %        multiply by 100 and show as percentage 
 ?        multiply by 1000 and show as per mille 
         currency sign; replaced by currency symbol;
          if doubled, replaced by international currency 
          symbol. If present in a pattern, the monetary
          decimal separator is used instead of the decimal 
          separator. (Unicode escape is \\u00a4) 
 X        any other characters can be used in the prefix or suffix 
 '        used to quote special characters in a prefix or suffix. 
 
Specified by:
numberFormat in interface Context
Following copied from interface: com.go.tea.runtime.Context
Parameters:
format - number format specification string

numberFormat

public void numberFormat(java.lang.String format,
                         java.lang.String infinity,
                         java.lang.String NaN)
Description copied from interface: Context
A function that sets the formatted value of numbers. Defines a format to use when printing numbers from templates. Passing null sets the format back to the default. The format string is of the form "#.#".

Here are the special characters used in the parts of the format string, with notes on their usage.

 
 Symbol   Meaning 
 ------   ------- 
 0        a digit 
 #        a digit, zero shows as absent 
 .        placeholder for decimal separator. 
 ,        placeholder for grouping separator. 
 ;        separates formats. 
 -        default negative prefix. 
 %        multiply by 100 and show as percentage 
 ?        multiply by 1000 and show as per mille 
         currency sign; replaced by currency symbol;
          if doubled, replaced by international currency 
          symbol. If present in a pattern, the monetary
          decimal separator is used instead of the decimal 
          separator. (Unicode escape is \\u00a4) 
 X        any other characters can be used in the prefix or suffix 
 '        used to quote special characters in a prefix or suffix. 
 
Specified by:
numberFormat in interface Context
Following copied from interface: com.go.tea.runtime.Context
Parameters:
format - number format specification string
infinity - display string for infinity
NaN - display string for not-a-number, resulting from zero divided by zero.

getNumberFormat

public java.lang.String getNumberFormat()
Description copied from interface: Context
Returns the current number format specification.
Specified by:
getNumberFormat in interface Context

getNumberFormatInfinity

public java.lang.String getNumberFormatInfinity()
Description copied from interface: Context
Returns the current number format for infinity.
Specified by:
getNumberFormatInfinity in interface Context

getNumberFormatNaN

public java.lang.String getNumberFormatNaN()
Description copied from interface: Context
Returns the current number format for NaN.
Specified by:
getNumberFormatNaN in interface Context

currentDate

public java.util.Date currentDate()
Description copied from interface: UtilityContext
Returns a Date object with the current date and time.
Specified by:
currentDate in interface UtilityContext

startsWith

public boolean startsWith(java.lang.String str,
                          java.lang.String prefix)
Description copied from interface: UtilityContext
Tests if the given string starts with the given prefix. Returns true if the given string starts with the given prefix.
Specified by:
startsWith in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
Tests if the given string ends with the given suffix. Returns true if the given string ends with the given suffix.
Specified by:
endsWith in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
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
Specified by:
find in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
Finds the indices for each occurrence of the given search string in the source string, starting from the given index.
Specified by:
find in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
Finds the index of the first occurrence of the given search string in the source string, or -1 if not found.
Specified by:
findFirst in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
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.
Specified by:
findFirst in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
Finds the index of the last occurrence of the given search string in the source string, or -1 if not found.
Specified by:
findLast in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
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.
Specified by:
findLast in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
Returns the trailing end of the given string, starting from the given index.
Specified by:
substring in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
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.
Specified by:
substring in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
Converts all the characters in the given string to lowercase.
Specified by:
toLowerCase in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
Parameters:
str - the string to convert
Returns:
the string converted to lowercase

toUpperCase

public java.lang.String toUpperCase(java.lang.String str)
Description copied from interface: UtilityContext
Converts all the characters in the given string to uppercase.
Specified by:
toUpperCase in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
Parameters:
str - the string to convert
Returns:
the string converted to uppercase

trim

public java.lang.String trim(java.lang.String str)
Description copied from interface: UtilityContext
Trims all leading and trailing whitespace characters from the given string.
Specified by:
trim in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
Parameters:
str - the string to trim
Returns:
the trimmed string

trimLeading

public java.lang.String trimLeading(java.lang.String str)
Description copied from interface: UtilityContext
Trims all leading whitespace characters from the given string.
Specified by:
trimLeading in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
Parameters:
str - the string to trim
Returns:
the trimmed string

trimTrailing

public java.lang.String trimTrailing(java.lang.String str)
Description copied from interface: UtilityContext
Trims all trailing whitespace characters from the given string.
Specified by:
trimTrailing in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
Replaces all exact matches of the given pattern in the source string with the provided replacement.
Specified by:
replace in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
Replaces all exact matches of the given pattern in the source string with the provided replacement, starting from the given index.
Specified by:
replace in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
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.
Specified by:
replace in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
Replaces the first exact match of the given pattern in the source string with the provided replacement.
Specified by:
replaceFirst in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
Replaces the first exact match of the given pattern in the source string with the provided replacement, starting from the given index.
Specified by:
replaceFirst in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
Replaces the last exact match of the given pattern in the source string with the provided replacement.
Specified by:
replaceLast in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
Replaces the last exact match of the given pattern in the source string with the provided replacement, starting from the given index.
Specified by:
replaceLast in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
A function that converts an integer to a short ordinal value. i.e. 1st, 2nd, 3rd etc.
Specified by:
shortOrdinal in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
A function that converts an integer to a short ordinal value. i.e. 1st, 2nd, 3rd etc.
Specified by:
shortOrdinal in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
A function that converts an integer to an ordinal value. i.e. first, second, third etc.
Specified by:
ordinal in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
A function that converts an integer to an ordinal value. i.e. first, second, third etc.
Specified by:
ordinal in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
A function that converts an integer to a cardinal value. i.e. one, two, three etc.
Specified by:
cardinal in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
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)
Description copied from interface: UtilityContext
A function that converts an integer to a cardinal value. i.e. one, two, three etc.
Specified by:
cardinal in interface UtilityContext
Following copied from interface: com.go.tea.runtime.UtilityContext
Parameters:
n - the number to convert
Returns:
a String containing the cardinal value of the specified number