Documentation of 'com.jstatcom.util.UString' Java class
UString
com.jstatcom.util

Class UString



  • public final class UString
    extends java.lang.Object
    A collection of static methods that are related to strings and formatting.
    • Constructor Summary

      Constructors 
      Constructor and Description
      UString() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static java.lang.String capitalizeFirst(java.lang.String s)
      Resturns string with first characted capitalized, rest lowercase.
      static java.lang.String formatNumber(double number, java.text.NumberFormat format, int precision)
      Formats number with format if format != null.
      static java.lang.Double parseToNumber(java.lang.String text)
      Parses a given string to a Double if possible and returns it.
      static java.lang.String replaceAllSubStrings(java.lang.String origString, java.lang.String substring, java.lang.String replacementString)
      This method replaces all occurences of a substring in an original string with a replacement string.
      static java.lang.String replaceSubString(java.lang.String origString, java.lang.String substring, java.lang.String replacementString)
      This method replaces the first occurence of a substring in an original string with a replacement string.
      static java.lang.String replaceSubString(java.lang.String origString, java.lang.String substring, java.lang.String replacementString, int pos)
      This method replaces the first occurence of a substring in an original string with a replacement string, starting from a given position.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UString

        public UString()
    • Method Detail

      • formatNumber

        public static java.lang.String formatNumber(double number,
                                                    java.text.NumberFormat format,
                                                    int precision)
        Formats number with format if format != null. Otherwise return number as a string. The formatter respects the given precision.
        Parameters:
        number - the double to format
        format - the formatter, can be null
        precision - number of digits right to the decimal point
        Returns:
        a formatted string with number
      • parseToNumber

        public static java.lang.Double parseToNumber(java.lang.String text)
        Parses a given string to a Double if possible and returns it. NaN, (+)Infinity, and -Infinity, are recognized. If the given string is empty, NaN is returned.
        Parameters:
        text - a string that should represent a number, scientific notation is recognized as well
        Returns:
        the assembled Double or null if something went wrong
        Throws:
        java.lang.IllegalArgumentException - if (text == null)
      • replaceAllSubStrings

        public static java.lang.String replaceAllSubStrings(java.lang.String origString,
                                                            java.lang.String substring,
                                                            java.lang.String replacementString)
        This method replaces all occurences of a substring in an original string with a replacement string. It does not work with regular expressions.
        Parameters:
        origString - the string to work on
        substring - must occur completely in origString for the replacement to work
        replacementString - the string with which substring is replaced
        Returns:
        a new string with the replacement(s) or
        origString if any of the parameters is null, if substring is empty or if substring does not occur in origString
      • replaceSubString

        public static java.lang.String replaceSubString(java.lang.String origString,
                                                        java.lang.String substring,
                                                        java.lang.String replacementString)
        This method replaces the first occurence of a substring in an original string with a replacement string. It does not work with regular expressions.
        Parameters:
        origString - the string to work on
        substring - must occur completely in origString for the replacement to work
        replacementString - the string with which substring is replaced
        Returns:
        a new string with the replacement or
        origString if any of the parameters is null, if substring is empty or if substring does not occur in origString
      • replaceSubString

        public static java.lang.String replaceSubString(java.lang.String origString,
                                                        java.lang.String substring,
                                                        java.lang.String replacementString,
                                                        int pos)
        This method replaces the first occurence of a substring in an original string with a replacement string, starting from a given position. It does not work with regular expressions.
        Parameters:
        origString - the string to work on
        substring - must occur completely in origString for the replacement to work
        replacementString - the string with which substring is replaced
        pos - the index in origString to start searching for substring, if < 0 pos is set to 0
        Returns:
        a new string with the replacement or
        origString if any of the parameters is null, if substring is empty or if substring does not occur in origString or if pos >= origString.length()
      • capitalizeFirst

        public static java.lang.String capitalizeFirst(java.lang.String s)
        Resturns string with first characted capitalized, rest lowercase. Useful for names.
        Parameters:
        s -
        Returns:
        string with first char upper case, rest lowercase or null if s == null

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.