|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Context
Interface establishes basic printing and formatting functions for a template runtime context.
Compiler.getRuntimeContext(),
DefaultContext| Method Summary | |
|---|---|
void |
dateFormat(String format)
Defines a format to use when printing dates from templates. |
void |
dateFormat(String format,
String timeZoneID)
A function that sets the formatted value of dates. |
Locale[] |
getAvailableLocales()
Returns a list of all the available locales. |
TimeZone[] |
getAvailableTimeZones()
Returns a list of all the available time zones. |
String |
getDateFormat()
Returns the current date format specification. |
String |
getDateFormatTimeZone()
Returns the current date format time zone. |
Locale |
getLocale()
Returns the current locale setting. |
String |
getNullFormat()
Returns the current null format specification. |
String |
getNumberFormat()
Returns the current number format specification. |
String |
getNumberFormatInfinity()
Returns the current number format for infinity. |
String |
getNumberFormatNaN()
Returns the current number format for NaN. |
void |
nullFormat(String format)
A function that sets the formatted value of null object references. |
void |
numberFormat(String format)
A function that sets the formatted value of numbers. |
void |
numberFormat(String format,
String infinity,
String NaN)
A function that sets the formatted value of numbers. |
void |
print(Date date)
|
void |
print(double n)
|
void |
print(float n)
|
void |
print(int n)
|
void |
print(long n)
|
void |
print(Number n)
|
void |
print(Object obj)
Method that is the runtime receiver. |
void |
print(org.joda.time.ReadableInstant instant)
|
void |
setLocale(Locale locale)
Setting the locale resets date and number formats to the default for that locale. |
void |
setLocale(String language,
String country)
Setting the locale resets date and number formats to the default for that locale. |
void |
setLocale(String language,
String country,
String variant)
Setting the locale resets date and number formats to the default for that locale. |
String |
toString(Date date)
A function that converts a date to a string, using the current datetime format. |
String |
toString(double n)
A function that converts a number to a string, using the current number format. |
String |
toString(float n)
A function that converts a number to a string, using the current number format. |
String |
toString(int n)
A function that converts a number to a string, using the current number format. |
String |
toString(long n)
A function that converts a number to a string, using the current number format. |
String |
toString(Number n)
A function that converts a number to a string, using the current number format. |
String |
toString(Object obj)
A function that converts an object to a string, applying any applicable formatting settings. |
String |
toString(org.joda.time.ReadableInstant instant)
A function that converts an instant in time to a string, using the current datetime format. |
String |
toString(String str)
A function that converts a string to the null format string if it is null. |
| Methods inherited from interface org.teatrove.tea.runtime.OutputReceiver |
|---|
write, write, write, write, write |
| Method Detail |
|---|
void print(Object obj)
throws Exception
NOTE: This method should not be called directly within a template.
print in interface OutputReceiverExceptionCompiler.getRuntimeReceiver()
void print(Date date)
throws Exception
Exception
void print(org.joda.time.ReadableInstant instant)
throws Exception
Exception
void print(Number n)
throws Exception
Exception
void print(int n)
throws Exception
Exception
void print(float n)
throws Exception
Exception
void print(long n)
throws Exception
Exception
void print(double n)
throws Exception
ExceptionString toString(Object obj)
Compiler.getRuntimeStringConverter()String toString(String str)
Compiler.getRuntimeStringConverter()String toString(Date date)
Compiler.getRuntimeStringConverter()String toString(org.joda.time.ReadableInstant instant)
Compiler.getRuntimeStringConverter()String toString(Number n)
Compiler.getRuntimeStringConverter()String toString(int n)
Compiler.getRuntimeStringConverter()String toString(float n)
Compiler.getRuntimeStringConverter()String toString(long n)
Compiler.getRuntimeStringConverter()String toString(double n)
Compiler.getRuntimeStringConverter()void setLocale(Locale locale)
See getAvailableLocales to get all the available language, country and variant codes.
locale - pre-constructed locale object
void setLocale(String language,
String country)
language - language codecountry - country code
void setLocale(String language,
String country,
String variant)
language - language codecountry - country codevariant - optional variant codeLocale getLocale()
Locale[] getAvailableLocales()
void nullFormat(String format)
format - string to print in place of "null".String getNullFormat()
void dateFormat(String format)
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:
The count of pattern letters determine the format.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) '
(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
format - date format specification string
void dateFormat(String format,
String timeZoneID)
format - date format specification stringtimeZoneID - time zone ID, i.e. "PST"String getDateFormat()
String getDateFormatTimeZone()
TimeZone[] getAvailableTimeZones()
void numberFormat(String format)
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.
format - number format specification string
void numberFormat(String format,
String infinity,
String NaN)
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.
format - number format specification stringinfinity - display string for infinityNaN - display string for not-a-number, resulting from zero divided
by zero.String getNumberFormat()
String getNumberFormatInfinity()
String getNumberFormatNaN()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||