| 1 | package felix.util; |
| 2 | |
| 3 | import java.util.ArrayList; |
| 4 | import java.util.Collection; |
| 5 | import java.util.HashSet; |
| 6 | |
| 7 | import tuffy.util.StringMan; |
| 8 | |
| 9 | /** |
| 10 | * Container of string related utilities. |
| 11 | */ |
| 12 | public class FelixStringMan extends StringMan{ |
| 13 | |
| 14 | /** |
| 15 | * Returns comma separated list with no spaces for given list. |
| 16 | * @param parts |
| 17 | * @return |
| 18 | */ |
| 19 | public static String commaListNoSpace(ArrayList<String> parts) { |
| 20 | return StringMan.join(",", parts); |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * Returns current indentation. |
| 25 | * @return |
| 26 | */ |
| 27 | public static String indentHead(){ |
| 28 | String ret = ""; |
| 29 | for(int i=0;i<FelixConfig.currentIndent;i++){ |
| 30 | ret += "\t"; |
| 31 | } |
| 32 | return ret; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Returns newline + current indentation. |
| 37 | * @return |
| 38 | */ |
| 39 | public static String nextLine(){ |
| 40 | String ret = "\n"; |
| 41 | for(int i=0;i<FelixConfig.currentIndent;i++){ |
| 42 | ret += "\t"; |
| 43 | } |
| 44 | return ret; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Returns HashSet for given object. |
| 49 | * @param obj |
| 50 | * @return |
| 51 | */ |
| 52 | public static <A> HashSet<A> toHashSet(A obj){ |
| 53 | HashSet<A> ret = new HashSet<A>(); |
| 54 | ret.add(obj); |
| 55 | return ret; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Returns ArrayList for given collection. |
| 60 | * @param _coll |
| 61 | * @return |
| 62 | */ |
| 63 | public static <A> ArrayList<String> colToStringArray(Collection<A> _coll){ |
| 64 | ArrayList<String> ret = new ArrayList<String>(); |
| 65 | for(A a : _coll){ |
| 66 | ret.add(a.toString()); |
| 67 | } |
| 68 | return ret; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Returns ArrayList for given object. |
| 73 | * @param _coll |
| 74 | * @return |
| 75 | */ |
| 76 | public static <A> ArrayList<String> colToStringArray(A... _coll){ |
| 77 | ArrayList<String> ret = new ArrayList<String>(); |
| 78 | for(A a : _coll){ |
| 79 | ret.add(a.toString()); |
| 80 | } |
| 81 | return ret; |
| 82 | } |
| 83 | |
| 84 | } |