Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Runtime

org.eclipse.gmf.runtime.common.core.util
Class StringUtil

java.lang.Object
  extended by 
org.eclipse.gmf.runtime.common.core.util.StringUtil

public class StringUtil
extends java.lang.Object

In JDK 1.3 we don't have the luxury of replaceAll as in JDK 1.4. The replace methods from this string class are intended to be used until JDK 1.4 is used. For completely different implementations of the replace methods, please see https://forum.java.sun.com/thread.jsp?forum=31&thread=284142&message=1109785 Replacing a whole word is completely different from replacing all instances. To avoid confusion, the method names are different too.


Method Summary
static boolean doesWordExist (java.lang.String string, java.lang.String source, boolean caseSensitive)
          Returns if a substring was found as a whole word in a string.
static java.lang.String encodeURL (java.lang.String url)
          Encode the url string
static boolean isValidPositiveInteger (java.lang.String string)
          Do not use Integer.parseInt().
static java.lang.String replace (java.lang.String string, java.lang.String source, java.lang.String dest, boolean caseSensitive)
          Replace the first instance of part of a string with another string.
static java.lang.String replaceAll (java.lang.String string, java.lang.String source, java.lang.String dest, boolean caseSensitive)
          Replace all instances of part of a string with another string
static java.lang.String replaceAllWholeWords (java.lang.String string, java.lang.String source, java.lang.String dest, boolean caseSensitive)
          Replaces whole words found in one string with another string.
static java.lang.String replaceWholeWords (java.lang.String string, java.lang.String source, java.lang.String dest, boolean caseSensitive)
          Replaces whole words found in one string with another string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

replace

public static java.lang.String replace(java.lang.String string,
                                       java.lang.String source,
                                       java.lang.String dest,
                                       boolean caseSensitive)
Replace the first instance of part of a string with another string.

Parameters:
string - is the string that contains the substring to be replaced
source - is the substring that will be replaced if it is found in the string
dest - what the substring will be replaced with if it is found in the string
caseSensitive - true to do a case sensitive search, false to do a case insensitive search
Returns:
the string containing the first instance of source replaced with dest

replaceAll

public static java.lang.String replaceAll(java.lang.String string,
                                          java.lang.String source,
                                          java.lang.String dest,
                                          boolean caseSensitive)
Replace all instances of part of a string with another string

Parameters:
string - is the string that contains the substring to be replaced
source - is the substring that will be replaced if it is found in the string
dest - what the substring will be replaced with if it is found in the string
caseSensitive - true to do a case sensitive search, false to do a case insensitive search
Returns:
the string containing all instances of source replaced with dest

replaceWholeWords

public static java.lang.String replaceWholeWords(java.lang.String string,
                                                 java.lang.String source,
                                                 java.lang.String dest,
                                                 boolean caseSensitive)
Replaces whole words found in one string with another string. The whole words are delimted by delimiters defined in the DELIMTERES constant.

Parameters:
string - is the string that contains the substring to be replaced
source - is the substring that will be replaced if it is found in the string
dest - what the substring will be replaced with if it is found in the string
caseSensitive - true to do a case sensitive search, false to do a case insensitive search
Returns:
the string containing the first instance of source replaced with dest.

replaceAllWholeWords

public static java.lang.String replaceAllWholeWords(java.lang.String string,
                                                    java.lang.String source,
                                                    java.lang.String dest,
                                                    boolean caseSensitive)
Replaces whole words found in one string with another string. The whole words are delimted by delimiters defined in the DELIMTERES constant.

Parameters:
string - is the string that contains the substring to be replaced
source - is the substring that will be replaced if it is found in the string
dest - what the substring will be replaced with if it is found in the string
caseSensitive - true to do a case sensitive search, false to do a case insensitive search
Returns:
the string containing all instances of source replaced with dest.

doesWordExist

public static boolean doesWordExist(java.lang.String string,
                                    java.lang.String source,
                                    boolean caseSensitive)
Returns if a substring was found as a whole word in a string. The whole words are delimted by delimiters defined in the DELIMTERES constant.

Parameters:
string - is the string that contains the substring to be replaced
source - is the substring that we are checking for in string
caseSensitive - true to do a case sensitive search, false to do a case insensitive search
Returns:
boolean true if the string was found as a word, false if the string was not found as a word.

isValidPositiveInteger

public static boolean isValidPositiveInteger(java.lang.String string)
Do not use Integer.parseInt(). This is doing something different. Based on code from Gleb's SetMultiplicityDialog.

Parameters:
string - to check if it is a valid positive integer
Returns:
true if it's a valid positive integer, false if it isn't

encodeURL

public static java.lang.String encodeURL(java.lang.String url)
Encode the url string

Parameters:
url - String to encode
Returns:
String encoded URL

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire