org.openrdf.util
Class StringUtil

java.lang.Object
  extended byorg.openrdf.util.StringUtil

public class StringUtil
extends Object


Constructor Summary
StringUtil()
           
 
Method Summary
static String gsub(String olds, String news, String text)
          Substitute String "old" by String "new" in String "text" everywhere.
static int indexOfWord(String text, String word)
          Searches for the first occurrence of a word, which must be surrounded by whitespace characters, in a text.
static int indexOfWord(String text, String word, int fromIndex)
          Searches for the first occurrence of a word, which must be surrounded by whitespace characters, that appears in a text after 'fromIndex'.
static int lastIndexOfWord(String text, String word)
          Searches for the last occurrence of a word, which must be surrounded by whitespace characters, in a text.
static int lastIndexOfWord(String text, String word, int fromIndex)
          Searches for the last occurrence of a word, which must be surrounded by whitespace characters, in a text.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringUtil

public StringUtil()
Method Detail

gsub

public static String gsub(String olds,
                          String news,
                          String text)
Substitute String "old" by String "new" in String "text" everywhere. This is static util function that I could not place anywhere more appropriate. The name of this function is from the good-old awk time.

Parameters:
olds - The String to be substituted.
news - The String is the new content.
text - The String in which the substitution is done.
Returns:
The result String containing the substitutions; if no substitutions were made, the result is 'text'.

indexOfWord

public static int indexOfWord(String text,
                              String word)
Searches for the first occurrence of a word, which must be surrounded by whitespace characters, in a text.


indexOfWord

public static int indexOfWord(String text,
                              String word,
                              int fromIndex)
Searches for the first occurrence of a word, which must be surrounded by whitespace characters, that appears in a text after 'fromIndex'.


lastIndexOfWord

public static int lastIndexOfWord(String text,
                                  String word)
Searches for the last occurrence of a word, which must be surrounded by whitespace characters, in a text.


lastIndexOfWord

public static int lastIndexOfWord(String text,
                                  String word,
                                  int fromIndex)
Searches for the last occurrence of a word, which must be surrounded by whitespace characters, in a text. The algorithm searches the text backwards, starting from 'fromIndex'.



Copyright © 2002-2006 Aduna BV, GNU LGPL License applies.