fr.dyade.aaa.util

Class Strings


public class Strings
extends java.lang.Object

This class provides a set of static functions for building string representations of complex structures.

Field Summary

static int
listBorder
Controls the formatting of lists of objects.
static int
listMax
Controls the formatting of lists of objects.

Method Summary

static void
toByteArray(ByteArrayOutputStream output, String str)
Provides a Java string literal representing the parameter string.
static String
toString(Hashtable table)
Provides a string representation of a hash table of objects.
static String
toString(Object obj)
Provides a string representation of an object.
static String
toString(String str)
Provides a Java string literal representing the parameter string.
static void
toString(StringBuffer output, Hashtable table)
Provides a string representation of a hash table of objects.
static void
toString(StringBuffer output, Object obj)
Provides a string representation of an object.
static void
toString(StringBuffer output, Object obj, Class type)
Provides a string representation of an array.
static void
toString(StringBuffer output, String str)
Provides a Java string literal representing the parameter string.
static void
toString(StringBuffer output, Vector vector)
Provides a string representation of a vector of objects.
static void
toString(StringBuffer output, boolean[] tab)
Provides a string representation of an array of booleans.
static void
toString(StringBuffer output, byte[] tab)
Provides a string representation of an array of bytes.
static void
toString(StringBuffer output, char[] tab)
Provides a string representation of an array of chars.
static void
toString(StringBuffer output, double[] tab)
Provides a string representation of an array of doubles.
static void
toString(StringBuffer output, float[] tab)
Provides a string representation of an array of floats.
static void
toString(StringBuffer output, int[] tab)
Provides a string representation of an array of ints.
static void
toString(StringBuffer output, long[] tab)
Provides a string representation of an array of longs.
static void
toString(StringBuffer output, short[] tab)
Provides a string representation of an array of shorts.
static String
toString(Vector vector)
Provides a string representation of a vector of objects.
static String
toStringArray(Object tab)
Provides a string representation of an array.
static void
toStringArray(StringBuffer output, Object tab)
Provides a string representation of an array.

Field Details

listBorder

public static int listBorder
Controls the formatting of lists of objects. Lists with a number of elements greater than listMax are partially printed, with the listBorder leading 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 3.


listMax

public static int listMax
Controls the formatting of lists of objects. Lists with a number of elements up to listMax are entirely printed. A value of -1 leads 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 is 10.

Method Details

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 into
str - the string to print


toString

public static final String toString(Hashtable table)
Provides a string representation of a hash table of objects. Calls toString(StringBuffer, ...).

Parameters:
table - the table of Object objects to print

Returns:
a string representation of the table


toString

public static final String toString(Object obj)
Provides a string representation of an object. Calls toString(StringBuffer).

Parameters:
obj - the object to print

Returns:
a string representation of the object


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(StringBuffer output,
                                  Hashtable table)
Provides a string representation of a hash table of objects. Uses the listMax and listBorder variables.

Parameters:
output - a buffer to print the object into
table - the table of Object objects to print


toString

public static final void toString(StringBuffer output,
                                  Object obj)
Provides a string representation of an object. Checks if there exists in this class a specialized toString function for the object class, or calls the toString function of the object.

Parameters:
output - a buffer to print the object into
obj - the object to print


toString

public static final void toString(StringBuffer output,
                                  Object obj,
                                  Class type)
Provides a string representation of an array. Uses the listMax and listBorder variables.

Parameters:
output - a buffer to print the object into
obj - the array to print
type - the type of the array components


toString

public static final void toString(StringBuffer 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 into
str - the string to print


toString

public static final void toString(StringBuffer output,
                                  Vector vector)
Provides a string representation of a vector of objects. Uses the listMax and listBorder variables.

Parameters:
output - a buffer to print the object into
vector - the vector of Object objects to print


toString

public static final void toString(StringBuffer output,
                                  boolean[] tab)
Provides a string representation of an array of booleans. Uses the listMax and listBorder variables.

Parameters:
output - a buffer to print the object into
tab - the array to print


toString

public static final void toString(StringBuffer output,
                                  byte[] tab)
Provides a string representation of an array of bytes. Uses the listMax and listBorder variables.

Parameters:
output - a buffer to print the object into
tab - the array to print


toString

public static final void toString(StringBuffer output,
                                  char[] tab)
Provides a string representation of an array of chars. Uses the listMax and listBorder variables.

Parameters:
output - a buffer to print the object into
tab - the array to print


toString

public static final void toString(StringBuffer output,
                                  double[] tab)
Provides a string representation of an array of doubles. Uses the listMax and listBorder variables.

Parameters:
output - a buffer to print the object into
tab - the array to print


toString

public static final void toString(StringBuffer output,
                                  float[] tab)
Provides a string representation of an array of floats. Uses the listMax and listBorder variables.

Parameters:
output - a buffer to print the object into
tab - the array to print


toString

public static final void toString(StringBuffer output,
                                  int[] tab)
Provides a string representation of an array of ints. Uses the listMax and listBorder variables.

Parameters:
output - a buffer to print the object into
tab - the array to print


toString

public static final void toString(StringBuffer output,
                                  long[] tab)
Provides a string representation of an array of longs. Uses the listMax and listBorder variables.

Parameters:
output - a buffer to print the object into
tab - the array to print


toString

public static final void toString(StringBuffer output,
                                  short[] tab)
Provides a string representation of an array of shorts. Uses the listMax and listBorder variables.

Parameters:
output - a buffer to print the object into
tab - the array to print


toString

public static final String toString(Vector vector)
Provides a string representation of a vector of objects. Calls toString(StringBuffer, ...).

Parameters:
vector - the vector of Object objects to print

Returns:
a string representation of the vector


toStringArray

public static final String toStringArray(Object tab)
Provides a string representation of an array. Calls toString(StringBuffer, Object, Class).

Parameters:
tab - the array to print

Returns:
a string representation of the array


toStringArray

public static final void toStringArray(StringBuffer output,
                                       Object tab)
Provides a string representation of an array. Calls toString(StringBuffer, Object, Class).

Parameters:
output - a buffer to print the object into
tab - the array to print


Copyright B) 2004 Scalagent - All rights reserved