de.smartics.util.lang
Class StringFunction

java.lang.Object
  extended by de.smartics.util.lang.StringFunction

public final class StringFunction
     
     
extends Object

A collection of useful string functions.


Method Summary
static String chop(StringBuilder buffer)
          Chops off the last character of the buffer and returns the string value of the modified buffer.
static boolean isLastChar(String string, char ch)
          Checks if the last character of the given string matches the given ch.
static String strip(String string)
          Replaces all consecutive white spaces by one space and removes white spaces from the start and end of the string.
static String toHyphenVersion(String camelCasedString)
          Returns the camelCasedString in a hyphen version.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

chop

public static String chop(StringBuilder buffer)
Chops off the last character of the buffer and returns the string value of the modified buffer.

Removes the last character if the buffer has at least one character. Returns the value as passed in otherwise.

Parameters:
buffer - the buffer to chop.
Returns:
the content of the buffer except the last character.

toHyphenVersion

public static String toHyphenVersion(String camelCasedString)
Returns the camelCasedString in a hyphen version.

Each upper case letter is replaces by a dash and the lower case letter.

 thisIsACamleCaseExample -> this-is-a-camle-case-example
 

Parameters:
camelCasedString - the input string.
Returns:
the hyphen version or null if null is passed as an argument.

isLastChar

public static boolean isLastChar(String string,
                                 char ch)
Checks if the last character of the given string matches the given ch.

Parameters:
string - the string to test.
ch - the expected last character of string.
Returns:
true if ch matches the last character of string, false otherwise.

strip

public static String strip(String string)
Replaces all consecutive white spaces by one space and removes white spaces from the start and end of the string.

Parameters:
string - the string to strip.
Returns:
the stripped string.


Copyright © 2011–2013 smartics. All rights reserved.