Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package routines;
- /*
- * user specification: the function's comment should contain keys as follows: 1. write about the function's comment.but
- * it must be before the "{talendTypes}" key.
- *
- * 2. {talendTypes} 's value must be talend Type, it is required . its value should be one of: String, char | Character,
- * long | Long, int | Integer, boolean | Boolean, byte | Byte, Date, double | Double, float | Float, Object, short |
- * Short
- *
- * 3. {Category} define a category for the Function. it is required. its value is user-defined .
- *
- * 4. {param} 's format is: {param} <type>[(<default value or closed list values>)] <name>[ : <comment>]
- *
- * <type> 's value should be one of: string, int, list, double, object, boolean, long, char, date. <name>'s value is the
- * Function's parameter name. the {param} is optional. so if you the Function without the parameters. the {param} don't
- * added. you can have many parameters for the Function.
- *
- * 5. {example} gives a example for the Function. it is optional.
- */
- public class split {
- /**
- * get : retourne le ième élément d'un tableau
- *
- *
- * {talendTypes} String
- *
- * {Category} User Defined
- *
- * {message} string("message.message") input: The string need to be printed.
- *
- */
- public static String get(String[] tab, int i) {
- if(i < tab.length && i >= 0){
- return tab[i];
- } else {
- return "";
- }
- }
- /**
- * split: split un message et retourne le ième élément.
- *
- *
- * {talendTypes} String
- *
- * {Category} User Defined
- *
- * {message} string("message.message") input: The string need to be printed.
- *
- */
- public static String split(String message, String split, int i) {
- if(message != null && !message.isEmpty()){
- String[] mes = message.split(split);
- if(mes.length>0){
- if(i < mes.length && i >= 0){
- return mes[i];
- } else {
- return "";
- }
- }
- }
- return "";
- }
- /**
- * split1: split un message et retourne le 1er élément.
- *
- *
- * {talendTypes} String
- *
- * {Category} User Defined
- *
- * {message} string("message.message") input: The string need to be printed.
- *
- */
- public static String split1(String message, String split) {
- if(message != null && !message.isEmpty()){
- String[] mes = message.split(split);
- if(mes.length>0){
- return mes[0];
- }
- }
- return "";
- }
- /**
- * split2: split un message et retourne le 2ème élément.
- *
- *
- * {talendTypes} String
- *
- * {Category} User Defined
- *
- * {message} string("message.message") input: The string need to be printed.
- *
- */
- public static String split2(String message, String split) {
- if(message != null && !message.isEmpty()){
- String[] mes = message.split(split);
- if(mes.length>=1){
- return mes[1];
- }
- }
- return "";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement