net.sf.xbus.base.core.strings
Class XStringSupport

java.lang.Object
  extended by net.sf.xbus.base.core.strings.XStringSupport

public class XStringSupport
extends java.lang.Object

XStringSupportis a collection of helpful methods concerning string handling.

Author:
Stephan Düwel

Constructor Summary
XStringSupport()
           
 
Method Summary
static java.lang.String getNumberString(int number, int length)
          getNumberString constructs a string out of an integer value.
static java.lang.String replaceAll(java.lang.String text, java.lang.String marker, java.lang.String replacement)
          Replaces all occurences of marker in text with replacement.
static java.lang.String replaceFirst(java.lang.String text, java.lang.String marker, java.lang.String replacement, int fromPosition)
           
static java.lang.String successorUsualChars(java.lang.String s, boolean lengthFix)
          successorUsualChars computes the successor string in lexicographic order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XStringSupport

public XStringSupport()
Method Detail

getNumberString

public static java.lang.String getNumberString(int number,
                                               int length)
getNumberString constructs a string out of an integer value. The number representation is decimal. The string is filled with leading zeros to reach a specified length. In case of negative values, the zeros are inserted between the minus sign and the number.

Parameters:
number - the integer value to be represented as a string
length - the desired length of the string representation
Returns:
the string representation of number

successorUsualChars

public static java.lang.String successorUsualChars(java.lang.String s,
                                                   boolean lengthFix)
successorUsualChars computes the successor string in lexicographic order. The method set only characters with ASCII codes between 32 and 126 to ensure that they can be properly displayed. The successor of other characters is ' ' (ASCII 32).

Parameters:
s - the predecessor string
lengthFix - if set to true, the string length is never augmented, in case of an overflow the blank string will be returned
Returns:
the successor string (obeying the described constraints)

replaceAll

public static java.lang.String replaceAll(java.lang.String text,
                                          java.lang.String marker,
                                          java.lang.String replacement)
Replaces all occurences of marker in text with replacement.

Example:
before:   Input_DEALERNUMBER_WILDCARD.xml
after:    Input_12345_parts.xml

Parameters:
text - text which all occurences of marker must be replaced
marker - text marker to be replaced
replacement - replaced text

replaceFirst

public static java.lang.String replaceFirst(java.lang.String text,
                                            java.lang.String marker,
                                            java.lang.String replacement,
                                            int fromPosition)