Java Utililty Methods String Collapse

List of utility methods to do String Collapse

  1. HOME
  2. Java
  3. S
  4. String Collapse

Description

The list of methods to do String Collapse are organized into topic(s).

Method

char collapse(char c)
collapse
if (c >= diacritics.length) {
 return c;
char tc = diacritics[c];
return (tc == 0) ? c : tc;
double collapse(double[] w)
collapse
if (w == null) {
 return 0.0;
double summ = 0.0d;
for (int i = 0; i < w.length; i++) {
 summ += w[i];
return summ;
...
float[] collapse(float[][] array)
Collapse a two-dimensional array to a one-dimensional one
float[] a = new float[array[0].length * array.length];
int i = 0;
for (int x = 0; x < array.length; x++) {
 for (int y = 0; y < array[x].length; y++) {
 a[i++] = array[x][y];
return a;
...
String collapse(String str, String characters, String replacement)
collapse
if (str == null) {
 return null;
StringBuffer newStr = new StringBuffer();
boolean prevCharMatched = false;
char c;
for (int i = 0; i < str.length(); i++) {
 c = str.charAt(i);
...
String collapse(String t)
collapse
for (int i = 0, length = t.length(); i < length; i++)
 if (!Character.isWhitespace(t.charAt(i)))
 for (int j = length - 1; j >= i; j--)
 if (!Character.isWhitespace(t.charAt(j)))
 return (i > 0 ? " " : "") + t.substring(i, j + 1) + (j < length - 1 ? " " : "");
return "";
String collapse(String text)
Collapses whitespace
int len = text.length();
int s = 0;
while (s < len) {
 if (isWhiteSpace(text.charAt(s)))
 break;
 s++;
if (s == len)
...
String collapsedName(Class klass)
collapsed Name
String name = klass.getName();
if (name.startsWith(PREFIX_RESOURCES)) {
 return SHORT_RESOURCES + name.substring(PREFIX_RESOURCES.length());
if (name.startsWith(PREFIX)) {
 return SHORT + name.substring(PREFIX.length());
return name;
...
String collapseLines(String message)
Returns a string with all break lines replaced by the string "\n"
return message.replaceAll("\n", "\\\\n");
String collapseMultipleNewlinesToOne(String s)
collapse Multiple Newlines To One
return s.replaceAll("\\\n+", "\\\n");
String collapseName(String name)
Collapse primitive type names.
if (name.equals("unsigned short"))
 name = "ushort";
else if (name.equals("unsigned long"))
 name = "ulong";
else if (name.equals("unsigned long long"))
 name = "ulonglong";
else if (name.equals("long long"))
 name = "longlong";
...


AltStyle によって変換されたページ (->オリジナル) /