org.kde.koala
public class KStringHandler extends Object implements QtSupport
KStringHandler kstr; String line = "This is a test of the strings"; cout << "1> " << kstr.word( line , "4:" ) << "\n"; cout << "2> " << kstr.remrange( line , "2:5" ) << "\n"; cout << "2> " << kstr.reverse( line ) << "\n"; cout << "2> " << kstr.center( kstr.word( line , 4 ) , 15 ) << "\n";and so forth.
See Also: KShell
UNKNOWN: Class for manipulating words and sentences in strings.
Constructor Summary | |
---|---|
protected | KStringHandler(Class dummy) |
KStringHandler() |
Method Summary | |
---|---|
static String | capwords(String text) Capitalizes each word in the string
"hello there" becomes "Hello There" (string) |
static ArrayList | capwords(String[] list) Capitalizes each word in the list
[hello, there] becomes [Hello, There] (list) |
static String | center(String text, int width) Centers a string and returns a string at least 'width' characters
wide.
|
static String | cEmSqueeze(String name, QFontMetrics fontMetrics, int maxlen) Substitute characters in the middle of a string by "...". |
static String | cEmSqueeze(String name, QFontMetrics fontMetrics) |
static String | cPixelSqueeze(String name, QFontMetrics fontMetrics, int maxPixels) Substitute characters in the middle of a string by "...". |
static String | csqueeze(String str, int maxlen) Substitute characters at the middle of a string by "...". |
static String | csqueeze(String str) |
void | dispose() Delete the wrapped C++ instance ahead of finalize() |
protected void | finalize() Deletes the wrapped C++ instance |
static String | from8Bit(String str)
Construct String from a c string, guessing whether it is UTF8- or
Local8Bit-encoded. |
static String | insword(String text, String word, int pos) Inserts a word into the string, and returns
a new string with the word included. the first
index is zero (0). |
boolean | isDisposed() Has the wrapped C++ instance been deleted? |
static boolean | isUtf8(String str)
Guess whether a string is UTF8 encoded. |
static String | lEmSqueeze(String name, QFontMetrics fontMetrics, int maxlen) Substitute characters at the beginning of a string by "...". |
static String | lEmSqueeze(String name, QFontMetrics fontMetrics) |
static String | lPixelSqueeze(String name, QFontMetrics fontMetrics, int maxPixels) Substitute characters at the beginning of a string by "...". |
static String | lsqueeze(String str, int maxlen) Substitute characters at the beginning of a string by "...". |
static String | lsqueeze(String str) |
static boolean | matchFileName(String filename, String pattern)
Match a filename. |
static String | obscure(String str)
Obscure string by using a simple symmetric encryption. |
static ArrayList | perlSplit(String sep, String s, int max)
Split a String into an ArrayList in a similar fashion to the static
ArrayList function in Qt, except you can specify a maximum number
of tokens. |
static ArrayList | perlSplit(String sep, String s) |
static ArrayList | perlSplit(char sep, String s, int max)
Split a String into an ArrayList in a similar fashion to the static
ArrayList function in Qt, except you can specify a maximum number
of tokens. |
static ArrayList | perlSplit(char sep, String s) |
static ArrayList | perlSplit(QRegExp sep, String s, int max)
Split a String into an ArrayList in a similar fashion to the static
ArrayList function in Qt, except you can specify a maximum number
of tokens. |
static ArrayList | perlSplit(QRegExp sep, String s) |
static String | remrange(String text, String range) Removes a word or ranges of words from the string,
and returns a new string. |
static String | remword(String text, int pos) Removes a word at the given index, and returns a
new string. |
static String | remword(String text, String word) Removes a matching word from the string, and returns
a new string. |
static String | reverse(String text) Reverses the order of the words in a string
"hello there" becomes "there hello" (string) |
static ArrayList | reverse(String[] list) Reverses the order of the words in a list
[hello, there] becomes [there, hello] (list) |
static String | rEmSqueeze(String name, QFontMetrics fontMetrics, int maxlen) Substitute characters at the end of a string by "...". |
static String | rEmSqueeze(String name, QFontMetrics fontMetrics) |
static String | rPixelSqueeze(String name, QFontMetrics fontMetrics, int maxPixels) Substitute characters at the end of a string by "...". |
static String | rsqueeze(String str, int maxlen) Substitute characters at the end of a string by "...". |
static String | rsqueeze(String str) |
static String | setword(String text, String word, int pos) Replaces a word in the string, and returns
a new string with the word included. the first
index is zero (0). |
static String | tagURLs(String text)
This method auto-detects URLs in strings, and adds HTML markup to them
so that richtext or HTML-enabled widgets (such as KActiveLabel)
will display the URL correctly. |
static String | word(String text, String range) Returns a range of words from that string.
|
Parameters: text the text to capitalize
Returns: the resulting string
UNKNOWN: Capitalizes each word in the string "hello there" becomes "Hello There" (string)
Parameters: list the list to capitalize
Returns: the resulting list
UNKNOWN: Capitalizes each word in the list [hello, there] becomes [Hello, There] (list)
width
, the original
string is returned. It is never truncated.Parameters: text the text to justify width the desired width of the new string
Returns: the resulting string
UNKNOWN: Centers a string and returns a string at least 'width' characters wide.
Parameters: name is the string to modify fontMetrics is the font metrics to use to calculate character sizes maxlen is the maximum length in ems the modified string will have If the original string is shorter than "maxlen", it is returned verbatim
Returns: the modified string
UNKNOWN: Substitute characters in the middle of a string by ".
Parameters: name is the string to modify fontMetrics is the font metrics to use to calculate character sizes maxPixels is the maximum pixel length the modified string will have If the original string is shorter than "maxlen", it is returned verbatim
Returns: the modified string
UNKNOWN: Substitute characters in the middle of a string by ".
Parameters: str is the string to modify maxlen is the maximum length the modified string will have If the original string is shorter than "maxlen", it is returned verbatim
Returns: the modified string
UNKNOWN: Substitute characters at the middle of a string by ".
Parameters: str the input string
Returns: the (hopefully correctly guessed) String representation of str
UNKNOWN: Construct String from a c string, guessing whether it is UTF8- or Local8Bit-encoded.
pos
words in the original
string, the new word will be appended to the end.Parameters: text the original text word the word to insert pos the position (in words) for the new word
Returns: the resulting string
UNKNOWN: Inserts a word into the string, and returns a new string with the word included.
Parameters: str the string to check
Returns: true if UTF8. If false, the string is probably in Local8Bit.
UNKNOWN: Guess whether a string is UTF8 encoded.
Parameters: name is the string to modify fontMetrics is the font metrics to use to calculate character sizes maxlen is the maximum length in ems the modified string will have If the original string is shorter than "maxlen", it is returned verbatim
Returns: the modified string
UNKNOWN: Substitute characters at the beginning of a string by ".
Parameters: name is the string to modify fontMetrics is the font metrics to use to calculate character sizes maxPixels is the maximum pixel length the modified string will have If the original string is shorter than "maxlen", it is returned verbatim
Returns: the modified string
UNKNOWN: Substitute characters at the beginning of a string by ".
Parameters: str is the string to modify maxlen is the maximum length the modified string will have If the original string is shorter than "maxlen", it is returned verbatim
Returns: the modified string
UNKNOWN: Substitute characters at the beginning of a string by ".
Parameters: filename is the real decoded filename (or dirname without trailing '/'). pattern is a pattern like .txt, .tar.gz, Makefile., README, etc. Patterns with two asterisks like "*.pk" are not supported.
Returns: true if the given filename matches the given pattern
UNKNOWN: Match a filename.
Parameters: str string to be obscured
Returns: obscured string
UNKNOWN: Obscure string by using a simple symmetric encryption.
perlSplit("__", "some__string__for__you__here", 4) ArrayList contains: "some", "string", "for", "you__here"
Parameters: sep is the string to use to delimit s. s is the input string max is the maximum number of extractions to perform, or 0.
Returns: An ArrayList containing tokens extracted from s.
UNKNOWN: Split a String into an ArrayList in a similar fashion to the static ArrayList function in Qt, except you can specify a maximum number of tokens.
perlSplit(' ', "kparts reaches the parts other parts can't", 3) ArrayList contains: "kparts", "reaches", "the parts other parts can't"
Parameters: sep is the character to use to delimit s. s is the input string max is the maximum number of extractions to perform, or 0.
Returns: An ArrayList containing tokens extracted from s.
UNKNOWN: Split a String into an ArrayList in a similar fashion to the static ArrayList function in Qt, except you can specify a maximum number of tokens.
perlSplit(QRegExp("[! ]", "Split me up ! I'm bored ! OK ?", 3) ArrayList contains: "Split", "me", "up ! I'm bored, OK ?"
Parameters: sep is the regular expression to use to delimit s. s is the input string max is the maximum number of extractions to perform, or 0.
Returns: An ArrayList containing tokens extracted from s.
UNKNOWN: Split a String into an ArrayList in a similar fashion to the static ArrayList function in Qt, except you can specify a maximum number of tokens.
Parameters: text the original text range the words to remove (see description)
Returns: the resulting string
UNKNOWN: Removes a word or ranges of words from the string, and returns a new string.
Parameters: text the original text pos the position (in words) of thw word to delete
Returns: the resulting string
UNKNOWN: Removes a word at the given index, and returns a new string.
Parameters: text the original text word the word to remove
Returns: the resulting string
UNKNOWN: Removes a matching word from the string, and returns a new string.
Parameters: text the text to reverse
Returns: the resulting string
UNKNOWN: Reverses the order of the words in a string "hello there" becomes "there hello" (string)
Parameters: list the list to reverse
Returns: the resulting list
UNKNOWN: Reverses the order of the words in a list [hello, there] becomes [there, hello] (list)
Parameters: name is the string to modify fontMetrics is the font metrics to use to calculate character sizes maxlen is the maximum length in ems the modified string will have If the original string is shorter than "maxlen", it is returned verbatim
Returns: the modified string
UNKNOWN: Substitute characters at the end of a string by ".
Parameters: name is the string to modify fontMetrics is the font metrics to use to calculate character sizes maxPixels is the maximum pixel length the modified string will have If the original string is shorter than "maxlen", it is returned verbatim
Returns: the modified string
UNKNOWN: Substitute characters at the end of a string by ".
Parameters: str is the string to modify maxlen is the maximum length the modified string will have If the original string is shorter than "maxlen", it is returned verbatim
Returns: the modified string
UNKNOWN: Substitute characters at the end of a string by ".
pos
words in the original
string, the new word will be appended to the end.Parameters: text the original text word the word to insert pos the position (in words) for the new word
Returns: the resulting string
UNKNOWN: Replaces a word in the string, and returns a new string with the word included.
Parameters: text the string which may contain URLs
Returns: the resulting text
UNKNOWN: This method auto-detects URLs in strings, and adds HTML markup to them so that richtext or HTML-enabled widgets (such as KActiveLabel) will display the URL correctly.
Parameters: text the string to search for the words range the words to return (see description)
Returns: the words, or an empty string if not found
UNKNOWN: Returns a range of words from that string.