home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Main.bin
/
StringUtils.java
< prev
next >
Wrap
Text File
|
1998-09-08
|
6KB
|
246 lines
package com.symantec.itools.lang;
/**
* @author Symantec Internet Tools Division
* @version 1.0
* @since VCafe 3.0
*/
public class StringUtils
{
protected StringUtils()
{
throw new IllegalInstantiationError(StringUtils.class);
}
/**
* @param str1 TODO
* @param str2 TODO
* @since VCafe 3.0
*/
public static int compareToIgnoreCase(String str1, String str2)
{
return (str1.toLowerCase().compareTo(str2.toLowerCase()));
}
/**
* @param str TODO
* @param suffix TODO
* @since VCafe 3.0
*/
public static boolean endsWithIgnoreCase(String str, String suffix)
{
return (str.toLowerCase().endsWith(suffix.toLowerCase()));
}
/**
* @param str TODO
* @param find TODO
* @since VCafe 3.0
*/
public static int indexOfIgnoreCase(String str, int find)
{
return (str.toLowerCase().indexOf(Character.toLowerCase((char)find)));
}
/**
* @param str TODO
* @param find TODO
* @param start TODO
* @since VCafe 3.0
*/
public static int indexOfIgnoreCase(String str, int find, int start)
{
return (str.toLowerCase().indexOf(Character.toLowerCase((char)find), start));
}
/**
* @param str TODO
* @param find TODO
* @since VCafe 3.0
*/
public static int indexOfIgnoreCase(String str, String find)
{
return (str.toLowerCase().indexOf(find.toLowerCase()));
}
/**
* @param str TODO
* @param find TODO
* @param start TODO
* @since VCafe 3.0
*/
public static int indexOfIgnoreCase(String str, String find, int start)
{
return (str.toLowerCase().indexOf(find.toLowerCase(), start));
}
/**
* @param str TODO
* @param find TODO
* @since VCafe 3.0
*/
public static int lastIndexOfIgnoreCase(String str, int find)
{
return (str.toLowerCase().lastIndexOf(Character.toLowerCase((char)find)));
}
/**
* @param str TODO
* @param find TODO
* @param start TODO
* @since VCafe 3.0
*/
public static int lastIndexOfIgnoreCase(String str, int find, int start)
{
return (str.toLowerCase().lastIndexOf(Character.toLowerCase((char)find), start));
}
/**
* @param str TODO
* @param find TODO
* @since VCafe 3.0
*/
public static int lastIndexOfIgnoreCase(String str, String find)
{
return (str.toLowerCase().lastIndexOf(find.toLowerCase()));
}
/**
* @param str TODO
* @param find TODO
* @param start TODO
* @since VCafe 3.0
*/
public static int lastIndexOfIgnoreCase(String str, String find, int start)
{
return (str.toLowerCase().lastIndexOf(find.toLowerCase(), start));
}
/**
* @param str TODO
* @param ch TODO
* @since VCafe 3.0
*/
public static int occurencesOf(String str, char ch)
{
char[] s;
int count;
s = new char[str.length()];
str.getChars(0, s.length, s, 0);
count = 0;
for(int i = 0; i < s.length; i++)
{
if(s[i] == ch)
{
count++;
}
}
return (count);
}
/**
* @param str TODO
* @param ch TODO
* @since VCafe 3.0
*/
public static int occurencesOfIgnoreCase(String str, char ch)
{
return (occurencesOf(str.toLowerCase(), Character.toLowerCase(ch)));
}
/**
* @param str TODO
* @param oldChars TODO
* @param newChars TODO
* @since VCafe 3.0
*/
public static String replace(String str, String oldChars, String newChars)
{
int pos;
pos = str.indexOf(oldChars);
while(pos > -1)
{
String firstPart;
String lastPart;
firstPart = str.substring(0, pos);
lastPart = str.substring(pos + oldChars.length(), str.length());
str = firstPart + newChars + lastPart;
pos = str.indexOf(oldChars);
}
return (str);
}
/**
* @param str TODO
* @param oldChars TODO
* @param newChars TODO
* @since VCafe 3.0
*/
public static String replaceIgnoreCase(String str, String oldChars, String newChars)
{
String lowerStr;
int pos;
lowerStr = str.toLowerCase();
pos = lowerStr.indexOf(oldChars);
while(pos > -1)
{
String firstPart;
String lastPart;
firstPart = str.substring(0, pos);
lastPart = str.substring(pos + oldChars.length(), str.length());
str = firstPart + newChars + lastPart;
pos = lowerStr.indexOf(oldChars);
}
return (str);
}
/**
* @param str TODO
* @param prefix TODO
* @since VCafe 3.0
*/
public static boolean startsWithIgnoreCase(String str, String prefix)
{
return (str.toLowerCase().startsWith(prefix.toLowerCase()));
}
/**
* @param str TODO
* @param prefix TODO
* @param start TODO
* @since VCafe 3.0
*/
public static boolean startsWithIgnoreCase(String str, String prefix, int start)
{
return (str.toLowerCase().startsWith(prefix.toLowerCase(), start));
}
}