Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. package routines;
  2.  
  3. /*
  4. * user specification: the function's comment should contain keys as follows: 1. write about the function's comment.but
  5. * it must be before the "{talendTypes}" key.
  6. *
  7. * 2. {talendTypes} 's value must be talend Type, it is required . its value should be one of: String, char | Character,
  8. * long | Long, int | Integer, boolean | Boolean, byte | Byte, Date, double | Double, float | Float, Object, short |
  9. * Short
  10. *
  11. * 3. {Category} define a category for the Function. it is required. its value is user-defined .
  12. *
  13. * 4. {param} 's format is: {param} <type>[(<default value or closed list values>)] <name>[ : <comment>]
  14. *
  15. * <type> 's value should be one of: string, int, list, double, object, boolean, long, char, date. <name>'s value is the
  16. * Function's parameter name. the {param} is optional. so if you the Function without the parameters. the {param} don't
  17. * added. you can have many parameters for the Function.
  18. *
  19. * 5. {example} gives a example for the Function. it is optional.
  20. */
  21. public class split {
  22.  
  23. /**
  24. * get : retourne le ième élément d'un tableau
  25. *
  26. *
  27. * {talendTypes} String
  28. *
  29. * {Category} User Defined
  30. *
  31. * {message} string("message.message") input: The string need to be printed.
  32. *
  33. */
  34. public static String get(String[] tab, int i) {
  35. if(i < tab.length && i >= 0){
  36. return tab[i];
  37. } else {
  38. return "";
  39. }
  40. }
  41.  
  42. /**
  43. * split: split un message et retourne le ième élément.
  44. *
  45. *
  46. * {talendTypes} String
  47. *
  48. * {Category} User Defined
  49. *
  50. * {message} string("message.message") input: The string need to be printed.
  51. *
  52. */
  53. public static String split(String message, String split, int i) {
  54. if(message != null && !message.isEmpty()){
  55. String[] mes = message.split(split);
  56. if(mes.length>0){
  57. if(i < mes.length && i >= 0){
  58. return mes[i];
  59. } else {
  60. return "";
  61. }
  62. }
  63. }
  64. return "";
  65. }
  66.  
  67. /**
  68. * split1: split un message et retourne le 1er élément.
  69. *
  70. *
  71. * {talendTypes} String
  72. *
  73. * {Category} User Defined
  74. *
  75. * {message} string("message.message") input: The string need to be printed.
  76. *
  77. */
  78. public static String split1(String message, String split) {
  79. if(message != null && !message.isEmpty()){
  80. String[] mes = message.split(split);
  81. if(mes.length>0){
  82. return mes[0];
  83. }
  84. }
  85. return "";
  86. }
  87.  
  88. /**
  89. * split2: split un message et retourne le 2ème élément.
  90. *
  91. *
  92. * {talendTypes} String
  93. *
  94. * {Category} User Defined
  95. *
  96. * {message} string("message.message") input: The string need to be printed.
  97. *
  98. */
  99. public static String split2(String message, String split) {
  100. if(message != null && !message.isEmpty()){
  101. String[] mes = message.split(split);
  102. if(mes.length>=1){
  103. return mes[1];
  104. }
  105. }
  106. return "";
  107. }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement