org.ofbiz.base.util
Class UtilFormatOut

java.lang.Object
  extended by org.ofbiz.base.util.UtilFormatOut

public class UtilFormatOut
extends java.lang.Object

General output formatting functions - mainly for helping in JSPs


Field Summary
static java.lang.String module
           
 
Constructor Summary
UtilFormatOut()
           
 
Method Summary
static java.lang.String checkEmpty(java.lang.String string1, java.lang.String string2)
          Returns the first passed String if not empty, otherwise the second if not empty, otherwise an empty but non-null String.
static java.lang.String checkEmpty(java.lang.String string1, java.lang.String string2, java.lang.String string3)
          Returns the first passed String if not empty, otherwise the second if not empty, otherwise the third if not empty, otherwise an empty but non-null String.
static java.lang.String checkNull(java.lang.String string1)
          Checks to see if the passed string is null, if it is returns an empty but non-null string.
static java.lang.String checkNull(java.lang.String string1, java.lang.String string2)
          Returns the first passed String if not null, otherwise the second if not null, otherwise an empty but non-null String.
static java.lang.String checkNull(java.lang.String string1, java.lang.String string2, java.lang.String string3)
          Returns the first passed String if not null, otherwise the second if not null, otherwise the third if not null, otherwise an empty but non-null String.
static java.lang.String checkNull(java.lang.String string1, java.lang.String string2, java.lang.String string3, java.lang.String string4)
          Returns the first passed String if not null, otherwise the second if not null, otherwise the third if not null, otherwise the fourth if not null, otherwise an empty but non-null String.
static java.lang.String decodeQueryValue(java.lang.String query)
          Decodes a single query value from an HTTP URL parameter, replacing %ASCII values with characters
static java.lang.String encodeQuery(java.lang.String query)
          Encodes an HTTP URL query String, replacing characters used for other things in HTTP URL query strings, but not touching the separator characters '?', '=', and '&'
static java.lang.String encodeQueryValue(java.lang.String query)
          Encodes a single HTTP URL query value, replacing characters used for other things in HTTP URL query strings
