com.scooterframework.web.util
Class T

java.lang.Object
  extended by com.scooterframework.web.util.T

public class T
extends java.lang.Object

T(TextHelper) class has helper methods for rendering a text or munipulating a string.
This class is for generic objects. It does not render an ActiveRecord object. Use O(ObjectHelper) for that purpose.


Field Summary
static int CURRENCY
          int constant represents currency data type.
static int DATE
          int constant represents date data type.
static int NUMBER
          int constant represents numberic data type.
static int UNKNOWN
          int constant represents unknown data type.
 
Constructor Summary
T()
           
 
Method Summary
static java.lang.String booleanWord(boolean choice, java.lang.String wordTrue, java.lang.String wordFalse)
          Returns a string based on true or false of choice.
static java.util.Map<java.lang.String,java.lang.String> getDateAsMap()
          Returns a map of current date and time.
static java.lang.String getDateProperty(java.lang.String key)
          Returns a property from a map of current date and time.
static boolean isNumeric(java.lang.Object data)
          Checks if a data object is a numberic data.
static java.lang.String numberFormat(java.lang.Object data, int precision)
          Returns a text of number with a certain precision.
static java.lang.String pluralize(int count, java.lang.String word)
          Returns a pluralized word if the count is more than one.
static java.lang.String pluralize(int count, java.lang.String word, java.lang.String plform)
          Returns a pluralized word if the count is more than one.
static java.lang.String pluralize(java.lang.Object count, java.lang.String word)
          Returns a pluralized word if the count is more than one.
static java.lang.String pluralize(java.lang.Object count, java.lang.String word, java.lang.String plform)
          Returns a pluralized word if the count is more than one.
static java.lang.String text(java.lang.Object data)
          Returns text of an object with default locale.
static java.lang.String text(java.lang.Object data, int type)
          Returns text of an object of a type.
static java.lang.String text(java.lang.Object data, int type, java.lang.String pattern)
          Returns text of an object of a type in a certain pattern with default locale.
static java.lang.String text(java.lang.Object data, int type, java.lang.String pattern, java.util.Locale locale)
          Returns text of an object of a type in a certain pattern and locale.
static java.lang.String text(java.lang.Object data, java.lang.String pattern)
          Returns text of an object in a certain pattern with default locale.
static java.lang.String text(java.lang.Object data, java.lang.String pattern, java.util.Locale locale)
          Returns text of an object in a certain pattern and locale.
static java.lang.String textOfCurrency(double number)
          Returns a text of currency.
static java.lang.String textOfCurrency(double number, java.util.Locale locale)
          Returns a text of currency.
static java.lang.String textOfCurrency(float number)
          Returns a text of currency.
static java.lang.String textOfCurrency(float number, java.util.Locale locale)
          Returns a text of currency.
static java.lang.String textOfCurrency(int number)
          Returns a text of currency.
static java.lang.String textOfCurrency(int number, java.util.Locale locale)
          Returns a text of currency.
static java.lang.String textOfCurrency(long number)
          Returns a text of currency.
static java.lang.String textOfCurrency(long number, java.util.Locale locale)
          Returns a text of currency.
static java.lang.String textOfCurrency(java.lang.Object number)
          Returns a text of currency.
static java.lang.String textOfCurrency(java.lang.Object number, java.util.Locale locale)
          Returns a text of currency.
static java.lang.String textOfCurrency(java.lang.String number, java.util.Locale locale)
          Returns a text of currency.
static java.lang.String textOfDate(java.lang.Object date)
          Returns text of a date object.
static java.lang.String textOfDate(java.lang.Object date, java.lang.String pattern)
          Returns text of a date object for a certain pattern.
static java.lang.String textOfDate(java.lang.Object date, java.lang.String pattern, java.util.Locale locale)
          Returns text of a date object for a certain pattern and locale.
static java.lang.String textOfNumber(java.lang.Object number)
          Returns a text of number.
static java.lang.String textOfNumber(java.lang.Object number, int precision)
          Returns a text of number with a certain precision.
static java.lang.String textOfNumber(java.lang.Object number, java.lang.String pattern)
          Returns a text of number.
static java.lang.String textOfNumber(java.lang.Object number, java.lang.String pattern, java.util.Locale locale)
          Returns a text of number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN

