|
org.netbeans.modules.jellytools.platform/3 3.13 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.netbeans.jellytools.util.StringFilter
public class StringFilter
Filters string, you can simple use replaceString() method or create string filter for more sophisticated filtering.
Usage:
StringFilter sf = new StringFilter();
// remove 1st comment
sf.addReplaceFilter("/*", "*/", "");
// replace all multiple spaces
sf.addReplaceAllFilter(" ", " ");
// change author name
sf.addReplaceFilter("author: ", "", "author: spl@sun.com");
String string = "/* comment */ 4s 2s 3s author: xxx@sun.com";
String result = sf.filter(string);
replaceString(String original, String begin, String end, String replace)| Constructor Summary | |
|---|---|
StringFilter()
|
|
| Method Summary | |
|---|---|
void |
addReplaceAllFilter(String find,
String replace)
Adds replace pattern into Filter. |
void |
addReplaceFilter(String begin,
String end,
String replace)
Adds replace pattern into Filter. |
String |
filter(String str)
Filters string. |
void |
filterLinesToStream(String input,
PrintStream output)
Filters input string to a PrintStream. |
static String |
replaceString(String original,
String begin,
String end,
String replace)
Finds substring which starts with first occurrence of 'begin' and ends with nearest next occurrence of 'end' and replces it with 'replace '. |
static String |
replaceStringAll(String original,
String find,
String replace)
Finds and replace all substrings. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StringFilter()
| Method Detail |
|---|
public void addReplaceFilter(String begin,
String end,
String replace)
begin - the begin of substring to be findend - the end of substring to be findreplace - text to replacereplaceString(String original, String begin, String end, String replace )
public void addReplaceAllFilter(String find,
String replace)
find - text to findreplace - text to replacereplaceString(String original, String begin, String end, String replace )public String filter(String str)
str - text to filter
public static String replaceString(String original,
String begin,
String end,
String replace)
Usage:
replaceString("a-bcd-ef", "b", "d", "") => a--ef
replaceString("abc-def", "", "c", "") => -def
replaceString("ab-cdef", "c", "", "") => ab-
replaceString("ab-cdef-ab", "ab", "ab", "AB") => AB-cdef-AB
replaceString("abcdef", "", "", "AB") => abcdef
replace - text to replaceoriginal - the original stringbegin - the begin of substring to be findend - the end of substring to be find
public static String replaceStringAll(String original,
String find,
String replace)
original - the original stringfind - text to findreplace - text to replace
replaceString(String original, String begin, String end, String replace)
public void filterLinesToStream(String input,
PrintStream output)
input - string to be filteredoutput - stream to write results in
|
org.netbeans.modules.jellytools.platform/3 3.13 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||