jInfer

cz.cuni.mff.ksi.jinfer.base.utils
Class CollectionToString

java.lang.Object
  extended by cz.cuni.mff.ksi.jinfer.base.utils.CollectionToString

public class CollectionToString
extends Object

Helper class for collection presentation.


Nested Class Summary
static interface CollectionToString.ToString<T>
           
 
Field Summary
static CollectionToString.ToString<String> IDEMPOTENT
          A trivial toString strategy: simply returns the input String.
 
Method Summary
static
<T> String
colToString(Collection<T> collection, String separator, CollectionToString.ToString<T> toStringStrategy)
          Converts a collection to a string looking like this: (a,b,c,d).
static
<T> String
colToString(Collection<T> collection, String separator, CollectionToString.ToString<T> toStringStrategy, String braceOpen, String braceClose)
          Converts a collection to a string looking like this: (a,b,c,d).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IDEMPOTENT

public static final CollectionToString.ToString<String> IDEMPOTENT
A trivial toString strategy: simply returns the input String.

Method Detail

colToString

public static <T> String colToString(Collection<T> collection,
                                     String separator,
                                     CollectionToString.ToString<T> toStringStrategy)
Converts a collection to a string looking like this: (a,b,c,d). Separator and strategy of turning collection elements to string is configurable.

Type Parameters:
T - Type on which we work.
Parameters:
collection - Collection to be turned into a string.
separator - A character that will separate the elements.
toStringStrategy - Strategy how to convert an element of the collection to a string.
Returns:
String representing the collection.

colToString

public static <T> String colToString(Collection<T> collection,
                                     String separator,
                                     CollectionToString.ToString<T> toStringStrategy,
                                     String braceOpen,
                                     String braceClose)
Converts a collection to a string looking like this: (a,b,c,d). Separator and strategy of turning collection elements to string is configurable.

Type Parameters:
T - Type on which we work.
Parameters:
collection - Collection to be turned into a string.
separator - A character that will separate the elements.
toStringStrategy - Strategy how to convert an element of the collection to a string.
braceOpen - How to opening brace should look like (empty string is OK).
braceClose - How to closing brace should look like (empty string is OK).
Returns:
String representing the collection.

jInfer

Generated on Fri Dec 9 00:01:25 CET 2011