Class Strings
- java.lang.Object
-
- fr.dyade.aaa.common.Strings
-
public class Strings extends Object
This class provides a set of static functions for building string representations of complex structures.
-
-
Field Summary
Fields Modifier and Type Field Description static intlistBorderControls the default formatting of lists of objects.static intlistMaxControls the default formatting of lists of objects.
-
Constructor Summary
Constructors Constructor Description Strings()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidtoByteArray(ByteArrayOutputStream output, String str)Provides a Java string literal representing the parameter string.static StringtoString(Object obj)Provides a string representation of an object.static StringtoString(String str)Provides a Java string literal representing the parameter string.static voidtoString(StringBuilder output, boolean[] tab)Provides a string representation of an array of booleans.static voidtoString(StringBuilder output, boolean[] tab, int listMax, int listBorder)Provides a string representation of an array of booleans.static voidtoString(StringBuilder output, byte[] tab)Provides a string representation of an array of bytes.static voidtoString(StringBuilder output, byte[] tab, int listMax, int listBorder)Provides a string representation of an array of bytes.static voidtoString(StringBuilder output, char[] tab)Provides a string representation of an array of chars.static voidtoString(StringBuilder output, char[] tab, int listMax, int listBorder)Provides a string representation of an array of chars.static voidtoString(StringBuilder output, double[] tab)Provides a string representation of an array of doubles.static voidtoString(StringBuilder output, double[] tab, int listMax, int listBorder)Provides a string representation of an array of doubles.static voidtoString(StringBuilder output, float[] tab)Provides a string representation of an array of floats.static voidtoString(StringBuilder output, float[] tab, int listMax, int listBorder)Provides a string representation of an array of floats.static voidtoString(StringBuilder output, int[] tab)Provides a string representation of an array of ints.static voidtoString(StringBuilder output, int[] tab, int listMax, int listBorder)Provides a string representation of an array of ints.static voidtoString(StringBuilder output, long[] tab)Provides a string representation of an array of longs.static voidtoString(StringBuilder output, long[] tab, int listMax, int listBorder)Provides a string representation of an array of longs.static voidtoString(StringBuilder output, short[] tab)Provides a string representation of an array of shorts.static voidtoString(StringBuilder output, short[] tab, int listMax, int listBorder)Provides a string representation of an array of shorts.static voidtoString(StringBuilder output, Object obj)Provides a string representation of an object.static voidtoString(StringBuilder output, Object[] tab)Provides a string representation of an array of objects.static voidtoString(StringBuilder output, Object[] tab, int listMax, int listBorder)Provides a string representation of an array of objects.static voidtoString(StringBuilder output, Object obj, Class<?> type)Provides a string representation of an array.static voidtoString(StringBuilder output, Object obj, Class<?> type, int listMax, int listBorder)Provides a string representation of an array.static voidtoString(StringBuilder output, String str)Provides a Java string literal representing the parameter string.static voidtoString(StringBuilder output, Collection<?> set)Provides a string representation of an unordered Collection of objects.static voidtoString(StringBuilder output, Collection<?> set, int listMax, int listBorder)Provides a string representation of an unordered Collection of objects.static voidtoString(StringBuilder output, List<?> list)Provides a string representation of a list of objects.static voidtoString(StringBuilder output, List<?> list, int listMax, int listBorder)Provides a string representation of a list of objects.static voidtoString(StringBuilder output, Map.Entry<?,?> entry)Provides a string representation of a Map entry.static voidtoString(StringBuilder output, Map<?,?> map)Provides a string representation of a Map.static StringtoString(Collection<?> set)Provides a string representation of an unordered Collection of objects.static StringtoString(List<?> list)Provides a string representation of a list of objects.static StringtoString(Map<?,?> map)Provides a string representation of a Map.static StringtoStringArray(Object tab)Provides a string representation of an array.static voidtoStringArray(StringBuilder output, Object tab)Provides a string representation of an array.
-
-
-
Field Detail
-
listMax
public static int listMax
Controls the default formatting of lists of objects. By default lists with a number of elements up tolistMaxare entirely printed. A value of-1leads to complete printing of the list, whatever its size.This variable, when used in an agent server, may be set by the debug variable
Debug.var.fr.dyade.aaa.util.listMax. Its default value is10.
-
listBorder
public static int listBorder
Controls the default formatting of lists of objects. By default lists with a number of elements greater thanlistMaxare partially printed, with thelistBorderleading and trailing elements.This variable, when used in an agent server, may be set by the debug variable
Debug.var.fr.dyade.aaa.util.listBorder. Its default value is is3.
-
-
Method Detail
-
toString
public static final void toString(StringBuilder output, Object obj)
Provides a string representation of an object. Checks if there exists in this class a specializedtoStringfunction for the object class, or calls thetoStringfunction of the object.- Parameters:
output- a buffer to print the object intoobj- the object to print
-
toString
public static final String toString(Object obj)
Provides a string representation of an object. CallstoString(StringBuilder).- Parameters:
obj- the object to print- Returns:
- a string representation of the object
-
toByteArray
public static final void toByteArray(ByteArrayOutputStream output, String str)
Provides a Java string literal representing the parameter string. This includes surrounding double quotes, and quoted special characters, including UTF escape sequences when necessary.This function works only for ASCII character encoding, and assumes this is the default encoding.
- Parameters:
output- a byte buffer to print the object intostr- the string to print
-
toString
public static final void toString(StringBuilder output, String str)
Provides a Java string literal representing the parameter string. This includes surrounding double quotes, and quoted special characters, including UTF escape sequences when necessary.This function works only for ASCII character encoding, and assumes this is the default encoding.
- Parameters:
output- a string buffer to print the object intostr- the string to print
-
toString
public static final String toString(String str)
Provides a Java string literal representing the parameter string. This includes surrounding double quotes, and quoted special characters, including UTF escape sequences when necessary.This function works only for ASCII character encoding, and assumes this is the default encoding.
- Parameters:
str- the string to print- Returns:
- a Java string literal representation of the string
-
toString
public static final void toString(StringBuilder output, Object obj, Class<?> type)
Provides a string representation of an array.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.- Parameters:
output- a buffer to print the object intoobj- the array to printtype- the type of the array components- See Also:
listMax,listBorder
-
toString
public static final void toString(StringBuilder output, Object obj, Class<?> type, int listMax, int listBorder)
Provides a string representation of an array.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements. A value of-1forlistMaxleads to complete printing of the list, whatever its size.- Parameters:
output- a buffer to print the object intoobj- the array to printtype- the type of the array componentslistMax- Controls the formatting of lists of objects.listBorder- Controls the formatting of lists of objects.
-
toStringArray
public static final void toStringArray(StringBuilder output, Object tab)
Provides a string representation of an array. CallstoString(StringBuilder, Object, Class).- Parameters:
output- a buffer to print the object intotab- the array to print
-
toStringArray
public static final String toStringArray(Object tab)
Provides a string representation of an array. CallstoString(StringBuilder, Object, Class).- Parameters:
tab- the array to print- Returns:
- a string representation of the array
- See Also:
toString(StringBuilder, Object, Class)
-
toString
public static final void toString(StringBuilder output, boolean[] tab)
Provides a string representation of an array of booleans.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.- Parameters:
output- a buffer to print the object intotab- the array to print- See Also:
listMax,listBorder
-
toString
public static final void toString(StringBuilder output, boolean[] tab, int listMax, int listBorder)
Provides a string representation of an array of booleans.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.A value of
-1forlistMaxleads to complete printing of the list, whatever its size.- Parameters:
output- a buffer to print the object intotab- the array to printlistMax- Controls the formatting of lists of objects.listBorder- Controls the formatting of lists of objects.
-
toString
public static final void toString(StringBuilder output, byte[] tab)
Provides a string representation of an array of bytes.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.- Parameters:
output- a buffer to print the object intotab- the array to print- See Also:
listMax,listBorder
-
toString
public static final void toString(StringBuilder output, byte[] tab, int listMax, int listBorder)
Provides a string representation of an array of bytes.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.A value of
-1forlistMaxleads to complete printing of the list, whatever its size.- Parameters:
output- a buffer to print the object intotab- the array to printlistMax- Controls the formatting of lists of objects.listBorder- Controls the formatting of lists of objects.
-
toString
public static final void toString(StringBuilder output, char[] tab)
Provides a string representation of an array of chars.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.- Parameters:
output- a buffer to print the object intotab- the array to print- See Also:
listMax,listBorder
-
toString
public static final void toString(StringBuilder output, char[] tab, int listMax, int listBorder)
Provides a string representation of an array of chars.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.A value of
-1forlistMaxleads to complete printing of the list, whatever its size.- Parameters:
output- a buffer to print the object intotab- the array to printlistMax- Controls the formatting of lists of objects.listBorder- Controls the formatting of lists of objects.
-
toString
public static final void toString(StringBuilder output, short[] tab)
Provides a string representation of an array of shorts.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.- Parameters:
output- a buffer to print the object intotab- the array to print- See Also:
listMax,listBorder
-
toString
public static final void toString(StringBuilder output, short[] tab, int listMax, int listBorder)
Provides a string representation of an array of shorts.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.A value of
-1forlistMaxleads to complete printing of the list, whatever its size.- Parameters:
output- a buffer to print the object intotab- the array to printlistMax- Controls the formatting of lists of objects.listBorder- Controls the formatting of lists of objects.
-
toString
public static final void toString(StringBuilder output, int[] tab)
Provides a string representation of an array of ints.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.- Parameters:
output- a buffer to print the object intotab- the array to print- See Also:
listMax,listBorder
-
toString
public static final void toString(StringBuilder output, int[] tab, int listMax, int listBorder)
Provides a string representation of an array of ints.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.A value of
-1forlistMaxleads to complete printing of the list, whatever its size.- Parameters:
output- a buffer to print the object intotab- the array to printlistMax- Controls the formatting of lists of objects.listBorder- Controls the formatting of lists of objects.
-
toString
public static final void toString(StringBuilder output, long[] tab)
Provides a string representation of an array of longs.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.- Parameters:
output- a buffer to print the object intotab- the array to print- See Also:
listMax,listBorder
-
toString
public static final void toString(StringBuilder output, long[] tab, int listMax, int listBorder)
Provides a string representation of an array of longs.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.A value of
-1forlistMaxleads to complete printing of the list, whatever its size.- Parameters:
output- a buffer to print the object intotab- the array to printlistMax- Controls the formatting of lists of objects.listBorder- Controls the formatting of lists of objects.
-
toString
public static final void toString(StringBuilder output, float[] tab)
Provides a string representation of an array of floats.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.- Parameters:
output- a buffer to print the object intotab- the array to print- See Also:
listMax,listBorder
-
toString
public static final void toString(StringBuilder output, float[] tab, int listMax, int listBorder)
Provides a string representation of an array of floats.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.A value of
-1forlistMaxleads to complete printing of the list, whatever its size.- Parameters:
output- a buffer to print the object intotab- the array to printlistMax- Controls the formatting of lists of objects.listBorder- Controls the formatting of lists of objects.
-
toString
public static final void toString(StringBuilder output, double[] tab)
Provides a string representation of an array of doubles.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.- Parameters:
output- a buffer to print the object intotab- the array to print- See Also:
listMax,listBorder
-
toString
public static final void toString(StringBuilder output, double[] tab, int listMax, int listBorder)
Provides a string representation of an array of doubles.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.A value of
-1forlistMaxleads to complete printing of the list, whatever its size.- Parameters:
output- a buffer to print the object intotab- the array to printlistMax- Controls the formatting of lists of objects.listBorder- Controls the formatting of lists of objects.
-
toString
public static final void toString(StringBuilder output, Object[] tab)
Provides a string representation of an array of objects.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.- Parameters:
output- a buffer to print the object intotab- the array to print- See Also:
listMax,listBorder
-
toString
public static final void toString(StringBuilder output, Object[] tab, int listMax, int listBorder)
Provides a string representation of an array of objects.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.A value of
-1forlistMaxleads to complete printing of the list, whatever its size.- Parameters:
output- a buffer to print the object intotab- the array to printlistMax- Controls the formatting of lists of objects.listBorder- Controls the formatting of lists of objects.
-
toString
public static final void toString(StringBuilder output, List<?> list)
Provides a string representation of a list of objects. This includes Vectors.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.- Parameters:
output- a buffer to print the object intolist- the list ofObjectobjects to print- See Also:
listMax,listBorder
-
toString
public static final void toString(StringBuilder output, List<?> list, int listMax, int listBorder)
Provides a string representation of a list of objects. This includes Vectors.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.A value of
-1forlistMaxleads to complete printing of the list, whatever its size.- Parameters:
output- a buffer to print the object intolist- the list ofObjectobjects to printlistMax- Controls the formatting of lists of objects.listBorder- Controls the formatting of lists of objects.
-
toString
public static final String toString(List<?> list)
Provides a string representation of a list of objects. CallstoString(StringBuilder, ...).- Parameters:
list- the list ofObjectobjects to print- Returns:
- a string representation of the list
-
toString
public static final void toString(StringBuilder output, Collection<?> set)
Provides a string representation of an unordered Collection of objects. This includes HashSets.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.- Parameters:
output- a buffer to print the object intoset- the collection to print- See Also:
listMax,listBorder
-
toString
public static final void toString(StringBuilder output, Collection<?> set, int listMax, int listBorder)
Provides a string representation of an unordered Collection of objects. This includes HashSets.Lists with a number of elements greater than
listMaxare partially printed, with thelistBorderleading and trailing elements.A value of
-1forlistMaxleads to complete printing of the list, whatever its size.- Parameters:
output- a buffer to print the object intoset- the collection to printlistMax- Controls the formatting of lists of objects.listBorder- Controls the formatting of lists of objects.
-
toString
public static final String toString(Collection<?> set)
Provides a string representation of an unordered Collection of objects. CallstoString(StringBuilder, ...).- Parameters:
set- the collection to print- Returns:
- a string representation of the list
-
toString
public static final void toString(StringBuilder output, Map<?,?> map)
Provides a string representation of a Map. This includes HashTables. Uses thelistMaxandlistBordervariables.- Parameters:
output- a buffer to print the object intomap- the map to print
-
toString
public static final String toString(Map<?,?> map)
Provides a string representation of a Map. CallstoString(StringBuilder, ...).- Parameters:
map- the map to print- Returns:
- a string representation of the map
-
toString
public static final void toString(StringBuilder output, Map.Entry<?,?> entry)
Provides a string representation of a Map entry.- Parameters:
output- a buffer to print the object intoentry- the map entry to print
-
-