PIRL.Strings

## Class String_Utilities

- java.lang.Object
- - PIRL.Strings.String_Utilities

    public class String_Utilities
    extends Object

The String_Utilities are a collection of static functions that operate on String objects to provide various commonly used operations.

### Field Summary

Fields
`static int` `DEFAULT_DECIMAL_DIGITS` The default number of decimal digits used by the `Amount_Magnitude(long, int)` function.
`static String` `ID` Class identification with revision number and date.
`static int` `MAX_DECIMAL_DIGITS` The default number of decimal digits used by the `Amount_Magnitude(long, int)` function.

### Method Summary

Methods
`static String` `Amount_Magnitude(long amount)` Provide a binary magnitude String representation of an amount.
`static String` `Amount_Magnitude(long amount, int decimal_digits)` Provide a binary magnitude String representation of an amount.
`static String` `Following(String string, char delimiter)` Gets that portion of a String following a delimiter.
`static String` `Preceeding(String string, char delimiter)` Gets that portion of a String preceeding a delimiter.
`static String` `Trim(String string, char delimiter)` Trims all delimiter characters from both ends of a string.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### ID

    public static final String ID

Class identification with revision number and date.

See Also:
  Constant Field Values

#### DEFAULT_DECIMAL_DIGITS

    public static final int DEFAULT_DECIMAL_DIGITS

The default number of decimal digits used by the `Amount_Magnitude(long, int)` function.

See Also:
  Constant Field Values

#### MAX_DECIMAL_DIGITS

    public static final int MAX_DECIMAL_DIGITS

The default number of decimal digits used by the `Amount_Magnitude(long, int)` function.

See Also:
  Constant Field Values

### Method Detail

#### Trim

    public static String Trim(String string,
              char delimiter)

Trims all delimiter characters from both ends of a string.

Parameters:
  `string` - The String to trim.
  `delimiter` - The character to be trimmed off the ends.
Returns:
  The string, sans leading and trailing characers.

#### Preceeding

    public static String Preceeding(String string,
                    char delimiter)

Gets that portion of a String preceeding a delimiter.

Parameters:
  `string` - The String from which to get the leading portion.
  `delimiter` - The delimiter character.
Returns:
  The portion of the String before the delimiter, or null if the delimiter is not present.

#### Following

    public static String Following(String string,
                   char delimiter)

Gets that portion of a String following a delimiter.

Parameters:
  `string` - The String from which to get the trailing portion.
  `delimiter` - The delimiter character.
Returns:
  The portion of the String following the delimiter, or null if the delimiter is not present.

#### Amount_Magnitude

    public static String Amount_Magnitude(long amount,
                          int decimal_digits)

Provide a binary magnitude String representation of an amount.

An amount that is less than 1024 is returned as its String representation. Otherwise it is divided by 1024 until its value is less than 1024, up to a maximum of five times. The number of divisions determines the binary magnitude of the amount, the first character of which is then appended to the String representation of the reduced value:

1. Kilo
2. Mega
3. Giga
4. Tera
5. Peta

Negative values are treated as positive values with the negative sign applied to the final result.

Parameters:
  `amount` - The amount to be represented.
  `decimal_digits` - The number of decimal digits in the reduced amount representation. If this is negative the `DEFAULT_DECIMAL_DIGITS` will be used. The number of digits will be limited to a maximum of `MAX_DECIMAL_DIGITS`.
Returns:
  A String representation of the amount with a binary magnitude suffix character if the amount was not less than 1024.

#### Amount_Magnitude

    public static String Amount_Magnitude(long amount)

Provide a binary magnitude String representation of an amount.

The `DEFAULT_DECIMAL_DIGITS` number of decimal digits in the reduced amount representation will be used.

Parameters:
  `amount` - The amount to be represented.
Returns:
  A String representation of the amount with a binary magnitude suffix character if the amount was not less than 1024.
See Also:
  `Amount_Magnitude(long, int)`