Class UtilFormatOut

java.lang.Object
org.ofbiz.core.util.UtilFormatOut

public class UtilFormatOut extends Object
General output formatting functions - mainly for helping in JSPs
Since:
2.0
Version:
$Revision: 1.1 $
Author:
David E. Jones, Andy Zeneski
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    checkEmpty(String string1, String string2)
    Returns the first passed String if not empty, otherwise the second if not empty, otherwise an empty but non-null String.
    static String
    checkEmpty(String string1, String string2, 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 String
    checkNull(String string1)
    Checks to see if the passed string is null, if it is returns an empty but non-null string.
    static String
    checkNull(String string1, String string2)
    Returns the first passed String if not null, otherwise the second if not null, otherwise an empty but non-null String.
    static String
    checkNull(String string1, String string2, 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 String
    checkNull(String string1, String string2, String string3, 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 String
    Decodes a single query value from an HTTP URL parameter, replacing %ASCII values with characters
    static String
    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 String
    Encodes a single HTTP URL query value, replacing characters used for other things in HTTP URL query strings
    static String
    Encodes an XML string replacing the characters '<', '>', '"', ''', '&'
    static String
    formatDate(Timestamp timestamp)
    Formats a String timestamp into a nice string
    static String
    formatPercentage(double percentage)
    Formats a double representing a percentage into a string
    static String
    Formats a Double representing a percentage into a string
    static String
    formatPrice(double price)
    Formats a double representing a price into a string
    static String
    Formats a Double representing a price into a string
    static String
    formatQuantity(double quantity)
    Formats an double representing a quantity into a string
    static String
    formatQuantity(float quantity)
    Formats a float representing a quantity into a string
    static String
    formatQuantity(int quantity)
    Formats an int representing a quantity into a string
    static String
    formatQuantity(long quantity)
    Formats an int representing a quantity into a string
    static String
    Formats an Double representing a quantity into a string
    static String
    Formats a Float representing a quantity into a string
    static String
    Formats an Integer representing a quantity into a string
    static String
    formatQuantity(Long quantity)
    Formats an Long representing a quantity into a string
    static String
    ifNotEmpty(String base, String pre, String post)
    Returns pre + base + post if base String is not null or empty, otherwise an empty but non-null String.
    static String
    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 String
    replaceString(String mainString, String oldString, String newString)
    Replaces all occurances of oldString in mainString with newString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • UtilFormatOut

      public UtilFormatOut()
  • Method Details

    • formatPrice

      public static 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
    • formatPrice

      public static 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
    • formatPercentage

      public static 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
    • formatPercentage

      public static 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 String formatQuantity(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 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 String formatQuantity(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 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 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 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 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
    • formatQuantity

      public static 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
    • formatDate

      public static String formatDate(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 String makeString(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 String checkNull(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 String checkNull(String string1, 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 String checkNull(String string1, String string2, 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 String checkNull(String string1, String string2, String string3, 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 String ifNotEmpty(String base, String pre, 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 String checkEmpty(String string1, 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 String checkEmpty(String string1, String string2, 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 String encodeQuery(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 String encodeQueryValue(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 String replaceString(String mainString, String oldString, 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 String decodeQueryValue(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 String encodeXmlValue(String inString)
      Encodes an XML string replacing the characters '<', '>', '"', ''', '&'
      Parameters:
      inString - The plain value String
      Returns:
      The encoded String