|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjcreek.cke.util.TextUtilities
Contains some basic text utilities that could be very handy in certain situations.
Constructor Summary | |
TextUtilities()
|
Method Summary | |
static int |
findSubStringEndPos(java.lang.StringBuffer rawText,
int startPos,
java.lang.String subString,
boolean ignoreCase)
Similar to findSubStringFromToPos, but returns only the ending position. |
static int[] |
findSubStringFromToPos(java.lang.StringBuffer rawText,
int startPos,
java.lang.String startPattern,
java.lang.String endPattern,
boolean ignoreCase,
boolean includePatterns)
This method tries to find the start and end of a substring, by specifying the content of the start and end of the substring. |
static int |
findSubStringStartPos(java.lang.StringBuffer rawText,
int startPos,
java.lang.String subString,
boolean ignoreCase)
Similar to findSubStringFromToPos, but returns only the starting position. |
protected static boolean |
isIgnorableChar(char chr)
Checks if the specified character is an ignorable character. |
static java.lang.String |
replaceMatch(java.lang.String pattern,
java.lang.String txt,
java.lang.String substitute,
boolean caseDependent)
Replaces a matching regular expression pattern with a substitute text |
static java.lang.String |
stripHTML(java.lang.String html)
Strips a HTML file for it's HTML tags by using regular expressions. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TextUtilities()
Method Detail |
public static java.lang.String replaceMatch(java.lang.String pattern, java.lang.String txt, java.lang.String substitute, boolean caseDependent) throws java.lang.Exception
pattern
- the regular expression pattern to matchtxt
- the text that should be searched and replaced withinsubstitute
- the text that should replace the matching text foundcaseDependent
- set to true if the matching against the specified pattern
should be case dependent, or set to false if it should be case independent
java.lang.Exception
- if a pattern failure occurspublic static java.lang.String stripHTML(java.lang.String html) throws java.lang.Exception
html
- the HTML document to strip for HTML tags
java.lang.Exception
- if an pattern failure occurspublic static int[] findSubStringFromToPos(java.lang.StringBuffer rawText, int startPos, java.lang.String startPattern, java.lang.String endPattern, boolean ignoreCase, boolean includePatterns)
Note, that this algorithm is a very simple one, and it should perhaps be using regular expression for the string to match ot make it more robust.
rawText
- the text to performe the serach withinstartPos
- the starting position for where in the rawText the
search should beginstartPattern
- a string containing the text to match which should
be the start of the substringendPattern
- a string containing the text to match which should
be the end of the substringignoreCase
- set to true if the matching against the specified pattern
should be case dependent, or set to false if it should be case independentincludePatterns
- set to true if the patterns should be included
in the result.
public static int findSubStringEndPos(java.lang.StringBuffer rawText, int startPos, java.lang.String subString, boolean ignoreCase)
rawText
- the text to performe the serach withinstartPos
- the starting position for where in the rawText the
search should beginsubString
- a string containing the text to matchignoreCase
- set to true if the matching against the specified pattern
should be case dependent, or set to false if it should be case independent
public static int findSubStringStartPos(java.lang.StringBuffer rawText, int startPos, java.lang.String subString, boolean ignoreCase)
rawText
- the text to performe the serach withinstartPos
- the starting position for where in the rawText the
search should beginsubString
- a string containing the text to matchignoreCase
- set to true if the matching against the specified pattern
should be case dependent, or set to false if it should be case independent
protected static boolean isIgnorableChar(char chr)
chr
- the character to check
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |