org.rimudb.editor.util
Class StringUtil

java.lang.Object
  extended by org.rimudb.editor.util.StringUtil

public class StringUtil
extends java.lang.Object


Field Summary
static java.lang.String SC_LOWER
           
static java.lang.String SC_PROPER
           
static java.lang.String SC_SENTENCE
           
static java.lang.String SC_TITLE
           
static java.lang.String SC_UPPER
           
 
Method Summary
static java.lang.String leftJustify(java.lang.String s, int maxLength)
          Left justify a string, and fill to a given length with the blanks.
static java.lang.String leftJustify(java.lang.String s, int maxLength, char fill)
          Left justify a string, and fill to a given length with the character fill.
static java.lang.String replace(java.lang.String text, java.lang.String oldSubstring, java.lang.String newSubstring)
          Replace the first occurrence of oldSubstring in text, if there is one, with newSubstring.
static java.lang.String replaceAll(java.lang.String text, java.lang.String oldSubstring, java.lang.String newSubstring)
          Replaces all occurrences of oldSubstring in text, if there are any, with newSubstring.
static java.lang.String rightJustify(java.lang.String s, int maxLength)
          Right justify a string using blanks to pad the left part of the string until it reaches maxLength.
static java.lang.String rightJustify(java.lang.String s, int maxLength, char fill)
          Right justify a string using the specified padding character to pad the left part of the string until it reaches maxLength.
static java.lang.String toProperCase(java.lang.String s)
          Convert the String s to proper case.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SC_LOWER

public static final java.lang.String SC_LOWER
See Also:
Constant Field Values

SC_UPPER

public static final java.lang.String SC_UPPER
See Also:
Constant Field Values

SC_SENTENCE

public static final java.lang.String SC_SENTENCE
See Also:
Constant Field Values

SC_TITLE

public static final java.lang.String SC_TITLE
See Also:
Constant Field Values

SC_PROPER

public static final java.lang.String SC_PROPER
See Also:
Constant Field Values
Method Detail

rightJustify

public static java.lang.String rightJustify(java.lang.String s,
                                            int maxLength)

Right justify a string using blanks to pad the left part of the string until it reaches maxLength. If the length of the string is greater than maxLength characters, return only the first, left maxLength characters.


rightJustify

public static java.lang.String rightJustify(java.lang.String s,
                                            int maxLength,
                                            char fill)

Right justify a string using the specified padding character to pad the left part of the string until it reaches maxLength. If the length of the string is greater than maxLength characters, return only the first, left maxLength characters.

Returns:
The right-justified string.

leftJustify

public static java.lang.String leftJustify(java.lang.String s,
                                           int maxLength)
Left justify a string, and fill to a given length with the blanks. If the length of the string is greater than "maxLength" characters, return only the first, left "maxLength" characters.


leftJustify

public static java.lang.String leftJustify(java.lang.String s,
                                           int maxLength,
                                           char fill)
Left justify a string, and fill to a given length with the character fill. If the length of the string is greater than "maxLength" characters, return only the first, left "maxLength" characters.


replace

public static java.lang.String replace(java.lang.String text,
                                       java.lang.String oldSubstring,
                                       java.lang.String newSubstring)
Replace the first occurrence of oldSubstring in text, if there is one, with newSubstring.

Parameters:
text - - Replace a substring of this String
oldSubstring - - The substring of text to be replaced
newSubstring - - The string to put into text
Returns:
A new String which is a copy of text with the first occurrence of oldSubstring in text, if there is one, with newSubstring. Returns null if text is null. Returns text if either substring is null or oldSubstring is empty

replaceAll

public static java.lang.String replaceAll(java.lang.String text,
                                          java.lang.String oldSubstring,
                                          java.lang.String newSubstring)
Replaces all occurrences of oldSubstring in text, if there are any, with newSubstring.

Parameters:
text - - Replace substrings of this String
oldSubstring - - The substring of text to be replaced
newSubstring - - The string to put into text
Returns:
A new String which is a copy of text with all occurrences of oldSubstring in string, if there are any, with newSubstring. Returns null if text is null. Returns text if either substring is null or oldSubstring is empty

toProperCase

public static java.lang.String toProperCase(java.lang.String s)
Convert the String s to proper case.

Parameters:
s - String
Returns:
String


Copyright © 2008-2011 Simon Ritchie. All Rights Reserved.