net.m2technologies.open_arm.utilities
Class Strings

java.lang.Object
  extended bynet.m2technologies.open_arm.utilities.Strings

public class Strings
extends java.lang.Object

Copyright 2005 Mark Masterson

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Description:

Version:
0.009
Author:
Mark Masterson

Constructor Summary
Strings()
           
 
Method Summary
static java.lang.String convertStringArrayToString(java.lang.String[] stringArrayValue)
          Collapses a String{} into a String.
static java.lang.String[] convertStringToStringArray(java.lang.String stringValue)
          Parses a String, using a blank as default delimiter, and converts it to a String{}, where each element of the array is one of the tokens found in the delimited String.
static java.lang.String[] convertStringToStringArray(java.lang.String stringValue, java.lang.String delimiter)
          Parses a String, using the give delimiter, and converts it to a String{}, where each element of the array is one of the tokens found in the delimited String.
static int countForAllOccurencesOf(java.lang.String stringToTest, java.lang.String searchForValue)
          Searches the string passed as first parameter for all occurences of the string passed as the second one.
static boolean isNumeric(java.lang.String stringToTest)
          Determines wether the passed string is of numeric value.
static java.util.Collection parseStringToCollection(java.lang.String stringValue, java.lang.String delimiter)
          Parses a String, using the given delimiter, and adds each token thus found to a Collection.
static java.lang.String replaceAllOccurencesOf(java.lang.String stringToTest, java.lang.String stringToReplace, java.lang.String replacementValue)
          Searches the String passed as first parameter for the String passed as second parameter, and replaces that String, if found, with the String passed as third parameter.
 java.lang.String returnEmptyStringIfNull(java.lang.String stringToCheck)
          Checks if the parameter passed is a null, and if yes returns an empty string.
 java.lang.String returnNullIfEmptyString(java.lang.String stringToCheck)
          Checks the String passed as parameter, and returns a programmatic null if it is an empty string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Strings

public Strings()
Method Detail

countForAllOccurencesOf

public static int countForAllOccurencesOf(java.lang.String stringToTest,
                                          java.lang.String searchForValue)
Searches the string passed as first parameter for all occurences of the string passed as the second one.

Parameters:
stringToTest -
searchForValue -
Returns:
number of occurences

replaceAllOccurencesOf

public static java.lang.String replaceAllOccurencesOf(java.lang.String stringToTest,
                                                      java.lang.String stringToReplace,
                                                      java.lang.String replacementValue)
Searches the String passed as first parameter for the String passed as second parameter, and replaces that String, if found, with the String passed as third parameter. Will not replace two occurences of the "stringToReplace" parameter that are found directly next to each other.

Parameters:
stringToTest -
stringToReplace -
replacementValue -
Returns:
the transformed String value

convertStringArrayToString

public static final java.lang.String convertStringArrayToString(java.lang.String[] stringArrayValue)
Collapses a String{} into a String.

Parameters:
stringArrayValue -
Returns:
String

convertStringToStringArray

public static final java.lang.String[] convertStringToStringArray(java.lang.String stringValue)
Parses a String, using a blank as default delimiter, and converts it to a String{}, where each element of the array is one of the tokens found in the delimited String.

Parameters:
stringValue - -- the String to parse
Returns:
an array of Strings, where each element is a token found in the delimited String

convertStringToStringArray

public static final java.lang.String[] convertStringToStringArray(java.lang.String stringValue,
                                                                  java.lang.String delimiter)
Parses a String, using the give delimiter, and converts it to a String{}, where each element of the array is one of the tokens found in the delimited String.

Parameters:
stringValue - -- the String to parse
delimiter - -- delimiter to use in parsing the String
Returns:
an array of Strings, where each element is a token found in the delimited String

parseStringToCollection

public static final java.util.Collection parseStringToCollection(java.lang.String stringValue,
                                                                 java.lang.String delimiter)
Parses a String, using the given delimiter, and adds each token thus found to a Collection.

Parameters:
stringValue - -- the String to parse
delimiter - -- delimiter to use in parsing the Stringue
Returns:
-- a Collection, whose elements are the tokens found in the delimited String.

isNumeric

public static boolean isNumeric(java.lang.String stringToTest)
Determines wether the passed string is of numeric value.

Parameters:
stringToTest -
Returns:
true (string is of numeric value) or false (string contains at least one non-numeric character)

returnNullIfEmptyString

public java.lang.String returnNullIfEmptyString(java.lang.String stringToCheck)
Checks the String passed as parameter, and returns a programmatic null if it is an empty string. Simply returns the paramater unchanged if not an empty string.


returnEmptyStringIfNull

public java.lang.String returnEmptyStringIfNull(java.lang.String stringToCheck)
Checks if the parameter passed is a null, and if yes returns an empty string.