Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
/**
* decomposeByFixLength: decompose a String in parts depending on a list of positions
*
*
* {talendTypes} String
*
* {Category} User Defined
*
* {param} string("") text: The string which should be cut in parts
*
* {param} int("") length: The length of each part
*
* {example} decomposeByFixLength("this is a string", new int[]{3,3,1}) # "thi", "s i", "s".
*/
public static String[] decomposeByFixLength(String text, int[] length) {
if(text == null) return null;
String[] extractedParts= new String;
int actualPart= 0;
for (int len: length) {
extractedParts= text.substring(0, java.lang.Math.min(text.length(), len));
text= text.substring(java.lang.Math.min(text.length(), len));
}
return extractedParts;
}
/**
* join: joins strings together with a given separator
*
*
* {talendTypes} String
*
* {Category} User Defined
*
* {param} String("") parts: Array of Strings to join
*
* {param} String("") separator: Separator for the concatenated string parts
*
* {example} join(new String[]{"this","is","a","test"}, ",") # "this,is,a,test".
*/
public static String join(String[] parts, String separator) {
if(parts.length == 0) return "";
StringBuffer buf = new StringBuffer();
buf.append(parts);
for(int i=1,n=parts.length; i<n; i++)
buf.append(separator).append(parts);
return buf.toString();
}
decomposeString.join(decomposeString.decomposeByFixLength(rha.ACTES, new int {8,8,8} ),",")
rha.ACTES.substring(0, java.lang.Math.min(rha.ACTES.length(),8))
/**
* decomposeByFixLength: decompose a String in parts depending on a list of positions
*
*
* {talendTypes} String
*
* {Category} User Defined
*
* {param} string("") text: The string which should be cut in parts
*
* {param} int("") length: The length of each part
*
* {example} decomposeByFixLength("this is a string", new int[]{3,3,1}) # "thi", "s i", "s".
*/
public static String[] decomposeByFixLength(String text, int[] length) {
if(text == null) return null;
String[] extractedParts= new String;
int actualPart= 0;
for (int len: length) {
extractedParts= text.substring(0, java.lang.Math.min(text.length(), len));
text= text.substring(java.lang.Math.min(text.length(), len));
}
return extractedParts;
}
/**
* join: joins strings together with a given separator
*
*
* {talendTypes} String
*
* {Category} User Defined
*
* {param} String("") parts: Array of Strings to join
*
* {param} String("") separator: Separator for the concatenated string parts
*
* {example} join(new String[]{"this","is","a","test"}, ",") # "this,is,a,test".
*/
public static String join(String[] parts, String separator) {
if(parts.length == 0) return "";
StringBuffer buf = new StringBuffer();
buf.append(parts);
for(int i=1,n=parts.length; i<n; i++)
buf.append(separator).append(parts);
return buf.toString();
}
decomposeString.join(decomposeString.decomposeByFixLength(rha.ACTES, new int {8,8,8} ),",")
java.lang.NumberFormatException: For input string: "" (because currently in the file workPhone is blank, but in other files it may not be