@Test(expected = JsonFormatException.class) public void slicesToString_invalid1() throws JsonFormatException, IOException { List<JsonSlice> slices; slices = new ArrayList<JsonSlice>(); slices.add(new JsonSlice(State.START_HASH)); slices.add(new JsonSlice(State.START_ARRAY)); slices.add(new JsonSlice(State.END_ARRAY)); slices.add(new JsonSlice(State.END_HASH)); JsonSliceUtil.slicesToString(slices); }
public static String slicesToString(List<JsonSlice> slices) throws JsonFormatException, IOException { if (slices == null || slices.size() == 0) { throw new JsonFormatException("slices is null or empty."); } StringWriter writer = new StringWriter(); int cnt = slices.size(); for (int i = 0; i < cnt; i++) { JsonSlice slice = slices.get(i); if (slice == null) { throw new JsonFormatException("slice is null. i=" + i); } switch (slice.getState()) { case START_ARRAY: i = slicesToStringInArray(slices, i, writer); break; case START_HASH: i = slicesToStringInHash(slices, i, writer); break; default: throw new JsonFormatException("invalid state. i=" + i + " is " + slice.getState()); } } return writer.toString(); }
JsonSliceUtil { public static String slicesToString(List<JsonSlice> slices) throws JsonFormatException, IOException { if (slices == null || slices.size() == 0) { throw new JsonFormatException("slices is null or empty."); } StringWriter writer = new StringWriter(); int cnt = slices.size(); for (int i = 0; i < cnt; i++) { JsonSlice slice = slices.get(i); if (slice == null) { throw new JsonFormatException("slice is null. i=" + i); } switch (slice.getState()) { case START_ARRAY: i = slicesToStringInArray(slices, i, writer); break; case START_HASH: i = slicesToStringInHash(slices, i, writer); break; default: throw new JsonFormatException("invalid state. i=" + i + " is " + slice.getState()); } } return writer.toString(); } }
JsonSliceUtil { public static String slicesToString(List<JsonSlice> slices) throws JsonFormatException, IOException { if (slices == null || slices.size() == 0) { throw new JsonFormatException("slices is null or empty."); } StringWriter writer = new StringWriter(); int cnt = slices.size(); for (int i = 0; i < cnt; i++) { JsonSlice slice = slices.get(i); if (slice == null) { throw new JsonFormatException("slice is null. i=" + i); } switch (slice.getState()) { case START_ARRAY: i = slicesToStringInArray(slices, i, writer); break; case START_HASH: i = slicesToStringInHash(slices, i, writer); break; default: throw new JsonFormatException("invalid state. i=" + i + " is " + slice.getState()); } } return writer.toString(); }  }
JsonSliceUtil { public static String slicesToString(List<JsonSlice> slices) throws JsonFormatException, IOException { if (slices == null || slices.size() == 0) { throw new JsonFormatException("slices is null or empty."); } StringWriter writer = new StringWriter(); int cnt = slices.size(); for (int i = 0; i < cnt; i++) { JsonSlice slice = slices.get(i); if (slice == null) { throw new JsonFormatException("slice is null. i=" + i); } switch (slice.getState()) { case START_ARRAY: i = slicesToStringInArray(slices, i, writer); break; case START_HASH: i = slicesToStringInHash(slices, i, writer); break; default: throw new JsonFormatException("invalid state. i=" + i + " is " + slice.getState()); } } return writer.toString(); }  static String slicesToString(List<JsonSlice> slices); }
JsonSliceUtil { public static String slicesToString(List<JsonSlice> slices) throws JsonFormatException, IOException { if (slices == null || slices.size() == 0) { throw new JsonFormatException("slices is null or empty."); } StringWriter writer = new StringWriter(); int cnt = slices.size(); for (int i = 0; i < cnt; i++) { JsonSlice slice = slices.get(i); if (slice == null) { throw new JsonFormatException("slice is null. i=" + i); } switch (slice.getState()) { case START_ARRAY: i = slicesToStringInArray(slices, i, writer); break; case START_HASH: i = slicesToStringInHash(slices, i, writer); break; default: throw new JsonFormatException("invalid state. i=" + i + " is " + slice.getState()); } } return writer.toString(); }  static String slicesToString(List<JsonSlice> slices);  }