@Test public void testConvertStructureDataToArray() throws IOException { Array<?> sda = ArraysConvert.convertToArray(ma2Struct); assertThat(sda.getDataType()).isEqualTo(ma2Struct.getDataType()); assertThat(sda.getShape()).isEqualTo(ma2Struct.getShape()); assertThat(sda.length()).isEqualTo(ma2Struct.getSize()); Formatter f = new Formatter(); boolean ok = CompareArrayToMa2.compareData(f, "testConvertStructureData", ma2Struct, sda, false, true); if (!ok) { System.out.printf("%s%n", f); } assertThat(ok).isTrue(); }
public static Array<?> convertToArray(ucar.ma2.Array from) { if (from.isVlen()) { return convertVlen(from); } DataType dtype = from.getDataType(); if (dtype == DataType.OPAQUE) { return convertOpaque(from); } else if (dtype == DataType.STRING) { String[] sarray = new String[(int) from.getSize()]; for (int idx = 0; idx < sarray.length; idx++) { sarray[idx] = (String) from.getObject(idx); } return Arrays.factory(dtype, from.getShape(), sarray); } else if (dtype == DataType.STRUCTURE) { return convertArrayStructure(from); } else { return Arrays.factory(dtype, from.getShape(), from.get1DJavaArray(dtype)); } }
ArraysConvert { public static Array<?> convertToArray(ucar.ma2.Array from) { if (from.isVlen()) { return convertVlen(from); } DataType dtype = from.getDataType(); if (dtype == DataType.OPAQUE) { return convertOpaque(from); } else if (dtype == DataType.STRING) { String[] sarray = new String[(int) from.getSize()]; for (int idx = 0; idx < sarray.length; idx++) { sarray[idx] = (String) from.getObject(idx); } return Arrays.factory(dtype, from.getShape(), sarray); } else if (dtype == DataType.STRUCTURE) { return convertArrayStructure(from); } else { return Arrays.factory(dtype, from.getShape(), from.get1DJavaArray(dtype)); } } }
ArraysConvert { public static Array<?> convertToArray(ucar.ma2.Array from) { if (from.isVlen()) { return convertVlen(from); } DataType dtype = from.getDataType(); if (dtype == DataType.OPAQUE) { return convertOpaque(from); } else if (dtype == DataType.STRING) { String[] sarray = new String[(int) from.getSize()]; for (int idx = 0; idx < sarray.length; idx++) { sarray[idx] = (String) from.getObject(idx); } return Arrays.factory(dtype, from.getShape(), sarray); } else if (dtype == DataType.STRUCTURE) { return convertArrayStructure(from); } else { return Arrays.factory(dtype, from.getShape(), from.get1DJavaArray(dtype)); } }  }
ArraysConvert { public static Array<?> convertToArray(ucar.ma2.Array from) { if (from.isVlen()) { return convertVlen(from); } DataType dtype = from.getDataType(); if (dtype == DataType.OPAQUE) { return convertOpaque(from); } else if (dtype == DataType.STRING) { String[] sarray = new String[(int) from.getSize()]; for (int idx = 0; idx < sarray.length; idx++) { sarray[idx] = (String) from.getObject(idx); } return Arrays.factory(dtype, from.getShape(), sarray); } else if (dtype == DataType.STRUCTURE) { return convertArrayStructure(from); } else { return Arrays.factory(dtype, from.getShape(), from.get1DJavaArray(dtype)); } }  static Array<?> convertToArray(ucar.ma2.Array from); static ucar.ma2.Array convertFromArray(Array<?> from); }
ArraysConvert { public static Array<?> convertToArray(ucar.ma2.Array from) { if (from.isVlen()) { return convertVlen(from); } DataType dtype = from.getDataType(); if (dtype == DataType.OPAQUE) { return convertOpaque(from); } else if (dtype == DataType.STRING) { String[] sarray = new String[(int) from.getSize()]; for (int idx = 0; idx < sarray.length; idx++) { sarray[idx] = (String) from.getObject(idx); } return Arrays.factory(dtype, from.getShape(), sarray); } else if (dtype == DataType.STRUCTURE) { return convertArrayStructure(from); } else { return Arrays.factory(dtype, from.getShape(), from.get1DJavaArray(dtype)); } }  static Array<?> convertToArray(ucar.ma2.Array from); static ucar.ma2.Array convertFromArray(Array<?> from);  }