org.sonar.api.utils
Class KeyValueFormat

java.lang.Object
  extended by org.sonar.api.utils.KeyValueFormat

public final class KeyValueFormat
extends Object

Util class to format key/value data. Output is a string representation ready to be injected into the database

Since:
1.10

Nested Class Summary
static class KeyValueFormat.DoubleNumbersPairTransformer
          Implementation of Transformer
static class KeyValueFormat.IntegerNumbersPairTransformer
          Implementation of Transformer
static class KeyValueFormat.RulePriorityNumbersPairTransformer
          Implementation of Transformer
static class KeyValueFormat.StringNumberPairTransformer
          Implementation of Transformer
static interface KeyValueFormat.Transformer<KEY,VALUE>
           
 
Method Summary
static String format(org.apache.commons.collections.Bag bag)
          Deprecated. use Multiset from google collections instead of commons-collections bags
static String format(org.apache.commons.collections.Bag bag, int var)
          Deprecated. use Multiset from google collections instead of commons-collections bags
static
<KEY,VALUE>
String
format(Map<KEY,VALUE> map)
          Transforms a map into a string with the format : "key1=value1;key2=value2..."
static String format(com.google.common.collect.Multiset<?> set)
          Transforms a Multiset into a string with the format : "key1=count1;key2=count2..."
static String format(Object... objects)
          Transforms a Object...
static Map<String,String> parse(String data)
          Transforms a string with the following format : "key1=value1;key2=value2..." into a Map
static
<KEY,VALUE>
Map<KEY,VALUE>
parse(String data, KeyValueFormat.Transformer<KEY,VALUE> transformer)
          Transforms a string with the following format : "key1=value1;key2=value2..." into a Map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parse

public static <KEY,VALUE> Map<KEY,VALUE> parse(String data,
                                               KeyValueFormat.Transformer<KEY,VALUE> transformer)
Transforms a string with the following format : "key1=value1;key2=value2..." into a Map. Requires to implement the transform(key,value) method

Parameters:
data - the input string
transformer - the interface to implement
Returns:
a Map of

parse

public static Map<String,String> parse(String data)
Transforms a string with the following format : "key1=value1;key2=value2..." into a Map

Parameters:
data - the string to parse
Returns:
a map

format

public static <KEY,VALUE> String format(Map<KEY,VALUE> map)
Transforms a map into a string with the format : "key1=value1;key2=value2..."

Parameters:
map - the map to transform
Returns:
the formatted string

format

public static String format(org.apache.commons.collections.Bag bag)
Deprecated. use Multiset from google collections instead of commons-collections bags

Since:
1.11

format

public static String format(org.apache.commons.collections.Bag bag,
                            int var)
Deprecated. use Multiset from google collections instead of commons-collections bags

Since:
1.11

format

public static String format(com.google.common.collect.Multiset<?> set)
Transforms a Multiset into a string with the format : "key1=count1;key2=count2..."

Parameters:
set - the set to transform
Returns:
the formatted string

format

public static String format(Object... objects)
Transforms a Object... into a string with the format : "object1=object2;object3=object4..."

Parameters:
objects - the object list to transform
Returns:
the formatted string


Copyright © 2009-2010 SonarSource. All Rights Reserved.