| 111 | import com.google.common.collect.Lists; |
| 112 | |
| 113 | public class Util { |
| 114 | private static BagFactory mBagFactory = BagFactory.getInstance(); |
| 115 | private static TupleFactory mTupleFactory = TupleFactory.getInstance(); |
| 116 | |
| 117 | // Commonly-checked system state |
| 118 | // ================= |
| 119 | public static final boolean WINDOWS /* borrowed from Path.WINDOWS, Shell.WINDOWS */ |
| 120 | = System.getProperty("os.name").startsWith("Windows"); |
| 121 | |
| 122 | public static final String TEST_DIR = System.getProperty("test.build.dir", "build/test"); |
| 123 | |
| 124 | // Helper Functions |
| 125 | // ================= |
| 126 | |
| 127 | static public Tuple loadFlatTuple(Tuple t, int[] input) throws ExecException { |
| 128 | for (int i = 0; i < input.length; i++) { |
| 129 | t.set(i, new Integer(input[i])); |
| 130 | } |
| 131 | return t; |
| 132 | } |
| 133 | |
| 134 | static public Tuple loadTuple(Tuple t, String[] input) throws ExecException { |
| 135 | for (int i = 0; i < input.length; i++) { |
| 136 | t.set(i, input[i]); |
| 137 | } |
| 138 | return t; |
| 139 | } |
| 140 | |
| 141 | static public Tuple loadTuple(Tuple t, DataByteArray[] input) throws ExecException { |
| 142 | for (int i = 0; i < input.length; i++) { |
| 143 | t.set(i, input[i]); |
| 144 | } |
| 145 | return t; |
| 146 | } |
| 147 | |
| 148 | static public Tuple loadNestTuple(Tuple t, int[] input) throws ExecException { |
| 149 | DataBag bag = BagFactory.getInstance().newDefaultBag(); |
| 150 | for(int i = 0; i < input.length; i++) { |
| 151 | Tuple f = TupleFactory.getInstance().newTuple(1); |
| 152 | f.set(0, input[i]); |
| 153 | bag.add(f); |
| 154 | } |
| 155 | t.set(0, bag); |
| 156 | return t; |
| 157 | } |
| 158 | |
| 159 | static public Tuple loadNestTuple(Tuple t, long[] input) throws ExecException { |
| 160 | DataBag bag = BagFactory.getInstance().newDefaultBag(); |
| 161 | for(int i = 0; i < input.length; i++) { |
| 162 | Tuple f = TupleFactory.getInstance().newTuple(1); |
| 163 | f.set(0, new Long(input[i])); |
| 164 | bag.add(f); |
| 165 | } |
| 166 | t.set(0, bag); |
| 167 | return t; |
| 168 | } |
| 169 | |
| 170 | // this one should handle String, DataByteArray, Long, Integer etc.. |
nothing calls this directly
no test coverage detected