de.esprit.common.util

## Class DumpString

- java.lang.Object
- - de.esprit.common.util.DumpString

- All Implemented Interfaces:
    java.io.Serializable

      public class DumpString
      extends java.lang.Object
      implements java.io.Serializable

  This class can be filled with key-value pairs to be printed as dump output. The resulting String can be retrieved with the `toString()` method. You can add the following things to a DumpString:
  - Add key value pairs using `add(String, Object)`
  - Add a single line output using `addLine(String)`
  - Add a headline `addHeadline(String)`
  - Add the content of a list, map or array using `addList(Collection)`
  The output-format can either be a dump- or property-format, see `setPropertyFormat(boolean)`
  Author:
    Rainer Buesch
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DumpString()` Creates an empty DumpString.
    `DumpString(boolean isPropertyFormat)` Creates a DumpString for writing key value pairs in property format.
    `DumpString(int indent)` Creates a DumpString with the given fixed property-key length.
    `DumpString(java.lang.String header)`
    `DumpString(java.lang.String header, int headLineLength)`
    `DumpString(java.lang.String header, int headLineLength, int maxElements)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `DumpString` | `add(java.lang.String key, java.lang.Object value)` Use this method for dumping key value pairs.
    `void` | `addArray(java.lang.Object[] array)`
    `void` | `addArray(java.lang.String headline, java.lang.Object[] array)`
    `void` | `addHeadline(java.lang.String text)` Sets the length for a headline.
    `void` | `addLine()` Prints a newline only.
    `DumpString` | `addLine(java.lang.String text)` Prints the string with a trailing newline.
    `void` | `addList(java.util.Collection coll)`
    `void` | `addList(java.lang.String headline, java.util.Collection coll)`
    `void` | `addMap(java.util.Map map)`
    `void` | `addMap(java.lang.String headline, java.util.Map map)`
    `int` | `getFixKeyLength()`
    `int` | `getMaxKeyLength()`
    `void` | `remove(java.lang.String key)`
    `void` | `setFixKeyLength(int length)` Sets the key length for property printing to a fixed value.
    `void` | `setHeadLineLength(int length)`
    `void` | `setMaxElements(int maxElements)` Defines the maximum number of elements that are printed when a Collection, Map or Object[] ist dumped.
    `void` | `setPropertyFormat(boolean isPropertyFormat)` Forces key-value pairs to be printed in the java property format (key=value).
    `void` | `setPropertySeparator(java.lang.String propSep)`
    `static java.lang.String` | `sizeStringOf(java.util.Collection coll)`
    `static java.lang.String` | `sizeStringOf(java.util.Map map)`
    `static java.lang.String` | `sizeStringOf(java.lang.Object[] array)`
    `java.lang.String` | `toString()` Returns the resulting string that has been printed into the buffer.
    `ToString` | `toString(ToString s)` Fills the given ToString object with the key-value pairs of this DumpString

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

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

- - ### Constructor Detail

    - #### DumpString

          public DumpString()

      Creates an empty DumpString.

    - #### DumpString

          public DumpString(java.lang.String header)

    - #### DumpString

          public DumpString(java.lang.String header,
                    int headLineLength)

    - #### DumpString

          public DumpString(java.lang.String header,
                    int headLineLength,
                    int maxElements)

    - #### DumpString

          public DumpString(int indent)

      Creates a DumpString with the given fixed property-key length.

    - #### DumpString

          public DumpString(boolean isPropertyFormat)

      Creates a DumpString for writing key value pairs in property format.

  - ### Method Detail

    - #### setPropertyFormat

          public void setPropertyFormat(boolean isPropertyFormat)

      Forces key-value pairs to be printed in the java property format (key=value). If set to false then the format is right aligned keys with left aligned values separated by the current property separator (key: value).

    - #### setMaxElements

          public void setMaxElements(int maxElements)

      Defines the maximum number of elements that are printed when a Collection, Map or Object[] ist dumped. This output is limited because otherwise we would risk huge dumps with performance drawbacks.

    - #### setFixKeyLength

          public void setFixKeyLength(int length)

      Sets the key length for property printing to a fixed value. If set to 0, then the key-length is determined by the longest key printed into this DumpString

    - #### getFixKeyLength

          public int getFixKeyLength()

    - #### addHeadline

          public void addHeadline(java.lang.String text)

      Sets the length for a headline. A headline is filled up with dots up to this length.

    - #### setHeadLineLength

          public void setHeadLineLength(int length)

    - #### addLine

          public DumpString addLine(java.lang.String text)

      Prints the string with a trailing newline.

    - #### addLine

          public void addLine()

      Prints a newline only.

    - #### add

          public DumpString add(java.lang.String key,
                       java.lang.Object value)

      Use this method for dumping key value pairs. The key and values are aligned to look nicely. The width of the key property can be set in the constructor. This method is multiply overloaded in order to print various data types.

    - #### addArray

          public void addArray(java.lang.String headline,
                      java.lang.Object[] array)

    - #### addArray

          public void addArray(java.lang.Object[] array)

    - #### addList

          public void addList(java.lang.String headline,
                     java.util.Collection coll)

    - #### addList

          public void addList(java.util.Collection coll)

    - #### addMap

          public void addMap(java.lang.String headline,
                    java.util.Map map)

    - #### addMap

          public void addMap(java.util.Map map)

    - #### getMaxKeyLength

          public int getMaxKeyLength()

    - #### remove

          public void remove(java.lang.String key)

    - #### toString

          public java.lang.String toString()

      Returns the resulting string that has been printed into the buffer. Note that at the time this method is called the indentation level should be back on zero! A warning is issued if this is not the case.
      Overrides:
        `toString` in class `java.lang.Object`

    - #### setPropertySeparator

          public void setPropertySeparator(java.lang.String propSep)

    - #### toString

          public ToString toString(ToString s)

      Fills the given ToString object with the key-value pairs of this DumpString

    - #### sizeStringOf

          public static java.lang.String sizeStringOf(java.util.Collection coll)

    - #### sizeStringOf

          public static java.lang.String sizeStringOf(java.util.Map map)

    - #### sizeStringOf

          public static java.lang.String sizeStringOf(java.lang.Object[] array)

Copyright © 2014 EsprIT-Systems. All Rights Reserved.