Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Lightweight Bartering Grid
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## lbg.common.io
Class CommonStringHandling

    java.lang.Object
      lbg.common.io.CommonStringHandling

    public abstract class CommonStringHandling

extends java.lang.Object

A CommonStringHandling provides common String handling routines.

Author:
  Cyril Briquet

Field Summary
`static byte[]` | `DUMMY_BYTE_ARRAY` Zero-sized, dummy byte array.
`static byte[][]` | `DUMMY_BYTE_MATRIX` Zero-sized, dummy byte matrix.
`static byte[]` | `DUMMY_LOG` Zero-sized, dummy String, intended to be used as a dummy execution log.
`static MetaGridData[]` | `DUMMY_MGD_ARRAY` Zero-sized, dummy MetaGridData array.
`static java.lang.Object[]` | `DUMMY_OBJECT_ARRAY` Zero-sized, dummy Object array.
`static java.lang.String` | `DUMMY_STRING` Dummy String.
`static java.lang.String[]` | `DUMMY_STRING_ARRAY` Zero-sized, dummy String array.

Constructor Summary
`CommonStringHandling()`

Method Summary
`static java.lang.String` | `doNotEditNotice()` Returns a DO NOT EDIT notice.
`static java.lang.String` | `fillWithHeadingCharacter(long i, int len, char c)` Generates a String representation of target int, filled with target heading character, if target int is smaller than target power of 10.
`static java.lang.String` | `fillWithHeadingSpaces(long i, int len)` Generates a String representation of target int, filled with heading spaces, if target int is smaller than target power of 10.
`static java.lang.String` | `fillWithHeadingZeros(long i, int len)` Generates a String representation of target int, filled with heading zeros, if target int is smaller than target power of 10.
`static java.lang.String` | `fillWithHeadingZerosLimit(long i, long j)` Generates a String representation of target int, filled with heading zeros if target int if smaller than target limit.
`static java.lang.String` | `formatIntegerDoubleAsInteger(double d)` Formats floating-point literal as a String, removing trailing .0 if present.
`static java.lang.String` | `generateTimeStamp()` Generates a timestamp, i.e.
`static java.lang.String` | `getStackTrace(java.lang.String msg)` Formats as a String the current stack trace using target message.
`static java.lang.String` | `getStackTrace(java.lang.Throwable thr)` Formats as a String the stack trace of target Throwable.
`static boolean` | `loadBoolean(java.lang.String s)` Loads a boolean from target String.
`static boolean[]` | `loadBooleanArray(java.lang.String s)` Loads a boolean array from target String.
`static double` | `loadDouble(java.lang.String s)` Loads a double from target String.
`static double[]` | `loadDoubleArray(java.lang.String s)` Loads a double array from target String.
`static float` | `loadFloat(java.lang.String s)` Loads a float from target String.
`static float[]` | `loadFloatArray(java.lang.String s)` Loads a float array from target String.
`static int` | `loadInt(java.lang.String s)` Loads an integer from target String.
`static int[]` | `loadIntArray(java.lang.String s)` Loads an integer array from target String.
`static long` | `loadLong(java.lang.String s)` Loads a log from target String.
`static long[]` | `loadLongArray(java.lang.String s)` Loads a long array from target String.
`static java.lang.String` | `loadProperty(java.lang.String key, java.util.Properties props)` Loads property from target Properties given target key.
`static java.lang.String[]` | `loadStringArray(java.lang.String s)` Loads a String array from target String.
`static
`<T> T[]`
` | `mergeArrays(T[] a1, T[]... ax)` Merges the target arrays into one new array, so that the resulting array is a concatenation of the target arrays.
`static java.lang.String[]` | `mergeStringArrays(java.lang.String[] a1, java.lang.String[] a2)` Deprecated. Use `mergeArrays(T[], T[]...)` instead
`static java.lang.String` | `replaceTag(java.lang.String s, java.lang.String old_tag, java.lang.String new_tag)` Replace a tag by another tag at the head of target String.
`static void` | `setGroupProperty(java.util.Properties props, java.lang.String key, boolean[] values)` Sets target Properties with target (key, group values) pair.
`static void` | `setGroupProperty(java.util.Properties props, java.lang.String key, double[] values)` Sets target Properties with target (key, group values) pair.
`static void` | `setGroupProperty(java.util.Properties props, java.lang.String key, float[] values)` Sets target Properties with target (key, group values) pair.
`static void` | `setGroupProperty(java.util.Properties props, java.lang.String key, int[] values)` Sets target Properties with target (key, group values) pair.
`static void` | `setGroupProperty(java.util.Properties props, java.lang.String key, long[] values)` Sets target Properties with target (key, group values) pair.
`static void` | `setGroupProperty(java.util.Properties props, java.lang.String key, java.lang.String value, int s)` Sets target Properties with target (key, group value) pair.
`static void` | `setGroupProperty(java.util.Properties props, java.lang.String key, java.lang.String value_all_except_one, java.lang.String value_last, int s)` Sets target Properties with target (key, group value) pair.
`static void` | `setProperty(java.util.Properties props, java.lang.String key, java.lang.String value)` Sets target Properties with target (key, value) pair.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DUMMY_LOG

    public static final byte[] DUMMY_LOG

  Zero-sized, dummy String, intended to be used as a dummy execution log.

