public class StringUtil
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
capitalize(java.lang.String string) |
static java.lang.String |
join(java.lang.Iterable<java.lang.String> values,
java.lang.String separator) |
static java.lang.String |
join(java.lang.String[] values,
java.lang.String separator) |
static java.lang.String |
methodMatchingError(java.util.List<IJavaMethod> methods,
Expression... arguments)
If a set of methods is available and none matches, this method creates a
suitable message.
|
static java.lang.String[] |
split(java.lang.String value,
char delimiter)
Splits a string in parts, given a specified delimiter.
|
static java.lang.String[] |
splitParagraphs(java.lang.String value)
Processes a doc comment into paragraphs.
|
static java.lang.String |
unescapeString(java.lang.String oldstr)
unescape_perl_string()
|
public static java.lang.String join(java.lang.String[] values,
java.lang.String separator)
public static java.lang.String join(java.lang.Iterable<java.lang.String> values,
java.lang.String separator)
public static java.lang.String methodMatchingError(java.util.List<IJavaMethod> methods, Expression... arguments)
methods - matching methodsarguments - calling argumentspublic static java.lang.String[] split(java.lang.String value,
char delimiter)
value - string to be splitdelimiter - delimiterpublic static java.lang.String[] splitParagraphs(java.lang.String value)
value - input valuepublic static java.lang.String unescapeString(java.lang.String oldstr)
Tom Christiansen
It's completely ridiculous that there's no standard unescape_java_string
function. Since I have to do the damn thing myself, I might as well make
it halfway useful by supporting things Java was too stupid to consider in
strings:
=> "?" items are additions to Java string escapes but normal in Java
regexes
=> "!" items are also additions to Java regex escapes
Standard singletons: ?\a ?\e \f \n \r \t
NB: \b is unsupported as backspace so it can pass-through to the regex
translator untouched; I refuse to make anyone doublebackslash it as
doublebackslashing is a Java idiocy I desperately wish would die out.
There are plenty of other ways to write it:
\cH, \12, \012, \x08 \x{8}, , \U00000008
Octal escapes: \0 \0N \0NN \N \NN \NNN Can range up to !\777 not \377
TODO: add !\o{NNNNN} last Unicode is 4177777 maxint is 37777777777
Control chars: ?\cX Means: ord(X) ^ ord('@')
Old hex escapes: \xXX unbraced must be 2 xdigits
Perl hex escapes: !\x{XXX} braced may be 1-8 xdigits NB: proper Unicode
never needs more than 6, as highest valid codepoint is 0x10FFFF, not
maxint 0xFFFFFFFF
Lame Java escape: \[IDIOT JAVA PREPROCESSOR]uXXXX must be exactly 4
xdigits;
I can't write XXXX in this comment where it belongs because the damned
Java Preprocessor can't mind its own business. Idiots!
Lame Python escape: !\UXXXXXXXX must be exactly 8 xdigits
TODO: Perl translation escapes: \Q \U \L \E \[IDIOT JAVA PREPROCESSOR]u
\l These are not so important to cover if you're passing the result to
Pattern.compile(), since it handles them for you further downstream. Hm,
what about \[IDIOT JAVA PREPROCESSOR]u?
oldstr - public static java.lang.String capitalize(java.lang.String string)