public static final int UNKNOWN
int constant represents unknown data type.

See Also:
Constant Field Values

CURRENCY

public static final int CURRENCY
int constant represents currency data type.

See Also:
Constant Field Values

DATE

public static final int DATE
int constant represents date data type.

See Also:
Constant Field Values

NUMBER

public static final int NUMBER
int constant represents numberic data type.

See Also:
Constant Field Values
Constructor Detail

T

public T()
Method Detail

booleanWord

public static java.lang.String booleanWord(boolean choice,
                                           java.lang.String wordTrue,
                                           java.lang.String wordFalse)
Returns a string based on true or false of choice.

Returns:
wordTrue if choice is true.

pluralize

public static java.lang.String pluralize(int count,
                                         java.lang.String word)
Returns a pluralized word if the count is more than one.

Returns:
pluralized string

pluralize

public static java.lang.String pluralize(int count,
                                         java.lang.String word,
                                         java.lang.String plform)
Returns a pluralized word if the count is more than one.

Returns:
pluralized string

pluralize

public static java.lang.String pluralize(java.lang.Object count,
                                         java.lang.String word)
Returns a pluralized word if the count is more than one.

Returns:
pluralized string

pluralize

public static java.lang.String pluralize(java.lang.Object count,
                                         java.lang.String word,
                                         java.lang.String plform)
Returns a pluralized word if the count is more than one.

Returns:
pluralized string

text

public static java.lang.String text(java.lang.Object data)
Returns text of an object with default locale.

Parameters:
data - the object
Returns:
text of data

text

public static java.lang.String text(java.lang.Object data,
                                    java.lang.String pattern)
Returns text of an object in a certain pattern with default locale.

Parameters:
data - the object
pattern - the pattern of result text
Returns:
text of data

text

public static java.lang.String text(java.lang.Object data,
                                    java.lang.String pattern,
                                    java.util.Locale locale)
Returns text of an object in a certain pattern and locale.

Parameters:
data - the object
pattern - the pattern of result text
locale - the locale of result text
Returns:
text of data

text

public static java.lang.String text(java.lang.Object data,
                                    int type)
Returns text of an object of a type.

Parameters:
data - the object
type - data type (1=Currency, 2=Date, 3=Number)
Returns:
text of data

text

public static java.lang.String text(java.lang.Object data,
                                    int type,
                                    java.lang.String pattern)
Returns text of an object of a type in a certain pattern with default locale.

Parameters:
data - the object
type - data type (1=Currency, 2=Date, 3=Number)
pattern - the pattern of result text
Returns:
text of data

text

public static java.lang.String text(java.lang.Object data,
                                    int type,
                                    java.lang.String pattern,
                                    java.util.Locale locale)
Returns text of an object of a type in a certain pattern and locale.

Parameters:
data - the object
type - data type (1=Currency, 2=Date, 3=Number)
pattern - the pattern of result text
locale - the locale of result text
Returns:
text of data

isNumeric

public static boolean isNumeric(java.lang.Object data)
Checks if a data object is a numberic data. A string value can be numeric too if it can be converted to a number.

Parameters:
data -
Returns:
true if the data represents a number.

numberFormat

public static java.lang.String numberFormat(java.lang.Object data,
                                            int precision)
Returns a text of number with a certain precision. First group the number into thousands and round it to the number of decimal places specified by precision. This method is exactly the same as textOfNumber(Object number, int precision).

Parameters:
data - the object
precision - number of decimal needed
Returns:
a number text

textOfNumber

public static java.lang.String textOfNumber(java.lang.Object number,
                                            int precision)
Returns a text of number with a certain precision. First group the number into thousands and round it to the number of decimal places specified by precision.

Parameters:
number - the object
precision - number of decimal needed
Returns:
a number text

textOfNumber

public static java.lang.String textOfNumber(java.lang.Object number)
Returns a text of number.

Parameters:
number - the object
Returns:
a number text

textOfNumber

public static java.lang.String textOfNumber(java.lang.Object number,
                                            java.lang.String pattern)
Returns a text of number.

Parameters:
number - the object
pattern - the pattern format of the result
Returns:
a number text

textOfNumber

public static java.lang.String textOfNumber(java.lang.Object number,
                                            java.lang.String pattern,
                                            java.util.Locale locale)
Returns a text of number.