static java.lang.String encodeXmlValue(java.lang.String inString)
          Encodes an XML string replacing the characters '<', '>', '"', ''', '&'
static java.lang.String formatAmount(double amount, java.util.Locale locale)
          Formats a double into a properly formatted string, with two decimals, based on Locale
static java.lang.String formatCurrency(java.math.BigDecimal price, java.lang.String isoCode, java.util.Locale locale)
          Formats a double into a properly formatted currency string based on isoCode and Locale
static java.lang.String formatCurrency(java.math.BigDecimal price, java.lang.String isoCode, java.util.Locale locale, int maximumFractionDigits)
          Formats a BigDecimal into a properly formatted currency string based on isoCode and Locale
static java.lang.String formatCurrency(double price, java.lang.String isoCode, java.util.Locale locale)
          Formats a double into a properly formatted currency string based on isoCode and Locale
static java.lang.String formatCurrency(double price, java.lang.String isoCode, java.util.Locale locale, int maximumFractionDigits)
          Formats a double into a properly formatted currency string based on isoCode and Locale
static java.lang.String formatDate(java.sql.Timestamp timestamp)
          Formats a String timestamp into a nice string
static java.lang.String formatPaddedNumber(long number, int numericPadding)
           
static java.lang.String formatPaddingRemove(java.lang.String original)
           
static java.lang.String formatPercentage(java.math.BigDecimal percentage)
          Formats a BigDecimal representing a percentage into a string
static java.lang.String formatPercentage(double percentage)
          Formats a double representing a percentage into a string
static java.lang.String formatPercentage(java.lang.Double percentage)
          Formats a Double representing a percentage into a string
static java.lang.String formatPrice(java.math.BigDecimal price)
          Formats a BigDecimal representing a price into a string
static java.lang.String formatPrice(double price)
          Formats a double representing a price into a string
static java.lang.String formatPrice(java.lang.Double price)
          Formats a Double representing a price into a string
static java.lang.Double formatPriceNumber(double price)
           
static java.lang.String formatPrintableCreditCard(java.lang.String original)
           
static java.lang.String formatQuantity(java.math.BigDecimal quantity)
          Formats an BigDecimal representing a quantity into a string
static java.lang.String formatQuantity(double quantity)
          Formats an double representing a quantity into a string
static java.lang.String formatQuantity(java.lang.Double quantity)
          Formats an Double representing a quantity into a string
static java.lang.String formatQuantity(float quantity)
          Formats a float representing a quantity into a string
static java.lang.String formatQuantity(java.lang.Float quantity)
          Formats a Float representing a quantity into a string
static java.lang.String formatQuantity(int quantity)
          Formats an int representing a quantity into a string
static java.lang.String formatQuantity(java.lang.Integer quantity)
          Formats an Integer representing a quantity into a string
static java.lang.String formatQuantity(long quantity)
          Formats an int representing a quantity into a string
static java.lang.String formatQuantity(java.lang.Long quantity)
          Formats an Long representing a quantity into a string
static java.lang.String formatSpelledOutAmount(double amount, java.util.Locale locale)
          Formats a double into a properly spelled out number string based on Locale
static java.lang.String formatSpelledOutAmount(java.lang.Double amount, java.util.Locale locale)
          Formats a Double into a properly spelled out number string based on Locale
static java.lang.String ifNotEmpty(java.lang.String base, java.lang.String pre, java.lang.String post)
          Returns pre + base + post if base String is not null or empty, otherwise an empty but non-null String.
static java.lang.String makeSqlSafe(java.lang.String unsafeString)
           
static java.lang.String makeString(java.lang.Object obj1)
          Checks to see if the passed Object is null, if it is returns an empty but non-null string, otherwise calls toString() on the object
static java.lang.String padString(java.lang.String str, int setLen, boolean padEnd, char padChar)
           
static java.lang.String replaceString(java.lang.String mainString, java.lang.String oldString, java.lang.String newString)
          Replaces all occurances of oldString in mainString with newString
static java.lang.String safeToString(java.lang.Object obj)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

module

public static final java.lang.String module
Constructor Detail

UtilFormatOut

public UtilFormatOut()
Method Detail

safeToString

public static java.lang.String safeToString(java.lang.Object obj)

formatPrice

public static java.lang.String formatPrice(java.lang.Double price)
Formats a Double representing a price into a string

Parameters:
price - The price Double to be formatted
Returns:
A String with the formatted price

formatPrice

public static java.lang.String formatPrice(java.math.BigDecimal price)
Formats a BigDecimal representing a price into a string

Parameters:
price - The price BigDecimal to be formatted
Returns:
A String with the formatted price

formatPrice

public static java.lang.String formatPrice(double price)
Formats a double representing a price into a string

Parameters:
price - The price double to be formatted
Returns:
A String with the formatted price

formatPriceNumber

public static java.lang.Double formatPriceNumber(double price)

formatCurrency

public static java.lang.String formatCurrency(double price,
                                              java.lang.String isoCode,
                                              java.util.Locale locale)
Formats a double into a properly formatted currency string based on isoCode and Locale

Parameters:
price - The price double to be formatted
isoCode - the currency ISO code
locale - The Locale used to format the number
Returns:
A String with the formatted price

formatCurrency

public static java.lang.String formatCurrency(double price,
                                              java.lang.String isoCode,
                                              java.util.Locale locale,
                                              int maximumFractionDigits)
Formats a double into a properly formatted currency string based on isoCode and Locale

Parameters:
price - The price double to be formatted
isoCode - the currency ISO code
locale - The Locale used to format the number
maximumFractionDigits - The maximum number of fraction digits used; if set to -1 than the default value for the locale is used
Returns:
A String with the formatted price

formatCurrency

public static java.lang.String formatCurrency(java.math.BigDecimal price,
                                              java.lang.String isoCode,
                                              java.util.Locale locale,
                                              int maximumFractionDigits)
Formats a BigDecimal into a properly formatted currency string based on isoCode and Locale

Parameters:
price - The price double to be formatted
isoCode - the currency ISO code
locale - The Locale used to format the number
maximumFractionDigits - The maximum number of fraction digits used; if set to -1 than the default value for the locale is used
Returns:
A String with the formatted price

formatCurrency

public static java.lang.String formatCurrency(java.math.BigDecimal price,
                                              java.lang.String isoCode,
                                              java.util.Locale locale)
Formats a double into a properly formatted currency string based on isoCode and Locale

Parameters:
price - The price double to be formatted
isoCode - the currency ISO code
locale - The Locale used to format the number
Returns:
A String with the formatted price

formatSpelledOutAmount

public static java.lang.String formatSpelledOutAmount(java.lang.Double amount,
                                                      java.util.Locale locale)
Formats a Double into a properly spelled out number string based on Locale

Parameters:
amount - The amount Double to be formatted
locale - The Locale used to format the number
Returns:
A String with the formatted number

formatSpelledOutAmount

public static java.lang.String formatSpelledOutAmount(double amount,
                                                      java.util.Locale locale)
Formats a double into a properly spelled out number string based on Locale

Parameters:
amount - The amount double to be formatted
locale - The Locale used to format the number
Returns:
A String with the formatted number

formatAmount

public static java.lang.String formatAmount(double amount,
                                            java.util.Locale locale)
Formats a double into a properly formatted string, with two decimals, based on Locale

Parameters:
amount - The amount double to be formatted
locale - The Locale used to format the number
Returns:
A String with the formatted amount

formatPercentage

public static java.lang.String formatPercentage(java.lang.Double percentage)
Formats a Double representing a percentage into a string

Parameters:
percentage - The percentage Double to be formatted
Returns:
A String with the formatted percentage

formatPercentage

public static java.lang.String formatPercentage(java.math.BigDecimal percentage)
Formats a BigDecimal representing a percentage into a string

Parameters:
percentage - The percentage Decimal to be formatted
Returns:
A String with the formatted percentage

formatPercentage

public static java.lang.String formatPercentage(double percentage)
Formats a double representing a percentage into a string

Parameters:
percentage - The percentage double to be formatted
Returns:
A String with the formatted percentage

formatQuantity

public static java.lang.String formatQuantity(java.lang.Long quantity)
Formats an Long representing a quantity into a string

Parameters:
quantity - The quantity Long to be formatted
Returns:
A String with the formatted quantity

formatQuantity

public static java.lang.String formatQuantity(long quantity)
Formats an int representing a quantity into a string

Parameters:
quantity - The quantity long to be formatted
Returns:
A String with the formatted quantity

formatQuantity

public static java.lang.String formatQuantity(java.lang.Integer quantity)
Formats an Integer representing a quantity into a string

Parameters:
quantity - The quantity Integer to be formatted
Returns:
A String with the formatted quantity

formatQuantity

public static java.lang.String formatQuantity(int quantity)
Formats an int representing a quantity into a string

Parameters:
quantity - The quantity int to be formatted
Returns:
A String with the formatted quantity

formatQuantity

public static java.lang.String formatQuantity(java.lang.Float quantity)
Formats a Float representing a quantity into a string

Parameters:
quantity - The quantity Float to be formatted
Returns:
A String with the formatted quantity

formatQuantity

public static java.lang.String formatQuantity(float quantity)
Formats a float representing a quantity into a string

Parameters:
quantity - The quantity float to be formatted
Returns:
A String with the formatted quantity

formatQuantity

public static java.lang.String formatQuantity(java.lang.Double quantity)
Formats an Double representing a quantity into a string

Parameters:
quantity - The quantity Double to be formatted
Returns:
A String with the formatted quantity

formatQuantity

public static java.lang.String formatQuantity(java.math.BigDecimal quantity)
Formats an BigDecimal representing a quantity into a string

Parameters:
quantity - The quantity BigDecimal to be formatted
Returns:
A String with the formatted quantity

formatQuantity

public static java.lang.String formatQuantity(double quantity)
Formats an double representing a quantity into a string

Parameters:
quantity - The quantity double to be formatted
Returns:
A String with the formatted quantity

formatPaddedNumber

public static java.lang.String formatPaddedNumber(long number,
                                                  int numericPadding)

formatPaddingRemove

public static java.lang.String formatPaddingRemove(java.lang.String original)

formatDate

public static java.lang.String formatDate(java.sql.Timestamp timestamp)
Formats a String timestamp into a nice string

Parameters:
timestamp - String timestamp to be formatted
Returns:
A String with the formatted date/time

makeString

public static java.lang.String makeString(java.lang.Object obj1)
Checks to see if the passed Object is null, if it is returns an empty but non-null string, otherwise calls toString() on the object

Parameters:
obj1 - The passed Object
Returns:
The toString() of the passed Object if not null, otherwise an empty non-null String

checkNull

public static java.lang.String checkNull(java.lang.String string1)
Checks to see if the passed string is null, if it is returns an empty but non-null string.

Parameters:
string1 - The passed String
Returns:
The passed String if not null, otherwise an empty non-null String

checkNull

public static java.lang.String checkNull(java.lang.String string1,
                                         java.lang.String string2)
Returns the first passed String if not null, otherwise the second if not null, otherwise an empty but non-null String.

Parameters:
string1 - The first passed String
string2 - The second passed String
Returns:
The first passed String if not null, otherwise the second if not null, otherwise an empty but non-null String

checkNull

public static java.lang.String checkNull(java.lang.String string1,
                                         java.lang.String string2,
                                         java.lang.String string3)
Returns the first passed String if not null, otherwise the second if not null, otherwise the third if not null, otherwise an empty but non-null String.

Parameters:
string1 - The first passed String
string2 - The second passed String
string3 - The third passed String
Returns:
The first passed String if not null, otherwise the second if not null, otherwise the third if not null, otherwise an empty but non-null String

checkNull

public static java.lang.String checkNull(java.lang.String string1,
                                         java.lang.String string2,
                                         java.lang.String string3,
                                         java.lang.String string4)
Returns the first passed String if not null, otherwise the second if not null, otherwise the third if not null, otherwise the fourth if not null, otherwise an empty but non-null String.

Parameters:
string1 - The first passed String
string2 - The second passed String
string3 - The third passed String
string4 - The fourth passed String
Returns:
The first passed String if not null, otherwise the second if not null, otherwise the third if not null, otherwise the fourth if not null, otherwise an empty but non-null String

ifNotEmpty

public static java.lang.String ifNotEmpty(java.lang.String base,
                                          java.lang.String pre,
                                          java.lang.String post)
Returns pre + base + post if base String is not null or empty, otherwise an empty but non-null String.

Parameters:
base - The base String
pre - The pre String
post - The post String
Returns:
pre + base + post if base String is not null or empty, otherwise an empty but non-null String.

checkEmpty

public static java.lang.String checkEmpty(java.lang.String string1,
                                          java.lang.String string2)
Returns the first passed String if not empty, otherwise the second if not empty, otherwise an empty but non-null String.

Parameters:
string1 - The first passed String
string2 - The second passed String
Returns:
The first passed String if not empty, otherwise the second if not empty, otherwise an empty but non-null String

checkEmpty

public static java.lang.String checkEmpty(java.lang.String string1,
                                          java.lang.String string2,
                                          java.lang.String string3)
Returns the first passed String if not empty, otherwise the second if not empty, otherwise the third if not empty, otherwise an empty but non-null String.

Parameters:
string1 - The first passed String
string2 - The second passed String
string3 - The third passed String
Returns:
The first passed String if not empty, otherwise the second if not empty, otherwise the third if not empty, otherwise an empty but non-null String

encodeQuery

public static java.lang.String encodeQuery(java.lang.String query)
Encodes an HTTP URL query String, replacing characters used for other things in HTTP URL query strings, but not touching the separator characters '?', '=', and '&'

Parameters:
query - The plain query String
Returns:
The encoded String

encodeQueryValue

public static java.lang.String encodeQueryValue(java.lang.String query)
Encodes a single HTTP URL query value, replacing characters used for other things in HTTP URL query strings

Parameters:
query - The plain query value String
Returns:
The encoded String

replaceString

public static java.lang.String replaceString(java.lang.String mainString,
                                             java.lang.String oldString,
                                             java.lang.String newString)
Replaces all occurances of oldString in mainString with newString

Parameters:
mainString - The original string
oldString - The string to replace
newString - The string to insert in place of the old
Returns:
mainString with all occurances of oldString replaced by newString

decodeQueryValue

public static java.lang.String decodeQueryValue(java.lang.String query)
Decodes a single query value from an HTTP URL parameter, replacing %ASCII values with characters

Parameters:
query - The encoded query value String
Returns:
The plain, decoded String

encodeXmlValue

public static java.lang.String encodeXmlValue(java.lang.String inString)
Encodes an XML string replacing the characters '<', '>', '"', ''', '&'

Parameters:
inString - The plain value String
Returns:
The encoded String

padString

public static java.lang.String padString(java.lang.String str,
                                         int setLen,
                                         boolean padEnd,
                                         char padChar)

makeSqlSafe

public static java.lang.String makeSqlSafe(java.lang.String unsafeString)

formatPrintableCreditCard

public static java.lang.String formatPrintableCreditCard(java.lang.String original)