org.modeshape.jdbc.util
Class StringUtil

java.lang.Object
  extended by org.modeshape.jdbc.util.StringUtil

public class StringUtil
extends Object

Utilities for string processing and manipulation.


Field Summary
static String[] EMPTY_STRING_ARRAY
           
 
Method Summary
static String createString(char charToRepeat, int numberOfRepeats)
          Create a new string containing the specified character repeated a specific number of times.
static String createString(String pattern, Object... parameters)
          Create a string by substituting the parameters into all key occurrences in the supplied format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_STRING_ARRAY

public static final String[] EMPTY_STRING_ARRAY
Method Detail

createString

public static String createString(String pattern,
                                  Object... parameters)
Create a string by substituting the parameters into all key occurrences in the supplied format. The pattern consists of zero or more keys of the form {n}, where n is an integer starting at 1. Therefore, the first parameter replaces all occurrences of "{1}", the second parameter replaces all occurrences of "{2}", etc.

If any parameter is null, the corresponding key is replaced with the string "null". Therefore, consider using an empty string when keys are to be removed altogether.

If there are no parameters, this method does nothing and returns the supplied pattern as is.

Parameters:
pattern - the pattern
parameters - the parameters used to replace keys
Returns:
the string with all keys replaced (or removed)

createString

public static String createString(char charToRepeat,
                                  int numberOfRepeats)
Create a new string containing the specified character repeated a specific number of times.

Parameters:
charToRepeat - the character to repeat
numberOfRepeats - the number of times the character is to repeat in the result; must be greater than 0
Returns:
the resulting string


Copyright © 2008-2010 JBoss, a division of Red Hat. All Rights Reserved.