Parameters:
number - the object
pattern - the pattern format of the result
locale - the locale of the result
Returns:
a number text

textOfCurrency

public static java.lang.String textOfCurrency(java.lang.Object number)
Returns a text of currency.

Parameters:
number - the number
Returns:
a currency text

textOfCurrency

public static java.lang.String textOfCurrency(java.lang.Object number,
                                              java.util.Locale locale)
Returns a text of currency.

Parameters:
number - the number
locale - the locale of the result
Returns:
a currency text

textOfCurrency

public static java.lang.String textOfCurrency(java.lang.String number,
                                              java.util.Locale locale)
Returns a text of currency.

Parameters:
number - the number
locale - the locale of the result
Returns:
a currency text

textOfCurrency

public static java.lang.String textOfCurrency(float number)
Returns a text of currency.

Parameters:
number - the number
Returns:
a currency text

textOfCurrency

public static java.lang.String textOfCurrency(float number,
                                              java.util.Locale locale)
Returns a text of currency.

Parameters:
number - the number
locale - the locale of the result
Returns:
a currency text

textOfCurrency

public static java.lang.String textOfCurrency(double number)
Returns a text of currency.

Parameters:
number - the number
Returns:
a currency text

textOfCurrency

public static java.lang.String textOfCurrency(double number,
                                              java.util.Locale locale)
Returns a text of currency.

Parameters:
number - the number
locale - the locale of the result
Returns:
a currency text

textOfCurrency

public static java.lang.String textOfCurrency(int number)
Returns a text of currency.

Parameters:
number - the number
Returns:
a currency text

textOfCurrency

public static java.lang.String textOfCurrency(int number,
                                              java.util.Locale locale)
Returns a text of currency.

Parameters:
number - the number
locale - the locale of the result
Returns:
a currency text

textOfCurrency

public static java.lang.String textOfCurrency(long number)
Returns a text of currency.

Parameters:
number - the number
Returns:
a currency text

textOfCurrency

public static java.lang.String textOfCurrency(long number,
                                              java.util.Locale locale)
Returns a text of currency.

Parameters:
number - the number
locale - the locale of the result
Returns:
a currency text

getDateAsMap

public static java.util.Map<java.lang.String,java.lang.String> getDateAsMap()
Returns a map of current date and time. Keys in the map are year, mon, month, mday, weekday, hours, minutes, seconds, mills and timeinmillis.
 Example:
 Key          Value
 -----        -------
 year         2007
 mon          7
 month        July
 mday         18
 weekday      Wednesday
 hours        0
 minutes      39
 seconds      24
 mills        354
 timeinmillis 1184776764354
 

Returns:
Map

getDateProperty

public static java.lang.String getDateProperty(java.lang.String key)
Returns a property from a map of current date and time. Keys in the map are year, mon, month, mday, weekday, hours, minutes, seconds, mills. Example: Key Value ----- ------- year 2007 mon 7 month July mday 18 weekday Wednesday hours 0 minutes 39 seconds 24 mills 354 timeinmillis 1184776764354

Returns:
Map

textOfDate

public static java.lang.String textOfDate(java.lang.Object date)
Returns text of a date object.

Parameters:
date - the object
Returns:
text of date

textOfDate

public static java.lang.String textOfDate(java.lang.Object date,
                                          java.lang.String pattern)

Returns text of a date object for a certain pattern.

If the result of this method is used in an html form and will be parsed automatically by Scooter, not all patterns are allowed. The allowed patterns are listed in the description of DateUtil.getDateTimePattern(String) method. Other kind of patterns may result in null value.

Parameters:
date - the object
pattern - the pattern of result text
Returns:
text of date

textOfDate

public static java.lang.String textOfDate(java.lang.Object date,
                                          java.lang.String pattern,
                                          java.util.Locale locale)

Returns text of a date object for a certain pattern and locale.

If the result of this method is used in an html form and will be parsed automatically by Scooter, not all patterns are allowed. The allowed patterns are listed in the description of DateUtil.getDateTimePattern(String) method. Other kind of patterns may result in null value.

If the gived pattern is empty and the date object is of Date type, then a default pattern "yyyy-MM-dd HH:mm:ss" is used.

Parameters:
date - the object
pattern - the pattern of result text
locale - the locale of result text
Returns:
text of date