org.jpox.util
Class StringUtils

java.lang.Object
  extended byorg.jpox.util.StringUtils

public class StringUtils
extends java.lang.Object

Utilities for String manipulation.

Version:
$Revision: 1.9 $

Constructor Summary
StringUtils()
           
 
Method Summary
static boolean areStringsEqual(java.lang.String str1, java.lang.String str2)
          Utility to tell if two strings are the same.
static java.lang.String booleanArrayToString(boolean[] ba)
          Utility to convert a boolean[] to a String.
static java.lang.String collectionToString(java.util.Collection coll)
          Converts the given collection of objects to string as a comma-separated list.
static int getIntValueForProperty(java.util.Properties props, java.lang.String propName, int defaultValue)
          Convenience method to extract an integer property value from a Properties file.
static java.lang.String intArrayToString(int[] ia)
          Utility to convert an int[] to a String.
static boolean isEmpty(java.lang.String s)
          check string is null or length is 0.
static boolean isValidJavaIdentifierForJDOQL(java.lang.String s)
          Utility to check if a name is a valid Java identifier.
static boolean isWhitespace(java.lang.String str)
          Utility to check if a string is whitespace.
static java.lang.String jdoFlagsToString(byte flags)
          Utility to convert JDO specific flags to a String.
static java.lang.String leftAlignedPaddedString(java.lang.String input, int length)
          Utility to return a left-aligned version of a string padded to the number of characters specified.
static boolean notEmpty(java.lang.String s)
          check string isnot null and length > 0.
static java.lang.String objectArrayToString(java.lang.Object[] arr)
          Utility to convert an Object[] to a String.
static java.lang.String replaceAll(java.lang.String theString, java.lang.String toReplace, java.lang.String replacement)
          Replaces each substring of this string that matches toReplace.
static java.lang.String rightAlignedPaddedString(java.lang.String input, int length)
          Utility to return a right-aligned version of a string padded to the number of characters specified.
static java.lang.String[] split(java.lang.String valuesString, java.lang.String token)
          Splits a list of values separated by a token
static java.lang.String toJVMIDString(java.lang.Object obj)
          Utility to convert an object to a JVM type string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringUtils

public StringUtils()
Method Detail

replaceAll

public static java.lang.String replaceAll(java.lang.String theString,
                                          java.lang.String toReplace,
                                          java.lang.String replacement)
Replaces each substring of this string that matches toReplace. Used to replace replaceAll when using J2SDK 1.3.1. This method is available at String.replaceAll in J2SDK 1.4

Parameters:
theString - The string to use
toReplace - The string to replace.
replacement - The replacement string.
Returns:
The updated string after replacing.

isWhitespace

public static boolean isWhitespace(java.lang.String str)
Utility to check if a string is whitespace. If the string is null, returns true also.

Parameters:
str - The string to check
Returns:
Whether the string is just whitespace

areStringsEqual

public static boolean areStringsEqual(java.lang.String str1,
                                      java.lang.String str2)
Utility to tell if two strings are the same. Extends the basic String 'equals' method by allowing for nulls.

Parameters:
str1 - The first string
str2 - The second string
Returns:
Whether the strings are equal.

leftAlignedPaddedString

public static java.lang.String leftAlignedPaddedString(java.lang.String input,
                                                       int length)
Utility to return a left-aligned version of a string padded to the number of characters specified.

Parameters:
input - The input string
length - The length desired
Returns:
The updated string

rightAlignedPaddedString

public static java.lang.String rightAlignedPaddedString(java.lang.String input,
                                                        int length)
Utility to return a right-aligned version of a string padded to the number of characters specified.

Parameters:
input - The input string
length - The length desired
Returns:
The updated string

split

public static java.lang.String[] split(java.lang.String valuesString,
                                       java.lang.String token)
Splits a list of values separated by a token

Parameters:
valuesString - the text to be splited
token - the token
Returns:
an array with all values

toJVMIDString

public static java.lang.String toJVMIDString(java.lang.Object obj)
Utility to convert an object to a JVM type string.

Parameters:
obj - The object
Returns:
The String version

booleanArrayToString

public static java.lang.String booleanArrayToString(boolean[] ba)
Utility to convert a boolean[] to a String.

Parameters:
ba - The boolean[]
Returns:
String version

intArrayToString

public static java.lang.String intArrayToString(int[] ia)
Utility to convert an int[] to a String.

Parameters:
ia - The int[]
Returns:
String version

objectArrayToString

public static java.lang.String objectArrayToString(java.lang.Object[] arr)
Utility to convert an Object[] to a String.

Parameters:
arr - The Object[]
Returns:
String version

collectionToString

public static java.lang.String collectionToString(java.util.Collection coll)
Converts the given collection of objects to string as a comma-separated list. If the list is empty the string "<none>" is returned.

Parameters:
coll - collection of objects to be converted
Returns:
A string containing each object in the given collection, converted toString() and separated by commas.

jdoFlagsToString

public static java.lang.String jdoFlagsToString(byte flags)
Utility to convert JDO specific flags to a String.

Parameters:
flags - The JDO flags
Returns:
String version

isValidJavaIdentifierForJDOQL

public static boolean isValidJavaIdentifierForJDOQL(java.lang.String s)
Utility to check if a name is a valid Java identifier. Used by JDOQL in validating the names of parameters/variables.

Parameters:
s - The name
Returns:
Whether it is a valid identifier in Java.

getIntValueForProperty

public static int getIntValueForProperty(java.util.Properties props,
                                         java.lang.String propName,
                                         int defaultValue)
Convenience method to extract an integer property value from a Properties file.

Parameters:
props - The Properties
propName - Name of the property
defaultValue - The default value to use (in case not specified)
Returns:
The value

isEmpty

public static boolean isEmpty(java.lang.String s)
check string is null or length is 0.

Parameters:
s - check string
Returns:
return true if string is null or length is 0. return false other case.

notEmpty

public static boolean notEmpty(java.lang.String s)
check string isnot null and length > 0.

Parameters:
s - check string
Returns:
return true if string isnot null and length greater than 0. return false other case.


Copyright © -2007 . All Rights Reserved.