### DUMMY_STRING

    public static final java.lang.String DUMMY_STRING

  Dummy String.

  See Also:
    Constant Field Values

### DUMMY_STRING_ARRAY

    public static final java.lang.String[] DUMMY_STRING_ARRAY

  Zero-sized, dummy String array.

### DUMMY_MGD_ARRAY

    public static final MetaGridData[] DUMMY_MGD_ARRAY

  Zero-sized, dummy MetaGridData array.

### DUMMY_OBJECT_ARRAY

    public static final java.lang.Object[] DUMMY_OBJECT_ARRAY

  Zero-sized, dummy Object array.

### DUMMY_BYTE_ARRAY

    public static final byte[] DUMMY_BYTE_ARRAY

  Zero-sized, dummy byte array.

### DUMMY_BYTE_MATRIX

    public static final byte[][] DUMMY_BYTE_MATRIX

  Zero-sized, dummy byte matrix.

Constructor Detail

### CommonStringHandling

    public CommonStringHandling()

Method Detail

### loadProperty

    public static java.lang.String loadProperty(java.lang.String key,
                                                java.util.Properties props)
                                         throws GridException

  Loads property from target Properties given target key.

  Parameters:
    `key` - target key
    `props` - target Properties
  Returns:
    property from target Properties given target key
  Throws:
    `GridException` - if target key or Properties are illegal

### setProperty

    public static void setProperty(java.util.Properties props,
                                   java.lang.String key,
                                   java.lang.String value)
                            throws GridException

  Sets target Properties with target (key, value) pair.

  Throws:
    `GridException`

### setGroupProperty

    public static void setGroupProperty(java.util.Properties props,
                                        java.lang.String key,
                                        java.lang.String value,
                                        int s)
                                 throws GridException

  Sets target Properties with target (key, group value) pair.

  Throws:
    `GridException`

### setGroupProperty

    public static void setGroupProperty(java.util.Properties props,
                                        java.lang.String key,
                                        java.lang.String value_all_except_one,
                                        java.lang.String value_last,
                                        int s)
                                 throws GridException

  Sets target Properties with target (key, group value) pair.

  Throws:
    `GridException`

### setGroupProperty

    public static void setGroupProperty(java.util.Properties props,
                                        java.lang.String key,
                                        int[] values)
                                 throws GridException

  Sets target Properties with target (key, group values) pair.

  Throws:
    `GridException`

### setGroupProperty

    public static void setGroupProperty(java.util.Properties props,
                                        java.lang.String key,
                                        long[] values)
                                 throws GridException

  Sets target Properties with target (key, group values) pair.

  Throws:
    `GridException`

### setGroupProperty

    public static void setGroupProperty(java.util.Properties props,
                                        java.lang.String key,
                                        float[] values)
                                 throws GridException

  Sets target Properties with target (key, group values) pair.

  Throws:
    `GridException`

### setGroupProperty

    public static void setGroupProperty(java.util.Properties props,
                                        java.lang.String key,
                                        double[] values)
                                 throws GridException

  Sets target Properties with target (key, group values) pair.

  Throws:
    `GridException`

