JsonHandler extends HandlerBase { protected JsonObjectBuilder showArrayProperty(Property property) { boolean[] boolArray = null; byte[] byteArray = null; char[] charArray = null; java.util.Date[] dateArray = null; double[] doubleArray = null; float[] floatArray = null; int[] intArray = null; long[] longArray = null; Object[] objArray = null; Property[] propArray = null; short[] shortArray = null; String[] stringArray = null; Rational[] rationalArray = null; NisoImageMetadata[] nisoArray = null; AESAudioMetadata[] aesArray = null; TextMDMetadata[] textMDArray = null; int n = 0; PropertyType propType = property.getType(); switch (propType) { case BOOLEAN: boolArray = (boolean[]) property.getValue(); n = boolArray.length; break; case BYTE: byteArray = (byte[]) property.getValue(); n = byteArray.length; break; case CHARACTER: charArray = (char[]) property.getValue(); n = charArray.length; break; case DATE: dateArray = (Date[]) property.getValue(); n = dateArray.length; break; case DOUBLE: doubleArray = (double[]) property.getValue(); n = doubleArray.length; break; case FLOAT: floatArray = (float[]) property.getValue(); n = floatArray.length; break; case INTEGER: intArray = (int[]) property.getValue(); n = intArray.length; break; case LONG: longArray = (long[]) property.getValue(); n = longArray.length; break; case OBJECT: objArray = (Object[]) property.getValue(); n = objArray.length; break; case SHORT: shortArray = (short[]) property.getValue(); n = shortArray.length; break; case STRING: stringArray = (String[]) property.getValue(); n = stringArray.length; break; case RATIONAL: rationalArray = (Rational[]) property.getValue(); n = rationalArray.length; break; case PROPERTY: propArray = (Property[]) property.getValue(); n = propArray.length; break; case NISOIMAGEMETADATA: nisoArray = (NisoImageMetadata[]) property.getValue(); n = nisoArray.length; break; case AESAUDIOMETADATA: aesArray = (AESAudioMetadata[]) property.getValue(); n = aesArray.length; break; case TEXTMDMETADATA: textMDArray = (TextMDMetadata[]) property.getValue(); n = textMDArray.length; break; default: break; } JsonArrayBuilder arrayBuilder = Json.createArrayBuilder(); for (int i = 0; i < n; i++) { switch (propType) { case BOOLEAN: arrayBuilder.add(boolArray[i]); break; case BYTE: arrayBuilder.add(String.valueOf(byteArray[i])); break; case CHARACTER: arrayBuilder.add(String.valueOf(charArray[i])); break; case DATE: arrayBuilder.add(dateArray[i].toString()); break; case DOUBLE: arrayBuilder.add(doubleArray[i]); break; case FLOAT: arrayBuilder.add(floatArray[i]); break; case INTEGER: arrayBuilder.add(intArray[i]); break; case LONG: arrayBuilder.add(longArray[i]); break; case OBJECT: arrayBuilder.add(valueToString(objArray[i])); break; case SHORT: arrayBuilder.add(shortArray[i]); break; case STRING: arrayBuilder.add(stringArray[i]); break; case RATIONAL: arrayBuilder.add(rationalArray[i].toString()); break; case PROPERTY: arrayBuilder.add(showProperty(propArray[i])); break; case NISOIMAGEMETADATA: arrayBuilder.add(showNisoImageMetadata(nisoArray[i])); break; case AESAUDIOMETADATA: arrayBuilder.add(showAESAudioMetadata(aesArray[i])); break; case TEXTMDMETADATA: arrayBuilder.add(showTextMDMetadata(textMDArray[i])); break; default: arrayBuilder.add("<error>"); break; } } return Json.createObjectBuilder().add(property.getName(), arrayBuilder); } JsonHandler();  JsonHandler(String name, String release, int[] date, String note, String rights); @Override void show(); @Override void show(App app); @Override void show(OutputHandler handler); @Override void show(Module module); @Override void show(RepInfo info); @Override void showFooter(); @Override void showHeader();  }
@Test public void testShowArrayMapProperty() throws IOException { final boolean[] testArray = new boolean[]{true, false, true}; Property prop = new Property("test", PropertyType.BOOLEAN, PropertyArity.ARRAY, testArray); JsonObjectBuilder b = this.handler.showArrayProperty(prop); buildJson(b); handler.close(); String result = outString.toString(); LOGGER.info(FIND + result); final String expected = "{\"test\":[true,false,true]}"; assertEquals(expected, result); }