org.codehaus.cargo.container.internal.util
Class PropertyUtils

java.lang.Object
  extended by org.codehaus.cargo.container.internal.util.PropertyUtils

public final class PropertyUtils
extends Object

A class to convert properties to strings and back.

Version:
$Id: PropertyUtils.java 1875 2009-02-13 13:54:16Z adriancole $

Method Summary
static String escapeBackSlashesIfNotNull(String in)
          Escapes backslashes so that they can parse properly.
static String joinOnDelimiter(Map toJoin, char delimiter)
          Convert properties to a string representation, based on the specified delimiter.
static String joinOnPipe(Map toJoin)
          Convert properties to a string representation.
static String joinOnSemicolon(Map toJoin)
          Convert properties to a string representation.
static void setPropertyIfNotNull(Properties properties, String property, Object value)
          Sets a property value if the property is not null.
static Properties splitPropertiesOnDelimiter(String toSplit, char delimiter)
          Construct a Properties object from a single string, by splitting it on a specified delimiter.
static Properties splitPropertiesOnPipe(String toSplit)
          Construct a Properties object from a single string, converting '|' symbols to end of line characters for parsing.
static Properties splitPropertiesOnSemicolon(String toSplit)
          Construct a Properties object from a single string, converting ';' symbols to end of line characters for parsing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

splitPropertiesOnPipe

public static Properties splitPropertiesOnPipe(String toSplit)
Construct a Properties object from a single string, converting '|' symbols to end of line characters for parsing.

Example: "abc=def|car=bmw" gets converted to "abc" -> "def", and "car" -> "bmw"

Parameters:
toSplit - The string value to convert to properties, pipe separated
Returns:
the list of properties
See Also:
getPropertiesFromDelimitedString

splitPropertiesOnSemicolon

public static Properties splitPropertiesOnSemicolon(String toSplit)
Construct a Properties object from a single string, converting ';' symbols to end of line characters for parsing.

Example: "abc=def;car=bmw" gets converted to "abc" -> "def", and "car" -> "bmw"

Parameters:
toSplit - The string value to convert to properties, semicolon separated
Returns:
the list of properties
See Also:
getPropertiesFromDelimitedString

splitPropertiesOnDelimiter

public static Properties splitPropertiesOnDelimiter(String toSplit,
                                                    char delimiter)
Construct a Properties object from a single string, by splitting it on a specified delimiter.

Example: "abc=def;car=bmw" gets converted to "abc" -> "def", and "car" -> "bmw" where: delimiter = ;

Parameters:
toSplit - The string value to convert to properties
delimiter - The delimiter of the string
Returns:
the list of properties

joinOnPipe

public static String joinOnPipe(Map toJoin)
Convert properties to a string representation.

Parameters:
toJoin - A list of properties to convert
Returns:
the properties as a string, pipe delimited

joinOnSemicolon

public static String joinOnSemicolon(Map toJoin)
Convert properties to a string representation.

Parameters:
toJoin - A list of properties to convert
Returns:
the properties as a string, pipe delimited

joinOnDelimiter

public static String joinOnDelimiter(Map toJoin,
                                     char delimiter)
Convert properties to a string representation, based on the specified delimiter.

Parameters:
toJoin - object to serialize as a string
delimiter - how to separate entries from each other
Returns:
the properties as a string, delimited by the above

setPropertyIfNotNull

public static void setPropertyIfNotNull(Properties properties,
                                        String property,
                                        Object value)
Sets a property value if the property is not null.

Parameters:
properties - the properties object to store the property into
property - the property to set
value - the value to set

escapeBackSlashesIfNotNull

public static String escapeBackSlashesIfNotNull(String in)
Escapes backslashes so that they can parse properly.

Parameters:
in - - string with backslashes
Returns:
string with backslashes escaped, or null, if passed null


Copyright © 2004-2012 Codehaus. All Rights Reserved.