### setGroupProperty

    public static void setGroupProperty(java.util.Properties props,
                                        java.lang.String key,
                                        boolean[] values)
                                 throws GridException

  Sets target Properties with target (key, group values) pair.

  Throws:
    `GridException`

### loadBoolean

    public static boolean loadBoolean(java.lang.String s)
                               throws GridException

  Loads a boolean from target String.

  Parameters:
    `s` - target String
  Returns:
    boolean loaded from target String
  Throws:
    `GridException` - if target String is illegal

### loadInt

    public static int loadInt(java.lang.String s)
                       throws GridException

  Loads an integer from target String.

  Parameters:
    `s` - target String
  Returns:
    integer loaded from target String
  Throws:
    `GridException` - if target String is illegal

### loadLong

    public static long loadLong(java.lang.String s)
                         throws GridException

  Loads a log from target String.

  Parameters:
    `s` - target String
  Returns:
    long loaded from target String
  Throws:
    `GridException` - if target String is illegal

### loadFloat

    public static float loadFloat(java.lang.String s)
                           throws GridException

  Loads a float from target String.

  Parameters:
    `s` - target String
  Returns:
    float loaded from target String
  Throws:
    `GridException` - if target String is illegal

### loadDouble

    public static double loadDouble(java.lang.String s)
                             throws GridException

  Loads a double from target String.

  Parameters:
    `s` - target String
  Returns:
    double loaded from target String
  Throws:
    `GridException` - if target String is illegal

### loadIntArray

    public static int[] loadIntArray(java.lang.String s)
                              throws GridException

  Loads an integer array from target String.

  Accepted syntax is exactly the following : `{x, y, z}`, i.e. comma separated, exactly one space behind the comma, the whole thing being enclosed in braces with no spaces before or after them.

  Parameters:
    `s` - target String
  Returns:
    integer array loaded from target String
  Throws:
    `GridException` - if target String is illegal

### loadLongArray

    public static long[] loadLongArray(java.lang.String s)
                                throws GridException

  Loads a long array from target String.

  Parameters:
    `s` - target String
  Returns:
    long array loaded from target String
  Throws:
    `GridException` - if target String is illegal

### loadFloatArray

    public static float[] loadFloatArray(java.lang.String s)
                                  throws GridException

  Loads a float array from target String.

  Parameters:
    `s` - target String
  Returns:
    float array loaded from target String
  Throws:
    `GridException` - if target String is illegal

### loadDoubleArray

    public static double[] loadDoubleArray(java.lang.String s)
                                    throws GridException

  Loads a double array from target String.

  Parameters:
    `s` - target String
  Returns:
    double array loaded from target String
  Throws:
    `GridException` - if target String is illegal

### loadStringArray

    public static java.lang.String[] loadStringArray(java.lang.String s)
                                              throws GridException

  Loads a String array from target String.

  Parameters:
    `s` - target String
  Returns:
    String array loaded from target String
  Throws:
    `GridException` - if target String is illegal

### loadBooleanArray

    public static boolean[] loadBooleanArray(java.lang.String s)
                                      throws GridException

  Loads a boolean array from target String.

  Parameters:
    `s` - target String
  Returns:
    boolean array loaded from target String
  Throws:
    `GridException` - if target String is illegal

### fillWithHeadingZerosLimit

    public static java.lang.String fillWithHeadingZerosLimit(long i,
                                                             long j)
                                                      throws GridException

  Generates a String representation of target int, filled with heading zeros if target int if smaller than target limit.

  Example: fillWithHeadingZerosLimit(42,100) -> "042".

  Parameters:
    `i` - target int
    `j` - target limit
  Returns:
    String representation of target int, filled with heading zeros if target int if smaller than pow(10,round(ceil(log10(j))))
  Throws:
    `GridException` - if a parameter is negative

