00001 package edu.tum.cs.util; 00002 00003 public class StringTool { 00004 public static String join(String glue, Object[] elems, int iStart, int iEnd) { 00005 StringBuffer res = new StringBuffer(); 00006 for(int i = iStart; i < iEnd; i++) { 00007 res.append(elems[i].toString()); 00008 if(i < iEnd-1) 00009 res.append(glue); 00010 } 00011 return res.toString(); 00012 } 00013 00014 public static String join(String glue, Object[] elems) { 00015 return join(glue, elems, 0, elems.length); 00016 } 00017 00018 public static String join(String glue, Iterable<?> elems) { 00019 StringBuffer res = new StringBuffer(); 00020 int i = 0; 00021 for(Object elem : elems) { 00022 if(i++ > 0) 00023 res.append(glue); 00024 res.append(elem.toString()); 00025 } 00026 return res.toString(); 00027 } 00028 00029 public static String join(String glue, double[] elems) { 00030 StringBuffer res = new StringBuffer(); 00031 for(int i = 0; i < elems.length; i++) { 00032 res.append(elems[i]); 00033 if(i < elems.length-1) 00034 res.append(glue); 00035 } 00036 return res.toString(); 00037 } 00038 }