### fillWithHeadingZeros

    public static java.lang.String fillWithHeadingZeros(long i,
                                                        int len)
                                                 throws GridException

  Generates a String representation of target int, filled with heading zeros, if target int is smaller than target power of 10. In other words, the target power of 10 represents the number of digits in the returned String representation.

  Example: fillWithHeadingZeros(42,3) -> "042".

  Parameters:
    `i` - target int
    `len` - base 10 power of target limit
  Returns:
    String representation of target int, filled with heading zeros if target int if smaller than pow(10,len-1)
  Throws:
    `GridException` - if a parameter is negative

### fillWithHeadingSpaces

    public static java.lang.String fillWithHeadingSpaces(long i,
                                                         int len)
                                                  throws GridException

  Generates a String representation of target int, filled with heading spaces, if target int is smaller than target power of 10. In other words, the target power of 10 represents the number of digits in the returned String representation.

  Example: fillWithHeadingZeros(42,3) -> " 42".

  Parameters:
    `i` - target int
    `len` - base 10 power of target limit
  Returns:
    String representation of target int, filled with heading zeros if target int if smaller than pow(10,len-1)
  Throws:
    `GridException` - if a parameter is negative

### fillWithHeadingCharacter

    public static java.lang.String fillWithHeadingCharacter(long i,
                                                            int len,
                                                            char c)
                                                     throws GridException

  Generates a String representation of target int, filled with target heading character, if target int is smaller than target power of 10. In other words, the target power of 10 represents the number of digits in the returned String representation.

  Example: fillWithHeadingZeros(42,3) -> "c42".

  Parameters:
    `i` - target int
    `len` - base 10 power of target limit
    `c` - target character
  Returns:
    String representation of target int, filled with heading zeros if target int if smaller than pow(10,len-1)
  Throws:
    `GridException` - if a parameter is negative

### replaceTag

    public static java.lang.String replaceTag(java.lang.String s,
                                              java.lang.String old_tag,
                                              java.lang.String new_tag)

  Replace a tag by another tag at the head of target String. Replacement takes place only when old tag is heading target String.

  Parameters:
    `s` - target String
    `old_tag` - old tag
    `new_tag` - new tag

### mergeStringArrays

    @Deprecated
    public static java.lang.String[] mergeStringArrays(java.lang.String[] a1,
                                                                  java.lang.String[] a2)
                                                throws GridException

  Deprecated. Use `mergeArrays(T[], T[]...)` instead

  Merges the two target String arrays into one new String array, so that the resulting array is a concatenation of the two target arrays.

  Parameters:
    `a1` - 1st target String array
    `a2` - 2nd target String array
  Returns:
    merged String array
  Throws:
    `GridException` - if a parameter is illegal

### mergeArrays

    public static <T> T[] mergeArrays(T[] a1,
                                      T[]... ax)

  Merges the target arrays into one new array, so that the resulting array is a concatenation of the target arrays.

  Parameters:
    `a1` - 1st target String array
    `ax` - The other arrays
  Returns:
    the merged array
  Throws:
    `java.lang.NullPointerException` - if any of the arrays is null

### formatIntegerDoubleAsInteger

    public static java.lang.String formatIntegerDoubleAsInteger(double d)

  Formats floating-point literal as a String, removing trailing .0 if present.

  Parameters:
    `d` - target floating-poing literal
  Returns:
    String representing target floating-poing literal

### generateTimeStamp

    public static java.lang.String generateTimeStamp()
                                              throws GridException

  Generates a timestamp, i.e. 20080303141924.

  Returns:
    generated timestamp
  Throws:
    `GridException`

### doNotEditNotice

    public static java.lang.String doNotEditNotice()

  Returns a DO NOT EDIT notice.

  Returns:
    DO NOT EDIT notice

### getStackTrace

    public static java.lang.String getStackTrace(java.lang.Throwable thr)

  Formats as a String the stack trace of target Throwable.

  Parameters:
    `thr` - target Throwable
  Returns:
    stack trace of target Throwable, as a String

### getStackTrace

    public static java.lang.String getStackTrace(java.lang.String msg)
                                          throws GridException

  Formats as a String the current stack trace using target message.

  Parameters:
    `msg` - target message
  Returns:
    stack trace of target Throwable, as a String
  Throws:
    `GridException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Lightweight Bartering Grid
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

> Copyright (c) 2005-2008, Cyril Briquet, parts Xavier Dalem.